Re: [PATCH] arm64: defconfig: Enable Qualcomm remoteproc dependencies
On 08-10-19, 17:14, Bjorn Andersson wrote: > Enable the the power domains, reset controllers and remote block device > memory access drivers necessary to boot the Audio, Compute and Modem > DSPs on Qualcomm SDM845. > > None of the power domains are system critical, but needs to be builtin > as the driver core prohibits probe deferal past late initcall. Reviewed-by: Vinod Koul Tested-by: Vinod Koul > > Signed-off-by: Bjorn Andersson > --- > arch/arm64/configs/defconfig | 5 + > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig > index c9a867ac32d4..42f042ba1039 100644 > --- a/arch/arm64/configs/defconfig > +++ b/arch/arm64/configs/defconfig > @@ -732,10 +732,13 @@ CONFIG_RPMSG_QCOM_GLINK_SMEM=m > CONFIG_RPMSG_QCOM_SMD=y > CONFIG_RASPBERRYPI_POWER=y > CONFIG_IMX_SCU_SOC=y > +CONFIG_QCOM_AOSS_QMP=y > CONFIG_QCOM_COMMAND_DB=y > CONFIG_QCOM_GENI_SE=y > CONFIG_QCOM_GLINK_SSR=m > +CONFIG_QCOM_RMTFS_MEM=m > CONFIG_QCOM_RPMH=y > +CONFIG_QCOM_RPMHPD=y > CONFIG_QCOM_SMEM=y > CONFIG_QCOM_SMD_RPM=y > CONFIG_QCOM_SMP2P=y > @@ -780,6 +783,8 @@ CONFIG_PWM_ROCKCHIP=y > CONFIG_PWM_SAMSUNG=y > CONFIG_PWM_SUN4I=m > CONFIG_PWM_TEGRA=m > +CONFIG_RESET_QCOM_AOSS=y > +CONFIG_RESET_QCOM_PDC=m > CONFIG_RESET_TI_SCI=y > CONFIG_PHY_XGENE=y > CONFIG_PHY_SUN4I_USB=y > -- > 2.18.0 -- ~Vinod
Re: [PATCH v2] ACPI / processor_idle: use ndelay instead of io port access for wait
Hi David, On 10/15/2019 7:48 PM, David Laight wrote: From: Yin Fengwei Sent: 15 October 2019 09:04 In function acpi_idle_do_entry(), an ioport access is used for dummy wait to guarantee hardware behavior. But it could trigger unnecessary vmexit in virtualization environment. If we run linux as guest and export all available native C state to guest, we did see many PM timer access triggered VMexit when guest enter deeper C state in our environment (We used ACRN hypervisor instead of kvm or xen which has PM timer emulated and exports all native C state to guest). According to the original comments of this part of code, io port access is only for dummy wait. We could use busy wait instead of io port access to guarantee hardware behavior and avoid unnecessary VMexit. You need some hard synchronisation instruction(s) after the inb() and before any kind of delay to ensure your delay code is executed after the inb() completes. I'm pretty sure that inb() is only synchronised with memory reads. Thanks a lot for the comments. I didn't find the common serializing instructions API in kernel (only memory barrier which is used to make sure of memory access). For Intel x86, cpuid could be used as serializing instruction. But it's not suitable for common code here. Do you have any suggestion? ... + /* profiling the time used for dummy wait op */ + ktime_get_real_ts64(); + inl(acpi_gbl_FADT.xpm_timer_block.address); + ktime_get_real_ts64(); That could be dominated by the cost of ktime_get_real_ts64(). It also need synchronising instructions. I did some testing. ktime_get_real_ts64() takes much less time than io port access. The test code is like: 1. local_irq_save(flag); ktime_get_real_ts64(); inl(acpi_gbl_FADT.xpm_timer_block.address); ktime_get_real_ts64(); local_irq_restore(flag); 2. local_irq_save(flag); ktime_get_real_ts64(); ktime_get_real_ts64(); local_irq_restore(flag); The delta in 1 is about 50ns. And delta in 2 is about 2000ns. The date is gotten on Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz. So I suppose the impact of ktime_get_real_ts64 is small. Regards Yin, Fengwei David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH v1 00/17] NVIDIA Tegra20 CPUFreq driver major update
On 16-10-19, 00:16, Dmitry Osipenko wrote: > Hello, > > This series moves intermediate-clk handling from tegra20-cpufreq into > tegra-clk driver, this allows us to switch to generic cpufreq-dt driver > which brings voltage scaling, per-hardware OPPs and Tegra30 support out > of the box. All boards need to adopt CPU OPPs in their device-trees in > order to get cpufreq support. This series adds OPPs only to selective > boards because there is assumption in a current device-trees that CPU > voltage is set for 1GHz freq and this won't work for those CPUs that > can go over 1GHz and thus require voltage regulators to be set up for > voltage scaling support (CC'ed Marcel for Toradex boards). We could > probably add delete-node for OPPs over 1GHz if there are not actively > maintained boards. How do you want to get these patches merged ? Can I just pick the cpufreq bits alone ? -- viresh
Re: [PATCH v3 2/3] bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd()
On Wed, Oct 16, 2019 at 05:44:31AM +0200, Christian Brauner wrote: > In v5.4-rc2 we added a new helper (cf. [1]) copy_struct_from_user(). > This helper is intended for all codepaths that copy structs from > userspace that are versioned by size. bpf_prog_get_info_by_fd() does > exactly what copy_struct_from_user() is doing. > Note that copy_struct_from_user() is calling min() already. So > technically, the min_t() call could go. But the info_len is used further > below so leave it. > > [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") > Cc: Alexei Starovoitov > Cc: Daniel Borkmann > Cc: b...@vger.kernel.org > Acked-by: Aleksa Sarai > Signed-off-by: Christian Brauner > --- > /* v1 */ > Link: > https://lore.kernel.org/r/20191009160907.10981-3-christian.brau...@ubuntu.com > > /* v2 */ > Link: > https://lore.kernel.org/r/20191016004138.24845-3-christian.brau...@ubuntu.com > - Alexei Starovoitov : > - remove unneeded initialization > > /* v3 */ > unchanged > --- > kernel/bpf/syscall.c | 9 +++-- > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 40edcaeccd71..151447f314ca 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -2306,20 +2306,17 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog > *prog, > union bpf_attr __user *uattr) > { > struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info); > - struct bpf_prog_info info = {}; > + struct bpf_prog_info info; > u32 info_len = attr->info.info_len; > struct bpf_prog_stats stats; > char __user *uinsns; > u32 ulen; > int err; > > - err = bpf_check_uarg_tail_zero(uinfo, sizeof(info), info_len); > + info_len = min_t(u32, sizeof(info), info_len); > + err = copy_struct_from_user(, sizeof(info), uinfo, info_len); really?! min?! Frankly I'm disappointed in quality of these patches. Especially considering it's v3. Just live the code alone.
Re: [PATCH 2/2] arm64: dts: sc7180: Add minimal dts/dtsi files for SC7180 soc
On 15-10-19, 16:03, Rajendra Nayak wrote: > + timer { > + compatible = "arm,armv8-timer"; > + interrupts = , > + , > + , > + ; > + }; > + > + clocks { Can we have these sorted alphabetically please > + xo_board: xo-board { > + compatible = "fixed-clock"; > + clock-frequency = <3840>; > + clock-output-names = "xo_board"; > + #clock-cells = <0>; > + }; > + > + sleep_clk: sleep-clk { > + compatible = "fixed-clock"; > + clock-frequency = <32764>; > + clock-output-names = "sleep_clk"; > + #clock-cells = <0>; > + }; > + > + bi_tcxo: bi_tcxo { why is this a clock defined here? Isnt this gcc clock? -- ~Vinod
Re: [PATCH v1 11/17] ARM: dts: tegra20: Add CPU Operating Performance Points
On 16-10-19, 00:16, Dmitry Osipenko wrote: > Operating Point are specified per HW version. The OPP voltages are kept > in a separate DTSI file because some boards may not define CPU regulator > in their device-tree if voltage scaling isn't necessary, like for example > in a case of tegra20-trimslice which is outlet-powered device. > > Signed-off-by: Dmitry Osipenko > --- > .../boot/dts/tegra20-cpu-opp-microvolt.dtsi | 201 > arch/arm/boot/dts/tegra20-cpu-opp.dtsi| 302 ++ > 2 files changed, 503 insertions(+) > create mode 100644 arch/arm/boot/dts/tegra20-cpu-opp-microvolt.dtsi > create mode 100644 arch/arm/boot/dts/tegra20-cpu-opp.dtsi > > diff --git a/arch/arm/boot/dts/tegra20-cpu-opp-microvolt.dtsi > b/arch/arm/boot/dts/tegra20-cpu-opp-microvolt.dtsi > new file mode 100644 > index ..e85ffdbef876 > --- /dev/null > +++ b/arch/arm/boot/dts/tegra20-cpu-opp-microvolt.dtsi > @@ -0,0 +1,201 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +/ { > + cpu0_opp_table: cpu_opp_table0 { > + opp@21600_750 { Maybe just drop the _750 (i.e. voltage) from the names as we don't generally follow it :) > + opp-microvolt = <75 75 1125000>; > + }; -- viresh
Re: [PATCH v3 1/3] bpf: use check_zeroed_user() in bpf_check_uarg_tail_zero()
On Wed, Oct 16, 2019 at 05:44:30AM +0200, Christian Brauner wrote: > In v5.4-rc2 we added a new helper (cf. [1]) check_zeroed_user() which > does what bpf_check_uarg_tail_zero() is doing generically. We're slowly > switching such codepaths over to use check_zeroed_user() instead of > using their own hand-rolled version. > > [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") > Cc: Alexei Starovoitov > Cc: Daniel Borkmann > Cc: b...@vger.kernel.org > Acked-by: Aleksa Sarai > Signed-off-by: Christian Brauner > --- > /* v1 */ > Link: > https://lore.kernel.org/r/20191009160907.10981-2-christian.brau...@ubuntu.com > > /* v2 */ > Link: > https://lore.kernel.org/r/20191016004138.24845-2-christian.brau...@ubuntu.com > - Alexei Starovoitov : > - Add a comment in bpf_check_uarg_tail_zero() to clarify that > copy_struct_from_user() should be used whenever possible instead. > > /* v3 */ > - Christian Brauner : > - use correct checks for check_zeroed_user() > --- > kernel/bpf/syscall.c | 25 + > 1 file changed, 9 insertions(+), 16 deletions(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 82eabd4e38ad..40edcaeccd71 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -58,35 +58,28 @@ static const struct bpf_map_ops * const bpf_map_types[] = > { > * There is a ToCToU between this function call and the following > * copy_from_user() call. However, this is not a concern since this function > is > * meant to be a future-proofing of bits. > + * > + * Note, instead of using bpf_check_uarg_tail_zero() followed by > + * copy_from_user() use the dedicated copy_struct_from_user() helper which > + * performs both tasks whenever possible. > */ > int bpf_check_uarg_tail_zero(void __user *uaddr, >size_t expected_size, >size_t actual_size) > { > - unsigned char __user *addr; > - unsigned char __user *end; > - unsigned char val; > + size_t size = min(expected_size, actual_size); > + size_t rest = max(expected_size, actual_size) - size; > int err; > > if (unlikely(actual_size > PAGE_SIZE)) /* silly large */ > return -E2BIG; > > - if (unlikely(!access_ok(uaddr, actual_size))) > - return -EFAULT; > - > if (actual_size <= expected_size) > return 0; > > - addr = uaddr + expected_size; > - end = uaddr + actual_size; > - > - for (; addr < end; addr++) { > - err = get_user(val, addr); > - if (err) > - return err; > - if (val) > - return -E2BIG; > - } > + err = check_zeroed_user(uaddr + expected_size, rest); Just noticed this 'rest' math. I bet compiler can optimize unnecessary min+max, but let's save it from that job. Just do actual_size - expected_size here instead.
Re: [PATCH] of-thermal: Disable polling when interrupt property is found in DT
On Wed, Oct 16, 2019 at 10:27 AM Stephen Boyd wrote: > > Quoting Amit Kucheria (2019-10-15 16:13:16) > > Currently, in order to enable interrupt-only mode, one must set > > polling-delay-passive and polling-delay properties in the DT to 0, > > otherwise the thermal framework will continue to setup a periodic timers > > to monitor the thermal zones. > > > > Change the behaviour, so that on DT-based systems, we no longer have to > > set the properties to zero if we find an 'interrupt' property in the > > sensor. > > > > Following data shows the number of times > > thermal_zone_device_set_polling() is invoked with and without this > > patch. So the patch achieves the same behaviour as setting the delay > > properties to 0. > > > > Current behaviour (without setting delay properties to 0): > > FUNC COUNT > > thermal_zone_device_update 302 > > thermal_zone_device_set_pollin 7911 > > thermal_zone_device_set_polling? Yes, the script I was using restricted the width of the fn name while printing. > > > > > Current behaviour (with delay properties set to 0): > > FUNC COUNT > > thermal_zone_device_update3 > > thermal_zone_device_set_pollin6 > > > > With this patch (without setting delay properties to 0): > > FUNC COUNT > > thermal_zone_device_update3 > > thermal_zone_device_set_pollin6 > > > > Suggested-by: Stephen Boyd > > Signed-off-by: Amit Kucheria > > --- > > Reviewed-by: Stephen Boyd >
Re: [PATCH 1/2] dt-bindings: qcom: Add SC7180 bindings
On 15-10-19, 16:03, Rajendra Nayak wrote: > Add a SoC string 'sc7180' for the qualcomm SC7180 SoC. > Also add a new board type 'idp' Reviewed-by: Vinod Koul > > Signed-off-by: Rajendra Nayak > --- > Documentation/devicetree/bindings/arm/qcom.yaml | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/Documentation/devicetree/bindings/arm/qcom.yaml > b/Documentation/devicetree/bindings/arm/qcom.yaml > index e39d8f02e33c..0a60ea051541 100644 > --- a/Documentation/devicetree/bindings/arm/qcom.yaml > +++ b/Documentation/devicetree/bindings/arm/qcom.yaml > @@ -36,6 +36,7 @@ description: | > mdm9615 > ipq8074 > sdm845 > + sc7180 > >The 'board' element must be one of the following strings: > > @@ -46,6 +47,7 @@ description: | > sbc > hk01 > qrd > + idp > >The 'soc_version' and 'board_version' elements take the form of > v. >where the minor number may be omitted when it's zero, i.e. v1.0 is the > same > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member > of Code Aurora Forum, hosted by The Linux Foundation -- ~Vinod
Re: [PATCH v1 07/17] cpufreq: tegra20: Use generic cpufreq-dt driver (Tegra30 supported now)
On 16-10-19, 00:16, Dmitry Osipenko wrote: > Re-parenting to intermediate clock is supported now by the clock driver > and thus there is no need in a customized CPUFreq driver, all that code > is common for both Tegra20 and Tegra30. The available CPU freqs are now > specified in device-tree in a form of OPPs, all users should update their > device-trees. > > Signed-off-by: Dmitry Osipenko > --- > drivers/cpufreq/Kconfig.arm | 4 +- > drivers/cpufreq/cpufreq-dt-platdev.c | 2 + > drivers/cpufreq/tegra20-cpufreq.c| 236 ++- > 3 files changed, 55 insertions(+), 187 deletions(-) > > diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm > index a905796f7f85..2118c45d0acd 100644 > --- a/drivers/cpufreq/Kconfig.arm > +++ b/drivers/cpufreq/Kconfig.arm > @@ -301,8 +301,8 @@ config ARM_TANGO_CPUFREQ > default y > > config ARM_TEGRA20_CPUFREQ > - tristate "Tegra20 CPUFreq support" > - depends on ARCH_TEGRA > + bool "Tegra20 CPUFreq support" Google is currently working on the GKI (generic kernel image) project where they want to use a single kernel image with modules for all kind of android devices. And for that they need all such drivers to be built as module. Since this is already an module, I would ask you to keep it as is instead of moving it to bool here. Else some google guy will switch it back as module later on. LGTM otherwise. Nice work. Thanks. -- viresh
[PATCH 1/2] kbuild: reduce KBUILD_SINGLE_TARGETS as descending into subdirectories
KBUILD_SINGLE_TARGETS does not need to contain all the targets. Change it to keep track the targets only from the current directory and its subdirectories. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a9e47953ca53..dcbb0124dac4 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -469,15 +469,15 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \ ifdef single-build +KBUILD_SINGLE_TARGETS := $(filter $(obj)/%, $(KBUILD_SINGLE_TARGETS)) + curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \ $(if $(filter $(x) $(basename $(x)).o, $(targets)), $(x # Handle single targets without any rule: show "Nothing to be done for ..." or # "No rule to make target ..." depending on whether the target exists. unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \ - $(filter $(obj)/%, \ - $(filter-out $(curdir-single), \ - $(KBUILD_SINGLE_TARGETS + $(filter-out $(curdir-single), $(KBUILD_SINGLE_TARGETS))) __build: $(curdir-single) $(subdir-ym) ifneq ($(unknown-single),) -- 2.17.1
[PATCH 2/2] kbuild: make target builds much faster
Since commit 394053f4a4b3 ("kbuild: make single targets work more correctly"), building single targets is really slow. Speed it up by not descending into unrelated directories. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index dcbb0124dac4..7eabbb66a65c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -479,7 +479,10 @@ curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \ unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \ $(filter-out $(curdir-single), $(KBUILD_SINGLE_TARGETS))) -__build: $(curdir-single) $(subdir-ym) +single-subdirs := $(foreach d, $(subdir-ym), \ + $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d))) + +__build: $(curdir-single) $(single-subdirs) ifneq ($(unknown-single),) $(Q)$(MAKE) -f /dev/null $(unknown-single) endif -- 2.17.1
linux-next: Tree for Oct 16
Hi all, Changes since 20191015: New tree: cel The pm tree lost its build failure. The drm-misc tree gained a semantic conflict against the amdgpu tree. The sound-asoc tree gained a conflict against the sound tree. The devicetree tree gained a conflict against Linus' tree. The drivers-x86 tree lost its build failure. Non-merge commits (relative to Linus' tree): 4158 4204 files changed, 141607 insertions(+), 66232 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 315 trees (counting Linus' and 78 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (8e0d0ad206f0 sparc64: disable fast-GUP due to unexplained oopses) Merging fixes/master (54ecb8f7028c Linux 5.4-rc1) Merging kbuild-current/fixes (991b78fbd223 scripts: setlocalversion: fix a bashism) Merging arc-current/for-curr (41277ba7eb4e ARC: mm: tlb flush optim: elide redundant uTLB invalidates for MMUv3) Merging arm-current/fixes (4c0742f65b4e ARM: 8914/1: NOMMU: Fix exc_ret for XIP) Merging arm-soc-fixes/arm/fixes (dd163ca3fb49 Merge tag 'mvebu-fixes-5.4-1' of git://git.infradead.org/linux-mvebu into arm/fixes) Merging arm64-fixes/for-next/fixes (8c551f919a73 arm64: hibernate: check pgd table allocation) Merging m68k-current/for-linus (0f1979b402df m68k: Remove ioremap_fullcache()) Merging powerpc-fixes/fixes (2272905a4580 spufs: fix a crash in spufs_create_root()) Merging s390-fixes/fixes (062795fcdcb2 s390/uaccess: avoid (false positive) compiler warnings) Merging sparc/master (038029c03e21 sparc: remove unneeded uapi/asm/statfs.h) Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2) Merging net/master (ddc790e92b3a net: ethernet: broadcom: have drivers select DIMLIB as needed) Merging bpf/master (9e8acd9c44a0 bpf: lwtunnel: Fix reroute supplying invalid dst) Merging ipsec/master (68ce6688a5ba net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte) Merging netfilter/master (503c9addef61 ptp: fix typo of "mechanism" in Kconfig help text) Merging ipvs/master (503c9addef61 ptp: fix typo of "mechanism" in Kconfig help text) Merging wireless-drivers/master (d79749f7716d ath10k: fix latency issue for QCA988x) Merging mac80211/master (82ad862115c2 Merge branch 'smc-fixes') Merging rdma-fixes/for-rc (0417791536ae RDMA/mlx5: Add missing synchronize_srcu() for MW cases) Merging sound-current/for-linus (130bce3afbbb ALSA: hdac: clear link output stream mapping) Merging sound-asoc-fixes/for-linus (8a5ed7fb8253 Merge branch 'asoc-5.4' into asoc-linus) Merging regmap-fixes/for-linus (da0c9ea146cb Linux 5.4-rc2) Merging regulator-fixes/for-linus (68a2d13c4d54 Merge branch 'regulator-5.4' into regulator-linus) Merging spi-fixes/for-linus (09ee9e1664ba Merge branch 'spi-5.4' into spi-linus) Merging pci-current/for-linus (54ecb8f7028c Linux 5.4-rc1) Merging driver-core.current/driver-core-linus (82af5b660967 sysfs: Fixes __BIN_ATTR_WO() macro) Merging tty.current/tty-linus (f50b6805dbb9 8250-men-mcb: fix error checking when get_num_ports returns -ENODEV) Merging usb.current/usb-linus (7a7591979748 USB: usblp: fix use-after-free on disconnect) Merging usb-gadget-fixes/fixes (4a56a478a525 usb: gadget: mass_storage: Fix races between fsg_disable and fsg_set_alt) Merging usb-se
Re: [Outreachy kernel] [PATCH] staging: vc04_services: fix line over 80 characters checks warning
> #ifndef VCHI_BULK_GRANULARITY > # if __VCCOREVER__ >= 0x0400 > -# define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache > cleans > +#define VCHI_BULK_GRANULARITY 32 // Allows for the need of cache cleans > # else > # define VCHI_BULK_GRANULARITY 16 > # endif The branches should be indented to the same degree. julia
Re: [PATCH v1 06/17] dt-bindings: cpufreq: Add binding for NVIDIA Tegra20/30
On 16-10-19, 00:16, Dmitry Osipenko wrote: > Add device-tree binding that describes CPU frequency-scaling hardware > found on NVIDIA Tegra20/30 SoCs. > > Signed-off-by: Dmitry Osipenko > --- > .../cpufreq/nvidia,tegra20-cpufreq.txt| 56 +++ > 1 file changed, 56 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/cpufreq/nvidia,tegra20-cpufreq.txt > > diff --git > a/Documentation/devicetree/bindings/cpufreq/nvidia,tegra20-cpufreq.txt > b/Documentation/devicetree/bindings/cpufreq/nvidia,tegra20-cpufreq.txt > new file mode 100644 > index ..daeca6ae6b76 > --- /dev/null > +++ b/Documentation/devicetree/bindings/cpufreq/nvidia,tegra20-cpufreq.txt > @@ -0,0 +1,56 @@ > +Binding for NVIDIA Tegra20 CPUFreq > +== > + > +Required properties: > +- clocks: Must contain an entry for the CPU clock. > + See ../clocks/clock-bindings.txt for details. > +- operating-points-v2: See ../bindings/opp/opp.txt for details. > +- #cooling-cells: Should be 2. See ../thermal/thermal.txt for details. > + > +For each opp entry in 'operating-points-v2' table: > +- opp-supported-hw: Two bitfields indicating: > + On Tegra20: > + 1. CPU process ID mask > + 2. SoC speedo ID mask > + > + On Tegra30: > + 1. CPU process ID mask > + 2. CPU speedo ID mask > + > + A bitwise AND is performed against these values and if any bit > + matches, the OPP gets enabled. > + > +- opp-microvolt: CPU voltage triplet. > + > +Optional properties: > +- cpu-supply: Phandle to the CPU power supply. > + > +Example: > + regulators { > + cpu_reg: regulator0 { > + regulator-name = "vdd_cpu"; > + }; > + }; > + > + cpu0_opp_table: opp_table0 { > + compatible = "operating-points-v2"; > + > + opp@45600 { > + clock-latency-ns = <125000>; > + opp-microvolt = <825000 825000 1125000>; > + opp-supported-hw = <0x03 0x0001>; > + opp-hz = /bits/ 64 <45600>; > + }; > + > + ... > + }; > + > + cpus { > + cpu@0 { > + compatible = "arm,cortex-a9"; > + clocks = <_car TEGRA20_CLK_CCLK>; > + operating-points-v2 = <_opp_table>; > + cpu-supply = <_reg>; > + #cooling-cells = <2>; > + }; > + }; LGTM. -- viresh
[PATCH] kbuild: remove unneeded variable, single-all
When single-build is set, everything in $(MAKECMDGOALS) is a single target. You can use $(MAKECMDGOALS) to list out the single targets. Signed-off-by: Masahiro Yamada --- Makefile | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ffd7a912fc46..710199f60c30 100644 --- a/Makefile +++ b/Makefile @@ -1764,11 +1764,9 @@ tools/%: FORCE ifdef single-build -single-all := $(filter $(single-targets), $(MAKECMDGOALS)) - # .ko is special because modpost is needed -single-ko := $(sort $(filter %.ko, $(single-all))) -single-no-ko := $(sort $(patsubst %.ko,%.mod, $(single-all))) +single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS))) +single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS))) $(single-ko): single_modpost @: -- 2.17.1
Re: [PATCH 09/12] iomap: lift the xfs writeback code to iomap
On Wed, Oct 16, 2019 at 09:07:21AM +1100, Dave Chinner wrote: > On Tue, Oct 15, 2019 at 05:43:42PM +0200, Christoph Hellwig wrote: > > Take the xfs writeback code and move it to fs/iomap. A new structure > > with three methods is added as the abstraction from the generic writeback > > code to the file system. These methods are used to map blocks, submit an > > ioend, and cancel a page that encountered an error before it was added to > > an ioend. > > > > Signed-off-by: Christoph Hellwig > > --- > > fs/iomap/buffered-io.c | 564 ++- > > fs/iomap/trace.h | 39 +++ > > fs/xfs/xfs_aops.c | 662 - > > fs/xfs/xfs_aops.h | 17 -- > > fs/xfs/xfs_super.c | 11 +- > > fs/xfs/xfs_trace.h | 39 --- > > include/linux/iomap.h | 59 > > 7 files changed, 722 insertions(+), 669 deletions(-) > . > > @@ -468,6 +471,8 @@ EXPORT_SYMBOL_GPL(iomap_is_partially_uptodate); > > int > > iomap_releasepage(struct page *page, gfp_t gfp_mask) > > { > > + trace_iomap_releasepage(page->mapping->host, page, 0, 0); > > + > > /* > > * mm accommodates an old ext3 case where clean pages might not have had > > * the dirty bit cleared. Thus, it can send actual dirty pages to > > @@ -483,6 +488,8 @@ EXPORT_SYMBOL_GPL(iomap_releasepage); > > void > > iomap_invalidatepage(struct page *page, unsigned int offset, unsigned int > > len) > > { > > + trace_iomap_invalidatepage(page->mapping->host, page, offset, len); > > + > > These tracepoints should be split out into a separate patch like > the readpage(s) tracepoints. Maybe just lift all the non-writeback > ones in a single patch... > > > /* > > * If we are invalidating the entire page, clear the dirty state from it > > * and release it to avoid unnecessary buildup of the LRU. > > @@ -1084,3 +1091,558 @@ vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, > > const struct iomap_ops *ops) > > return block_page_mkwrite_return(ret); > > } > > EXPORT_SYMBOL_GPL(iomap_page_mkwrite); > > + > > +static void > > +iomap_finish_page_writeback(struct inode *inode, struct bio_vec *bvec, > > + int error) > > +{ > > + struct iomap_page *iop = to_iomap_page(bvec->bv_page); > > + > > + if (error) { > > + SetPageError(bvec->bv_page); > > + mapping_set_error(inode->i_mapping, -EIO); > > + } > > + > > + WARN_ON_ONCE(i_blocksize(inode) < PAGE_SIZE && !iop); > > + WARN_ON_ONCE(iop && atomic_read(>write_count) <= 0); > > + > > + if (!iop || atomic_dec_and_test(>write_count)) > > + end_page_writeback(bvec->bv_page); > > +} > > Can we just pass the struct page into this function? > > . > > > +/* > > + * Submit the bio for an ioend. We are passed an ioend with a bio attached > > to > > + * it, and we submit that bio. The ioend may be used for multiple bio > > + * submissions, so we only want to allocate an append transaction for the > > ioend > > + * once. In the case of multiple bio submission, each bio will take an IO > > This needs to be changed to describe what wpc->ops->submit_ioend() > is used for rather than what XFS might use this hook for. > > > + * reference to the ioend to ensure that the ioend completion is only done > > once > > + * all bios have been submitted and the ioend is really done. > > + * > > + * If @error is non-zero, it means that we have a situation where some > > part of > > + * the submission process has failed after we have marked paged for > > writeback > > + * and unlocked them. In this situation, we need to fail the bio and ioend > > + * rather than submit it to IO. This typically only happens on a filesystem > > + * shutdown. > > + */ > > +static int > > +iomap_submit_ioend(struct iomap_writepage_ctx *wpc, struct iomap_ioend > > *ioend, > > + int error) > > +{ > > + ioend->io_bio->bi_private = ioend; > > + ioend->io_bio->bi_end_io = iomap_writepage_end_bio; > > + > > + if (wpc->ops->submit_ioend) > > + error = wpc->ops->submit_ioend(ioend, error); > > I'm not sure that "submit_ioend" is the best name for this method, > as it is a pre-bio-submission hook, not an actual IO submission > method. "prepare_ioend_for_submit" is more descriptive, but probably > too long. wpc->ops->prepare_submit(ioend, error) reads pretty well, > though... ->prepare_submission() ? --D > > + if (error) { > > + /* > > +* If we are failing the IO now, just mark the ioend with an > > +* error and finish it. This will run IO completion immediately > > +* as there is only one reference to the ioend at this point in > > +* time. > > +*/ > > + ioend->io_bio->bi_status = errno_to_blk_status(error); > > + bio_endio(ioend->io_bio); > > + return error; > > + } > > + > > + submit_bio(ioend->io_bio); > > + return 0; > > +} > > . > > +/* > > + * We implement an
Re: [PATCH 22/34] xen: Use CONFIG_PREEMPTION
On 15.10.19 21:18, Sebastian Andrzej Siewior wrote: From: Thomas Gleixner CONFIG_PREEMPTION is selected by CONFIG_PREEMPT and by CONFIG_PREEMPT_RT. Both PREEMPT and PREEMPT_RT require the same functionality which today depends on CONFIG_PREEMPT. Switch the preempt anand xen-ops code over to use CONFIG_PREEMPTION. Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: xen-de...@lists.xenproject.org Signed-off-by: Thomas Gleixner Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Juergen Gross Juergen
Re: [PATCH] dmaengine: axi-dmac: simple device_config operation implemented
On 15-10-19, 23:06, Lars-Peter Clausen wrote: > >> This DMA controller is a bit special. > >> It gets synthesized in FPGA, so the configuration is fixed and cannot be > >> changed at runtime. Maybe later we would allow/implement this > >> functionality, but this is a question for my HDL colleagues. > >> > >> Two things are done (in this order): > >> 1. For some paramters, axi_dmac_parse_chan_dt() is used to determine things > >> from device-tree; as it's an FPGA core, things are synthesized once and > >> cannot change (yet) > >> 2. For other parameters, the axi_dmac_detect_caps() is used to guess some > >> of them at probe time, by doing some reg reads/writes > > > > So the question for you hw folks is how would a controller work with > > multiple slave devices, do they need to synthesize it everytime? > > > > Rather than that why cant they make the peripheral addresses > > programmable so that you dont need updating fpga everytime! > > The DMA has a direct connection to the peripheral and the peripheral > data port is not connected to the general purpose memory interconnect. > So you can't write to it by an MMIO address andthere is no address > that needs to be configured. For an FPGA based design this is quite a > good solution in terms of resource usage, performance and simplicity. A > direct connection requires less resources than connection it to the > central memory interconnect, while at the same time having lower latency > and not eating up any additional bandwidth on the central memory connect. thanks for explanation! > So slave config in this case is a noop and all it can do is verify that > the requested configuration matches the available configuration. okay so noop it is! -- ~Vinod
Re: [PATCH 0/2] soundwire: Kconfig/build improvements
On 16-09-19, 13:57, Pierre-Louis Bossart wrote: > The Intel kbuild test reported issues with COMPILE_TEST or > cross-compilation when SOF is enabled, fix. This has no functional > impact. Applied, thanks -- ~Vinod
Re: [PATCH v2] ftrace: Introduce PERMANENT ftrace_ops flag
On 10/14/19 4:29 PM, Miroslav Benes wrote: > Livepatch uses ftrace for redirection to new patched functions. It means > that if ftrace is disabled, all live patched functions are disabled as > well. Toggling global 'ftrace_enabled' sysctl thus affect it directly. > It is not a problem per se, because only administrator can set sysctl > values, but it still may be surprising. > > Introduce PERMANENT ftrace_ops flag to amend this. If the > FTRACE_OPS_FL_PERMANENT is set on any ftrace ops, the tracing cannot be > disabled by disabling ftrace_enabled. Equally, a callback with the flag > set cannot be registered if ftrace_enabled is disabled. > > Signed-off-by: Miroslav Benes The patch looks good to me. A minor typo in flag description below. Reviewed-by: Kamalesh Babulal [...] > diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h > index 8a8cb3c401b2..c2cad29dc557 100644 > --- a/include/linux/ftrace.h > +++ b/include/linux/ftrace.h > @@ -142,6 +142,8 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops); > * PID - Is affected by set_ftrace_pid (allows filtering on those pids) > * RCU - Set when the ops can only be called when RCU is watching. > * TRACE_ARRAY - The ops->private points to a trace_array descriptor. > + * PERMAMENT - Set when the ops is permanent and should not be affected by > + * ftrace_enabled. > */ s/PERMAMENT/PERMANENT > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 62a50bf399d6..d2992ea29fe1 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -6752,12 +6764,19 @@ ftrace_enable_sysctl(struct ctl_table *table, int > write, > ftrace_startup_sysctl(); > > } else { > + if (is_permanent_ops_registered()) { > + ftrace_enabled = last_ftrace_enabled; > + ret = -EBUSY; > + goto out; > + } > + > /* stopping ftrace calls (just send to ftrace_stub) */ > ftrace_trace_function = ftrace_stub; > > ftrace_shutdown_sysctl(); > } > > + last_ftrace_enabled = !!ftrace_enabled; No strong feelings on last_ftrace_enabled placement, leaving it to your preference. > out: > mutex_unlock(_lock); > return ret; > -- Kamalesh
Re: [PATCH 03/34] powerpc: Use CONFIG_PREEMPTION
Le 15/10/2019 à 21:17, Sebastian Andrzej Siewior a écrit : From: Thomas Gleixner CONFIG_PREEMPTION is selected by CONFIG_PREEMPT and by CONFIG_PREEMPT_RT. Both PREEMPT and PREEMPT_RT require the same functionality which today depends on CONFIG_PREEMPT. Switch the entry code over to use CONFIG_PREEMPTION. Add PREEMPT_RT output in __die(). powerpc doesn't select ARCH_SUPPORTS_RT, so this change is useless as CONFIG_PREEMPT_RT cannot be selected. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: linuxppc-...@lists.ozlabs.org Signed-off-by: Thomas Gleixner [bigeasy: +traps.c, Kconfig] Signed-off-by: Sebastian Andrzej Siewior --- arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/entry_32.S | 4 ++-- arch/powerpc/kernel/entry_64.S | 4 ++-- arch/powerpc/kernel/traps.c| 7 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 3e56c9c2f16ee..8ead8d6e1cbc8 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -106,7 +106,7 @@ config LOCKDEP_SUPPORT config GENERIC_LOCKBREAK bool default y - depends on SMP && PREEMPT + depends on SMP && PREEMPTION config GENERIC_HWEIGHT bool diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index d60908ea37fb9..e1a4c39b83b86 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -897,7 +897,7 @@ user_exc_return:/* r10 contains MSR_KERNEL here */ bne-0b 1: -#ifdef CONFIG_PREEMPT +#ifdef CONFIG_PREEMPTION /* check current_thread_info->preempt_count */ lwz r0,TI_PREEMPT(r2) cmpwi 0,r0,0 /* if non-zero, just restore regs and return */ @@ -921,7 +921,7 @@ user_exc_return:/* r10 contains MSR_KERNEL here */ */ bl trace_hardirqs_on #endif -#endif /* CONFIG_PREEMPT */ +#endif /* CONFIG_PREEMPTION */ restore_kuap: kuap_restore r1, r2, r9, r10, r0 diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 6467bdab8d405..83733376533e8 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -840,7 +840,7 @@ _GLOBAL(ret_from_except_lite) bne-0b 1: -#ifdef CONFIG_PREEMPT +#ifdef CONFIG_PREEMPTION /* Check if we need to preempt */ andi. r0,r4,_TIF_NEED_RESCHED beq+restore @@ -871,7 +871,7 @@ _GLOBAL(ret_from_except_lite) li r10,MSR_RI mtmsrd r10,1 /* Update machine state */ #endif /* CONFIG_PPC_BOOK3E */ -#endif /* CONFIG_PREEMPT */ +#endif /* CONFIG_PREEMPTION */ .globl fast_exc_return_irq fast_exc_return_irq: diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 82f43535e6867..23d2f20be4f2e 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -252,14 +252,19 @@ NOKPROBE_SYMBOL(oops_end); static int __die(const char *str, struct pt_regs *regs, long err) { + const char *pr = ""; + Please follow the same approach as already existing. Don't add a local var for that. printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter); + if (IS_ENABLED(CONFIG_PREEMPTION)) + pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT"; + drop printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s%s %s\n", Add one %s IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE", PAGE_SIZE / 1024, early_radix_enabled() ? " MMU=Radix" : "", early_mmu_has_feature(MMU_FTR_HPTE_TABLE) ? " MMU=Hash" : "", - IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "", Replace by: IS_ENABLED(CONFIG_PREEMPTION) ? " PREEMPT" : "" + pr, add something like: IS_ENABLED(CONFIG_PREEMPT_RT) ? "_RT" : "" IS_ENABLED(CONFIG_SMP) ? " SMP" : "", IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "", debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "", Christophe
Re: [PATCH] of-thermal: Disable polling when interrupt property is found in DT
Quoting Amit Kucheria (2019-10-15 16:13:16) > Currently, in order to enable interrupt-only mode, one must set > polling-delay-passive and polling-delay properties in the DT to 0, > otherwise the thermal framework will continue to setup a periodic timers > to monitor the thermal zones. > > Change the behaviour, so that on DT-based systems, we no longer have to > set the properties to zero if we find an 'interrupt' property in the > sensor. > > Following data shows the number of times > thermal_zone_device_set_polling() is invoked with and without this > patch. So the patch achieves the same behaviour as setting the delay > properties to 0. > > Current behaviour (without setting delay properties to 0): > FUNC COUNT > thermal_zone_device_update 302 > thermal_zone_device_set_pollin 7911 thermal_zone_device_set_polling? > > Current behaviour (with delay properties set to 0): > FUNC COUNT > thermal_zone_device_update3 > thermal_zone_device_set_pollin6 > > With this patch (without setting delay properties to 0): > FUNC COUNT > thermal_zone_device_update3 > thermal_zone_device_set_pollin6 > > Suggested-by: Stephen Boyd > Signed-off-by: Amit Kucheria > --- Reviewed-by: Stephen Boyd
RE: [PATCH V3 1/7] mdev: class id support
> -Original Message- > From: Jason Wang > Sent: Friday, October 11, 2019 3:16 AM > To: k...@vger.kernel.org; linux-s...@vger.kernel.org; linux- > ker...@vger.kernel.org; dri-de...@lists.freedesktop.org; intel- > g...@lists.freedesktop.org; intel-gvt-...@lists.freedesktop.org; > kwankh...@nvidia.com; alex.william...@redhat.com; m...@redhat.com; > tiwei@intel.com > Cc: virtualizat...@lists.linux-foundation.org; net...@vger.kernel.org; > coh...@redhat.com; maxime.coque...@redhat.com; > cunming.li...@intel.com; zhihong.w...@intel.com; > rob.mil...@broadcom.com; xiao.w.w...@intel.com; > haotian.w...@sifive.com; zhen...@linux.intel.com; zhi.a.w...@intel.com; > jani.nik...@linux.intel.com; joonas.lahti...@linux.intel.com; > rodrigo.v...@intel.com; airl...@linux.ie; dan...@ffwll.ch; > far...@linux.ibm.com; pa...@linux.ibm.com; seb...@linux.ibm.com; > ober...@linux.ibm.com; heiko.carst...@de.ibm.com; g...@linux.ibm.com; > borntrae...@de.ibm.com; akrow...@linux.ibm.com; fre...@linux.ibm.com; > lingshan@intel.com; Ido Shamay ; > epere...@redhat.com; l...@redhat.com; Parav Pandit > ; christophe.de.dinec...@gmail.com; > kevin.t...@intel.com; Jason Wang > Subject: [PATCH V3 1/7] mdev: class id support > > Mdev bus only supports vfio driver right now, so it doesn't implement match > method. But in the future, we may add drivers other than vfio, the first > driver could be virtio-mdev. This means we need to add device class id > support in bus match method to pair the mdev device and mdev driver > correctly. > > So this patch adds id_table to mdev_driver and class_id for mdev device > with the match method for mdev bus. > > Signed-off-by: Jason Wang > --- > Documentation/driver-api/vfio-mediated-device.rst | 7 ++- > drivers/gpu/drm/i915/gvt/kvmgt.c | 1 + > drivers/s390/cio/vfio_ccw_ops.c | 1 + > drivers/s390/crypto/vfio_ap_ops.c | 1 + > drivers/vfio/mdev/mdev_core.c | 11 +++ > drivers/vfio/mdev/mdev_driver.c | 14 ++ > drivers/vfio/mdev/mdev_private.h | 1 + > drivers/vfio/mdev/vfio_mdev.c | 6 ++ > include/linux/mdev.h | 8 > include/linux/mod_devicetable.h | 8 > samples/vfio-mdev/mbochs.c| 1 + > samples/vfio-mdev/mdpy.c | 1 + > samples/vfio-mdev/mtty.c | 1 + > 13 files changed, 60 insertions(+), 1 deletion(-) > > diff --git a/Documentation/driver-api/vfio-mediated-device.rst > b/Documentation/driver-api/vfio-mediated-device.rst > index 25eb7d5b834b..2035e48da7b2 100644 > --- a/Documentation/driver-api/vfio-mediated-device.rst > +++ b/Documentation/driver-api/vfio-mediated-device.rst > @@ -102,12 +102,14 @@ structure to represent a mediated device's driver:: >* @probe: called when new device created >* @remove: called when device removed >* @driver: device driver structure > + * @id_table: the ids serviced by this driver >*/ > struct mdev_driver { >const char *name; >int (*probe) (struct device *dev); >void (*remove) (struct device *dev); >struct device_driverdriver; > + const struct mdev_class_id *id_table; > }; > > A mediated bus driver for mdev should use this structure in the function > calls @@ -165,12 +167,15 @@ register itself with the mdev core driver:: > extern int mdev_register_device(struct device *dev, >const struct mdev_parent_ops *ops); > > +It is also required to specify the class_id through:: > + > + extern int mdev_set_class(struct device *dev, u16 id); Drop extern. In actual API you have correct signature, i.e. struct mdev_device. s/struct device/struct mdev_device. > + > However, the mdev_parent_ops structure is not required in the function call > that a driver should use to unregister itself with the mdev core driver:: > > extern void mdev_unregister_device(struct device *dev); > > - > Mediated Device Management Interface Through sysfs > == > > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c > b/drivers/gpu/drm/i915/gvt/kvmgt.c > index 343d79c1cb7e..17e9d4634c84 100644 > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c > @@ -678,6 +678,7 @@ static int intel_vgpu_create(struct kobject *kobj, > struct mdev_device *mdev) >dev_name(mdev_dev(mdev))); > ret = 0; > > + mdev_set_class(mdev, MDEV_ID_VFIO); > out: > return ret; > } > diff --git a/drivers/s390/cio/vfio_ccw_ops.c > b/drivers/s390/cio/vfio_ccw_ops.c index f0d71ab77c50..b5d223882c6c > 100644 > --- a/drivers/s390/cio/vfio_ccw_ops.c > +++ b/drivers/s390/cio/vfio_ccw_ops.c > @@ -129,6 +129,7 @@ static int
Re: [PATCH RFC v1 1/2] vhost: option to fetch descriptors through an independent struct
On 2019/10/16 上午4:20, Michael S. Tsirkin wrote: On Mon, Oct 14, 2019 at 09:43:25AM +0800, Jason Wang wrote: On 2019/10/13 上午4:27, Michael S. Tsirkin wrote: On Sat, Oct 12, 2019 at 03:28:49PM +0800, Jason Wang wrote: On 2019/10/11 下午9:45, Michael S. Tsirkin wrote: The idea is to support multiple ring formats by converting to a format-independent array of descriptors. This costs extra cycles, but we gain in ability to fetch a batch of descriptors in one go, which is good for code cache locality. To simplify benchmarking, I kept the old code around so one can switch back and forth by writing into a module parameter. This will go away in the final submission. This patch causes a minor performance degradation, it's been kept as simple as possible for ease of review. Next patch gets us back the performance by adding batching. Signed-off-by: Michael S. Tsirkin --- drivers/vhost/test.c | 17 ++- drivers/vhost/vhost.c | 299 +- drivers/vhost/vhost.h | 16 +++ 3 files changed, 327 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 056308008288..39a018a7af2d 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c @@ -18,6 +18,9 @@ #include "test.h" #include "vhost.h" +static int newcode = 0; +module_param(newcode, int, 0644); + /* Max number of bytes transferred before requeueing the job. * Using this limit prevents one virtqueue from starving others. */ #define VHOST_TEST_WEIGHT 0x8 @@ -58,10 +61,16 @@ static void handle_vq(struct vhost_test *n) vhost_disable_notify(>dev, vq); for (;;) { - head = vhost_get_vq_desc(vq, vq->iov, -ARRAY_SIZE(vq->iov), -, , -NULL, NULL); + if (newcode) + head = vhost_get_vq_desc_batch(vq, vq->iov, + ARRAY_SIZE(vq->iov), + , , + NULL, NULL); + else + head = vhost_get_vq_desc(vq, vq->iov, +ARRAY_SIZE(vq->iov), +, , +NULL, NULL); /* On error, stop handling until the next kick. */ if (unlikely(head < 0)) break; diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 36ca2cf419bf..36661d6cb51f 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -301,6 +301,7 @@ static void vhost_vq_reset(struct vhost_dev *dev, struct vhost_virtqueue *vq) { vq->num = 1; + vq->ndescs = 0; vq->desc = NULL; vq->avail = NULL; vq->used = NULL; @@ -369,6 +370,9 @@ static int vhost_worker(void *data) static void vhost_vq_free_iovecs(struct vhost_virtqueue *vq) { + kfree(vq->descs); + vq->descs = NULL; + vq->max_descs = 0; kfree(vq->indirect); vq->indirect = NULL; kfree(vq->log); @@ -385,6 +389,10 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) for (i = 0; i < dev->nvqs; ++i) { vq = dev->vqs[i]; + vq->max_descs = dev->iov_limit; + vq->descs = kmalloc_array(vq->max_descs, + sizeof(*vq->descs), + GFP_KERNEL); Is iov_limit too much here? It can obviously increase the footprint. I guess the batching can only be done for descriptor without indirect or next set. Then we may batch 16 or 64. Thanks Yes, next patch only batches up to 64. But we do need iov_limit because guest can pass a long chain of scatter/gather. We already have iovecs in a huge array so this does not look like a big deal. If we ever teach the code to avoid the huge iov arrays by handling huge s/g lists piece by piece, we can make the desc array smaller at the same point. Another possible issue, if we try to batch descriptor chain when we've already batched some descriptors, we may reach the limit then some of the descriptors might need re-read. Or we may need circular index (head, tail) in this case? Thanks We never supported more than IOV_MAX descriptors. And we don't batch more than iov_limit - IOV_MAX. Ok, but what happens when we've already batched 63 descriptors then come a 3 descriptor chain? And it looks to me we need forget the cached descriptor during set_vring_base() Thanks so buffer never overflows.
RE: [PATCH 2/2] usb: cdns3: gadget: Fix full-speed mode
>On 19-10-07 15:16:01, Roger Quadros wrote: >> We need to disable USB3 PHY for full-speed mode else >> gadget mode is broken. >> >> Signed-off-by: Roger Quadros >> Signed-off-by: Sekhar Nori >> --- >> drivers/usb/cdns3/gadget.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c >> index 228cdc4ab886..157536753b8c 100644 >> --- a/drivers/usb/cdns3/gadget.c >> +++ b/drivers/usb/cdns3/gadget.c >> @@ -2571,6 +2571,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns) >> switch (max_speed) { >> case USB_SPEED_FULL: >> writel(USB_CONF_SFORCE_FS, _dev->regs->usb_conf); >> +writel(USB_CONF_USB3DIS, _dev->regs->usb_conf); >> break; >> case USB_SPEED_HIGH: >> writel(USB_CONF_USB3DIS, _dev->regs->usb_conf); > >Reviewed-by: Peter Chen Reviewed-by: Pawel Laszczak > >-- > >Thanks, >Peter Chen Regards, Pawell
[PATCH v5 5/5] locking/qspinlock: Introduce the shuffle reduction optimization into CNA
This optimization reduces the probability threads will be shuffled between the main and secondary queues when the secondary queue is empty. It is helpful when the lock is only lightly contended. Signed-off-by: Alex Kogan Reviewed-by: Steve Sistare --- kernel/locking/qspinlock_cna.h | 30 ++ 1 file changed, 30 insertions(+) diff --git a/kernel/locking/qspinlock_cna.h b/kernel/locking/qspinlock_cna.h index b92a6f9a19db..6a66850be1e6 100644 --- a/kernel/locking/qspinlock_cna.h +++ b/kernel/locking/qspinlock_cna.h @@ -4,6 +4,7 @@ #endif #include +#include /* * Implement a NUMA-aware version of MCS (aka CNA, or compact NUMA-aware lock). @@ -63,6 +64,34 @@ struct cna_node { */ #define INTRA_NODE_HANDOFF_THRESHOLD (1 << 16) +/* + * Controls the probability for enabling the scan of the main queue when + * the secondary queue is empty. The chosen value reduces the amount of + * unnecessary shuffling of threads between the two waiting queues when + * the contention is low, while responding fast enough and enabling + * the shuffling when the contention is high. + */ +#define SHUFFLE_REDUCTION_PROB_ARG (7) + +/* Per-CPU pseudo-random number seed */ +static DEFINE_PER_CPU(u32, seed); + +/* + * Return false with probability 1 / 2^@num_bits. + * Intuitively, the larger @num_bits the less likely false is to be returned. + * @num_bits must be a number between 0 and 31. + */ +static bool probably(unsigned int num_bits) +{ + u32 s; + + s = this_cpu_read(seed); + s = next_pseudo_random32(s); + this_cpu_write(seed, s); + + return s & ((1 << num_bits) - 1); +} + static void __init cna_init_nodes_per_cpu(unsigned int cpu) { struct mcs_spinlock *base = per_cpu_ptr([0].mcs, cpu); @@ -235,6 +264,7 @@ __always_inline u32 cna_pre_scan(struct qspinlock *lock, * should be made in cna_pass_lock() */ cn->pre_scan_result = + (node->locked <= 1 && probably(SHUFFLE_REDUCTION_PROB_ARG)) || cn->intra_count == INTRA_NODE_HANDOFF_THRESHOLD ? 1 : cna_scan_main_queue(node, node); -- 2.11.0 (Apple Git-81)
[PATCH v5 0/5] Add NUMA-awareness to qspinlock
Changes from v4: - Switch to a deterministic bound on the number of intra-node handoffs, as suggested by Longman. - Scan the main queue after acquiring the MCS lock and before acquiring the spinlock (pre-scan), as suggested by Longman. If no thread is found in pre-scan, try again after acquiring the spinlock, resuming from the same place where pre-scan stopped. - Convert the secondary queue to a cyclic list such that the tail’s @next points to the head of the queue. Store the pointer to the secondary queue tail (rather than head) in @locked. This eliminates the need for the @tail field in CNA nodes, making space for fields required by the two changes above. - Change arch_mcs_spin_lock_contended() to arch_mcs_spin_lock(), and fix misuse of old macro names, as suggested by Hanjun. Summary --- Lock throughput can be increased by handing a lock to a waiter on the same NUMA node as the lock holder, provided care is taken to avoid starvation of waiters on other NUMA nodes. This patch introduces CNA (compact NUMA-aware lock) as the slow path for qspinlock. It is enabled through a configuration option (NUMA_AWARE_SPINLOCKS). CNA is a NUMA-aware version of the MCS lock. Spinning threads are organized in two queues, a main queue for threads running on the same node as the current lock holder, and a secondary queue for threads running on other nodes. Threads store the ID of the node on which they are running in their queue nodes. After acquiring the MCS lock and before acquiring the spinlock, the lock holder scans the main queue looking for a thread running on the same node (pre-scan). If found (call it thread T), all threads in the main queue between the current lock holder and T are moved to the end of the secondary queue. If such T is not found, we make another scan of the main queue after acquiring the spinlock when unlocking the MCS lock (post-scan), starting at the node where pre-scan stopped. If both scans fail to find such T, the MCS lock is passed to the first thread in the secondary queue. If the secondary queue is empty, the MCS lock is passed to the next thread in the main queue. To avoid starvation of threads in the secondary queue, those threads are moved back to the head of the main queue after a certain number of intra-node lock hand-offs. More details are available at https://arxiv.org/abs/1810.05600. We have done some performance evaluation with the locktorture module as well as with several benchmarks from the will-it-scale repo. The following locktorture results are from an Oracle X5-4 server (four Intel Xeon E7-8895 v3 @ 2.60GHz sockets with 18 hyperthreaded cores each). Each number represents an average (over 25 runs) of the total number of ops (x10^7) reported at the end of each run. The standard deviation is also reported in (), and in general is about 3% from the average. The 'stock' kernel is v5.4.0-rc1, commit d90f2df63c5c, compiled in the default configuration. 'patch-CNA' is the modified kernel with NUMA_AWARE_SPINLOCKS set; the speedup is calculated dividing 'patch-CNA' by 'stock'. #thr stockpatch-CNA speedup (patch-CNA/stock) 1 2.674 (0.118) 2.736 (0.119) 1.023 2 2.588 (0.141) 2.603 (0.108) 1.006 4 4.230 (0.120) 4.220 (0.127) 0.998 8 5.362 (0.181) 6.679 (0.182) 1.246 16 6.639 (0.133) 8.050 (0.200) 1.213 32 7.359 (0.149) 8.792 (0.168) 1.195 36 7.443 (0.142) 8.873 (0.230) 1.192 72 6.554 (0.147) 9.317 (0.158) 1.421 108 6.156 (0.093) 9.404 (0.191) 1.528 142 5.659 (0.093) 9.361 (0.184) 1.654 The following tables contain throughput results (ops/us) from the same setup for will-it-scale/open1_threads: #thr stockpatch-CNA speedup (patch-CNA/stock) 1 0.532 (0.002) 0.532 (0.003) 1.000 2 0.785 (0.024) 0.779 (0.025) 0.992 4 1.426 (0.018) 1.409 (0.021) 0.988 8 1.779 (0.101) 1.711 (0.127) 0.962 16 1.761 (0.093) 1.671 (0.104) 0.949 32 0.935 (0.063) 1.619 (0.093) 1.731 36 0.936 (0.082) 1.591 (0.086) 1.699 72 0.839 (0.043) 1.667 (0.097) 1.988 108 0.842 (0.035) 1.701 (0.091) 2.021 142 0.830 (0.037) 1.714 (0.098) 2.066 and will-it-scale/lock2_threads: #thr stockpatch-CNA speedup (patch-CNA/stock) 1 1.555 (0.009) 1.577 (0.002) 1.014 2 2.644 (0.060) 2.682 (0.062) 1.014 4 5.159 (0.205) 5.197 (0.231) 1.007 8 4.302 (0.221) 4.279 (0.318) 0.995 16 4.259 (0.111) 4.087 (0.163) 0.960 32 2.583 (0.112) 4.077 (0.120) 1.578 36 2.499 (0.106) 4.076 (0.106) 1.631 72 1.979 (0.085) 4.077 (0.123) 2.061 108 2.096 (0.090) 4.043 (0.130) 1.929 142 1.913 (0.109) 3.984 (0.108) 2.082 Our evaluation shows that CNA also improves performance of user applications that have hot pthread mutexes. Those mutexes are blocking, and waiting threads park and unpark via the futex mechanism in the kernel. Given that kernel futex chains, which are hashed by the mutex address, are each protected by a chain-specific spin lock, the
[PATCH v5 3/5] locking/qspinlock: Introduce CNA into the slow path of qspinlock
In CNA, spinning threads are organized in two queues, a main queue for threads running on the same node as the current lock holder, and a secondary queue for threads running on other nodes. After acquiring the MCS lock and before acquiring the spinlock, the lock holder scans the main queue looking for a thread running on the same node (pre-scan). If found (call it thread T), all threads in the main queue between the current lock holder and T are moved to the end of the secondary queue. If such T is not found, we make another scan of the main queue when unlocking the MCS lock (post-scan), starting at the position where pre-scan stopped. If both scans fail to find such T, the MCS lock is passed to the first thread in the secondary queue. If the secondary queue is empty, the lock is passed to the next thread in the main queue. For more details, see https://arxiv.org/abs/1810.05600. Note that this variant of CNA may introduce starvation by continuously passing the lock to threads running on the same node. This issue will be addressed later in the series. Enabling CNA is controlled via a new configuration option (NUMA_AWARE_SPINLOCKS). By default, the CNA variant is patched in at the boot time only if we run on a multi-node machine in native environment and the new config is enabled. (For the time being, the patching requires CONFIG_PARAVIRT_SPINLOCKS to be enabled as well. However, this should be resolved once static_call() is available.) This default behavior can be overridden with the new kernel boot command-line option "numa_spinlock=on/off" (default is "auto"). Signed-off-by: Alex Kogan Reviewed-by: Steve Sistare --- arch/x86/Kconfig | 19 +++ arch/x86/include/asm/qspinlock.h | 4 + arch/x86/kernel/alternative.c| 41 +++ kernel/locking/mcs_spinlock.h| 2 +- kernel/locking/qspinlock.c | 34 +- kernel/locking/qspinlock_cna.h | 258 +++ 6 files changed, 353 insertions(+), 5 deletions(-) create mode 100644 kernel/locking/qspinlock_cna.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d6e1faa28c58..1d480f190def 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1573,6 +1573,25 @@ config NUMA Otherwise, you should say N. +config NUMA_AWARE_SPINLOCKS + bool "Numa-aware spinlocks" + depends on NUMA + depends on QUEUED_SPINLOCKS + # For now, we depend on PARAVIRT_SPINLOCKS to make the patching work. + # This is awkward, but hopefully would be resolved once static_call() + # is available. + depends on PARAVIRT_SPINLOCKS + default y + help + Introduce NUMA (Non Uniform Memory Access) awareness into + the slow path of spinlocks. + + In this variant of qspinlock, the kernel will try to keep the lock + on the same node, thus reducing the number of remote cache misses, + while trading some of the short term fairness for better performance. + + Say N if you want absolute first come first serve fairness. + config AMD_NUMA def_bool y prompt "Old style AMD Opteron NUMA detection" diff --git a/arch/x86/include/asm/qspinlock.h b/arch/x86/include/asm/qspinlock.h index 444d6fd9a6d8..6fa8fcc5c7af 100644 --- a/arch/x86/include/asm/qspinlock.h +++ b/arch/x86/include/asm/qspinlock.h @@ -27,6 +27,10 @@ static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lo return val; } +#ifdef CONFIG_NUMA_AWARE_SPINLOCKS +extern void __cna_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val); +#endif + #ifdef CONFIG_PARAVIRT_SPINLOCKS extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val); extern void __pv_init_lock_hash(void); diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 9d3a971ea364..e0e66bd8b251 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -698,6 +698,33 @@ static void __init int3_selftest(void) unregister_die_notifier(_exception_nb); } +#if defined(CONFIG_NUMA_AWARE_SPINLOCKS) +/* + * Constant (boot-param configurable) flag selecting the NUMA-aware variant + * of spinlock. Possible values: -1 (off) / 0 (auto, default) / 1 (on). + */ +static int numa_spinlock_flag; + +static int __init numa_spinlock_setup(char *str) +{ + if (!strcmp(str, "auto")) { + numa_spinlock_flag = 0; + return 1; + } else if (!strcmp(str, "on")) { + numa_spinlock_flag = 1; + return 1; + } else if (!strcmp(str, "off")) { + numa_spinlock_flag = -1; + return 1; + } + + return 0; +} + +__setup("numa_spinlock=", numa_spinlock_setup); + +#endif + void __init alternative_instructions(void) { int3_selftest(); @@ -738,6 +765,20 @@ void __init alternative_instructions(void) } #endif +#if defined(CONFIG_NUMA_AWARE_SPINLOCKS) + /* +* By default, switch
[PATCH v5 4/5] locking/qspinlock: Introduce starvation avoidance into CNA
Keep track of the number of intra-node lock handoffs, and force inter-node handoff once this number reaches a preset threshold. Signed-off-by: Alex Kogan Reviewed-by: Steve Sistare --- kernel/locking/qspinlock.c | 3 +++ kernel/locking/qspinlock_cna.h | 30 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 6d8c4a52e44e..1d0d884308ef 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c @@ -597,6 +597,9 @@ EXPORT_SYMBOL(queued_spin_lock_slowpath); #if !defined(_GEN_CNA_LOCK_SLOWPATH) && defined(CONFIG_NUMA_AWARE_SPINLOCKS) #define _GEN_CNA_LOCK_SLOWPATH +#undef pv_init_node +#define pv_init_node cna_init_node + #undef pv_wait_head_or_lock #define pv_wait_head_or_lock cna_pre_scan diff --git a/kernel/locking/qspinlock_cna.h b/kernel/locking/qspinlock_cna.h index 4d095f742d31..b92a6f9a19db 100644 --- a/kernel/locking/qspinlock_cna.h +++ b/kernel/locking/qspinlock_cna.h @@ -50,9 +50,19 @@ struct cna_node { struct mcs_spinlock mcs; int numa_node; u32 encoded_tail; - u32 pre_scan_result; /* 0 or an encoded tail */ + u32 pre_scan_result; /* 0, 1 or an encoded tail */ + u32 intra_count; }; +/* + * Controls the threshold for the number of intra-node lock hand-offs. It can + * be tuned and depend, e.g., on the number of CPUs per node. For now, + * choose a value that provides reasonable long-term fairness without + * sacrificing performance compared to a version that does not have any + * fairness guarantees. + */ +#define INTRA_NODE_HANDOFF_THRESHOLD (1 << 16) + static void __init cna_init_nodes_per_cpu(unsigned int cpu) { struct mcs_spinlock *base = per_cpu_ptr([0].mcs, cpu); @@ -86,6 +96,11 @@ static void __init cna_init_nodes(void) } early_initcall(cna_init_nodes); +static __always_inline void cna_init_node(struct mcs_spinlock *node) +{ + ((struct cna_node *)node)->intra_count = 0; +} + static inline bool cna_try_change_tail(struct qspinlock *lock, u32 val, struct mcs_spinlock *node) { @@ -215,7 +230,13 @@ __always_inline u32 cna_pre_scan(struct qspinlock *lock, { struct cna_node *cn = (struct cna_node *)node; - cn->pre_scan_result = cna_scan_main_queue(node, node); + /* +* setting @pre_scan_result to 1 indicates that no post-scan +* should be made in cna_pass_lock() +*/ + cn->pre_scan_result = + cn->intra_count == INTRA_NODE_HANDOFF_THRESHOLD ? + 1 : cna_scan_main_queue(node, node); return 0; } @@ -234,7 +255,7 @@ static inline void cna_pass_lock(struct mcs_spinlock *node, * pre-scan, and if so, try to find it in post-scan starting from the * node where pre-scan stopped (stored in @pre_scan_result) */ - if (scan > 0) + if (scan > 1) scan = cna_scan_main_queue(node, decode_tail(scan)); if (!scan) { /* if found a successor from the same numa node */ @@ -245,6 +266,9 @@ static inline void cna_pass_lock(struct mcs_spinlock *node, * to pass the lock */ val = node->locked + (node->locked == 0); + /* inc @intra_count if the secondary queue is not empty */ + ((struct cna_node *)next_holder)->intra_count = + cn->intra_count + (node->locked > 1); } else if (node->locked > 1) {/* if secondary queue is not empty */ /* next holder will be the first node in the secondary queue */ tail_2nd = decode_tail(node->locked); -- 2.11.0 (Apple Git-81)
[PATCH v5 1/5] locking/qspinlock: Rename mcs lock/unlock macros and make them more generic
The mcs unlock macro (arch_mcs_pass_lock) should accept the value to be stored into the lock argument as another argument. This allows using the same macro in cases where the value to be stored when passing the lock is different from 1. Signed-off-by: Alex Kogan Reviewed-by: Steve Sistare --- arch/arm/include/asm/mcs_spinlock.h | 6 +++--- include/asm-generic/mcs_spinlock.h | 4 ++-- kernel/locking/mcs_spinlock.h | 18 +- kernel/locking/qspinlock.c | 4 ++-- kernel/locking/qspinlock_paravirt.h | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/arm/include/asm/mcs_spinlock.h b/arch/arm/include/asm/mcs_spinlock.h index 529d2cf4d06f..693fe6ce3c43 100644 --- a/arch/arm/include/asm/mcs_spinlock.h +++ b/arch/arm/include/asm/mcs_spinlock.h @@ -6,7 +6,7 @@ #include /* MCS spin-locking. */ -#define arch_mcs_spin_lock_contended(lock) \ +#define arch_mcs_spin_lock(lock) \ do { \ /* Ensure prior stores are observed before we enter wfe. */ \ smp_mb(); \ @@ -14,9 +14,9 @@ do { \ wfe(); \ } while (0)\ -#define arch_mcs_spin_unlock_contended(lock) \ +#define arch_mcs_pass_lock(lock, val) \ do { \ - smp_store_release(lock, 1); \ + smp_store_release((lock), (val)); \ dsb_sev(); \ } while (0) diff --git a/include/asm-generic/mcs_spinlock.h b/include/asm-generic/mcs_spinlock.h index 10cd4ffc6ba2..868da43dba7c 100644 --- a/include/asm-generic/mcs_spinlock.h +++ b/include/asm-generic/mcs_spinlock.h @@ -4,8 +4,8 @@ /* * Architectures can define their own: * - * arch_mcs_spin_lock_contended(l) - * arch_mcs_spin_unlock_contended(l) + * arch_mcs_spin_lock(l) + * arch_mcs_pass_lock(l, val) * * See kernel/locking/mcs_spinlock.c. */ diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h index 5e10153b4d3c..52d06ec6f525 100644 --- a/kernel/locking/mcs_spinlock.h +++ b/kernel/locking/mcs_spinlock.h @@ -21,7 +21,7 @@ struct mcs_spinlock { int count; /* nesting count, see qspinlock.c */ }; -#ifndef arch_mcs_spin_lock_contended +#ifndef arch_mcs_spin_lock /* * Using smp_cond_load_acquire() provides the acquire semantics * required so that subsequent operations happen after the @@ -29,20 +29,20 @@ struct mcs_spinlock { * ARM64 would like to do spin-waiting instead of purely * spinning, and smp_cond_load_acquire() provides that behavior. */ -#define arch_mcs_spin_lock_contended(l) \ -do { \ - smp_cond_load_acquire(l, VAL); \ +#define arch_mcs_spin_lock(l) \ +do { \ + smp_cond_load_acquire(l, VAL); \ } while (0) #endif -#ifndef arch_mcs_spin_unlock_contended +#ifndef arch_mcs_spin_unlock /* * smp_store_release() provides a memory barrier to ensure all * operations in the critical section has been completed before * unlocking. */ -#define arch_mcs_spin_unlock_contended(l) \ - smp_store_release((l), 1) +#define arch_mcs_pass_lock(l, val) \ + smp_store_release((l), (val)) #endif /* @@ -91,7 +91,7 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node) WRITE_ONCE(prev->next, node); /* Wait until the lock holder passes the lock down. */ - arch_mcs_spin_lock_contended(>locked); + arch_mcs_spin_lock(>locked); } /* @@ -115,7 +115,7 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node) } /* Pass lock to next waiter. */ - arch_mcs_spin_unlock_contended(>locked); + arch_mcs_pass_lock(>locked, 1); } #endif /* __LINUX_MCS_SPINLOCK_H */ diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 2473f10c6956..804c0fbd6328 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c @@ -470,7 +470,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) WRITE_ONCE(prev->next, node); pv_wait_node(node, prev); - arch_mcs_spin_lock_contended(>locked); + arch_mcs_spin_lock(>locked); /*
RE: [PATCH 1/2] usb: cdns3: fix cdns3_core_init_role()
Hi Roger > >At startup we should trigger the HW state machine >only if it is OTG mode. Otherwise we should just >start the respective role. > >Initialize idle role by default. If we don't do this then >cdns3_idle_role_stop() is not called when switching to >host/device role and so lane switch mechanism >doesn't work. This results to super-speed device not working >in one orientation if it was plugged before driver probe. > >Signed-off-by: Roger Quadros >Signed-off-by: Sekhar Nori >--- > drivers/usb/cdns3/core.c | 20 +++- > 1 file changed, 19 insertions(+), 1 deletion(-) > >diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c >index 06f1e105be4e..1109dc5a4c39 100644 >--- a/drivers/usb/cdns3/core.c >+++ b/drivers/usb/cdns3/core.c >@@ -160,10 +160,28 @@ static int cdns3_core_init_role(struct cdns3 *cdns) > if (ret) > goto err; > >- if (cdns->dr_mode != USB_DR_MODE_OTG) { >+ /* Initialize idle role to start with */ >+ ret = cdns3_role_start(cdns, USB_ROLE_NONE); >+ if (ret) >+ goto err; >+ >+ switch (cdns->dr_mode) { >+ case USB_DR_MODE_UNKNOWN: One note in this place. USB_DR_MODE_UNKNOWN is not possible in this place. If cdns->dr_mode will be USB_DR_MODE_UNKNOWN then driver returns -EINVAL some line before after returning form cdns3_drd_update_mode and in consequence it jump to err label. Maybe for better readability it this condition should be treated here also as error. >+ case USB_DR_MODE_OTG: > ret = cdns3_hw_role_switch(cdns); > if (ret) > goto err; >+ break; >+ case USB_DR_MODE_PERIPHERAL: >+ ret = cdns3_role_start(cdns, USB_ROLE_DEVICE); >+ if (ret) >+ goto err; >+ break; >+ case USB_DR_MODE_HOST: >+ ret = cdns3_role_start(cdns, USB_ROLE_HOST); >+ if (ret) >+ goto err; >+ break; > } > > return ret; Reviewed-by: Pawel Laszczak Tested-by: Pawel Laszczak >-- >Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. >Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- Regards, Pawel
[PATCH v5 2/5] locking/qspinlock: Refactor the qspinlock slow path
Move some of the code manipulating the spin lock into separate functions. This would allow easier integration of alternative ways to manipulate that lock. Signed-off-by: Alex Kogan Reviewed-by: Steve Sistare --- kernel/locking/qspinlock.c | 38 -- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 804c0fbd6328..c06d1e8075d9 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c @@ -288,6 +288,34 @@ static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock, #define queued_spin_lock_slowpath native_queued_spin_lock_slowpath #endif +/* + * __try_clear_tail - try to clear tail by setting the lock value to + * _Q_LOCKED_VAL. + * @lock: Pointer to the queued spinlock structure + * @val: Current value of the lock + * @node: Pointer to the MCS node of the lock holder + */ +static __always_inline bool __try_clear_tail(struct qspinlock *lock, + u32 val, + struct mcs_spinlock *node) +{ + return atomic_try_cmpxchg_relaxed(>val, , _Q_LOCKED_VAL); +} + +/* + * __mcs_pass_lock - pass the MCS lock to the next waiter + * @node: Pointer to the MCS node of the lock holder + * @next: Pointer to the MCS node of the first waiter in the MCS queue + */ +static __always_inline void __mcs_pass_lock(struct mcs_spinlock *node, + struct mcs_spinlock *next) +{ + arch_mcs_pass_lock(>locked, 1); +} + +#define try_clear_tail __try_clear_tail +#define mcs_pass_lock __mcs_pass_lock + #endif /* _GEN_PV_LOCK_SLOWPATH */ /** @@ -532,7 +560,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) * PENDING will make the uncontended transition fail. */ if ((val & _Q_TAIL_MASK) == tail) { - if (atomic_try_cmpxchg_relaxed(>val, , _Q_LOCKED_VAL)) + if (try_clear_tail(lock, val, node)) goto release; /* No contention */ } @@ -549,7 +577,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) if (!next) next = smp_cond_load_relaxed(>next, (VAL)); - arch_mcs_pass_lock(>locked, 1); + mcs_pass_lock(node, next); pv_kick_node(lock, next); release: @@ -574,6 +602,12 @@ EXPORT_SYMBOL(queued_spin_lock_slowpath); #undef pv_kick_node #undef pv_wait_head_or_lock +#undef try_clear_tail +#define try_clear_tail __try_clear_tail + +#undef mcs_pass_lock +#define mcs_pass_lock __mcs_pass_lock + #undef queued_spin_lock_slowpath #define queued_spin_lock_slowpath __pv_queued_spin_lock_slowpath -- 2.11.0 (Apple Git-81)
Re: [PATCH 2/7] rcu: fix tracepoint string when RCU CPU kthread runs
On 2019/10/16 11:38 上午, Paul E. McKenney wrote: On Tue, Oct 15, 2019 at 10:23:57AM +, Lai Jiangshan wrote: "rcu_wait" is incorrct here, use "rcu_run" instead. Signed-off-by: Lai Jiangshan Signed-off-by: Lai Jiangshan --- kernel/rcu/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 278798e58698..c351fc280945 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2485,7 +2485,7 @@ static void rcu_cpu_kthread(unsigned int cpu) int spincnt; for (spincnt = 0; spincnt < 10; spincnt++) { - trace_rcu_utilization(TPS("Start CPU kthread@rcu_wait")); + trace_rcu_utilization(TPS("Start CPU kthread@rcu_run")); local_bh_disable(); *statusp = RCU_KTHREAD_RUNNING; local_irq_disable(); @@ -2496,7 +2496,7 @@ static void rcu_cpu_kthread(unsigned int cpu) rcu_core(); local_bh_enable(); if (*workp == 0) { - trace_rcu_utilization(TPS("End CPU kthread@rcu_wait")); + trace_rcu_utilization(TPS("End CPU kthread@rcu_run")); This one needs to stay as it was because this is where we wait when out of work. I don't fully understand those TPS marks. If it is all about "where we wait when out of work", it ought to be "Start ... wait", rather than "End ... wait". The later one ("End ... wait") should be put before "for (spincnt = 0; spincnt < 10; spincnt++)" and remove the whole "rcu_run" as this patch suggested. To be honest, "rcu_run" is redundant since we already has TPS("Start RCU core"). Any ways, patch2&3 lose their relevance and should be dropped. Looking forward to your improved version. Thanks, Lai So I took the first hunk and dropped this second hunk. Please let me know if I am missing something. Thanx, Paul *statusp = RCU_KTHREAD_WAITING; return; } -- 2.20.1
[v3,1/2] dt-bindings: i2c: support property idle-state
This supports property idle-state Signed-off-by: Biwen Li --- Change in v3: - update subject and description - add some information for property idle-state Change in v2: - update subject and description - add property idle-state Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt index 30ac6a60f041..7abda506b828 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt @@ -25,6 +25,8 @@ Required Properties: Optional Properties: - reset-gpios: Reference to the GPIO connected to the reset input. + - idle-state: if present, overrides i2c-mux-idle-disconnect, +Please refer to Documentation/devicetree/bindings/mux/mux-controller.txt - i2c-mux-idle-disconnect: Boolean; if defined, forces mux to disconnect all children in idle state. This is necessary for example, if there are several multiplexers on the bus and the devices behind them use same I2C addresses. -- 2.17.1
[v3,2/2] i2c: mux: pca954x: support property idle-state
This supports property idle-state Signed-off-by: Biwen Li --- Change in v3: - update subject and description - add a helper function pca954x_calculate_chan() Change in v2: - update subject and description - add property idle-state drivers/i2c/muxes/i2c-mux-pca954x.c | 64 ++--- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 923aa3a5a3dc..8777d429269c 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -86,7 +86,7 @@ struct pca954x { u8 last_chan; /* last register value */ /* MUX_IDLE_AS_IS, MUX_IDLE_DISCONNECT or >= 0 for channel */ - s8 idle_state; + s32 idle_state; struct i2c_client *client; @@ -229,22 +229,25 @@ static int pca954x_reg_write(struct i2c_adapter *adap, I2C_SMBUS_BYTE, ); } +static int pca954x_calculate_chan(struct pca954x *data, u32 chan) +{ + /* we make switches look like muxes, not sure how to be smarter */ + if (data->chip->muxtype == pca954x_ismux) + return chan | data->chip->enable; + else + return 1 << chan; +} + static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan) { struct pca954x *data = i2c_mux_priv(muxc); struct i2c_client *client = data->client; - const struct chip_desc *chip = data->chip; u8 regval; int ret = 0; - /* we make switches look like muxes, not sure how to be smarter */ - if (chip->muxtype == pca954x_ismux) - regval = chan | chip->enable; - else - regval = 1 << chan; - + regval = pca954x_calculate_chan(data, chan); /* Only select the channel if its different from the last channel */ - if (data->last_chan != regval) { + if ((data->last_chan & 0xff) != regval) { ret = pca954x_reg_write(muxc->parent, client, regval); data->last_chan = ret < 0 ? 0 : regval; } @@ -256,7 +259,7 @@ static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan) { struct pca954x *data = i2c_mux_priv(muxc); struct i2c_client *client = data->client; - s8 idle_state; + s32 idle_state; idle_state = READ_ONCE(data->idle_state); if (idle_state >= 0) @@ -402,6 +405,23 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc) i2c_mux_del_adapters(muxc); } +static int pca954x_init(struct i2c_client *client, struct pca954x *data) +{ + /* +* Write the mux register at addr to verify +* that the mux is in fact present. This also +* initializes the mux to a channel +* or disconnected state. +*/ + if (data->idle_state >= 0) { + data->last_chan = pca954x_calculate_chan(data, data->idle_state); + } else { + /* Disconnect multiplexer */ + data->last_chan = 0; + } + return i2c_smbus_write_byte(client, data->last_chan); +} + /* * I2C init/probing/exit functions */ @@ -411,7 +431,6 @@ static int pca954x_probe(struct i2c_client *client, struct i2c_adapter *adap = client->adapter; struct device *dev = >dev; struct device_node *np = dev->of_node; - bool idle_disconnect_dt; struct gpio_desc *gpio; struct i2c_mux_core *muxc; struct pca954x *data; @@ -462,22 +481,18 @@ static int pca954x_probe(struct i2c_client *client, } } - /* Write the mux register at addr to verify -* that the mux is in fact present. This also -* initializes the mux to disconnected state. -*/ - if (i2c_smbus_write_byte(client, 0) < 0) { + data->idle_state = MUX_IDLE_AS_IS; + if (np && of_property_read_u32(np, "idle-state", >idle_state)) { + if (np && of_property_read_bool(np, "i2c-mux-idle-disconnect")) + data->idle_state = MUX_IDLE_DISCONNECT; + } + + ret = pca954x_init(client, data); + if (ret < 0) { dev_warn(dev, "probe failed\n"); return -ENODEV; } - data->last_chan = 0; /* force the first selection */ - data->idle_state = MUX_IDLE_AS_IS; - - idle_disconnect_dt = np && - of_property_read_bool(np, "i2c-mux-idle-disconnect"); - if (idle_disconnect_dt) - data->idle_state = MUX_IDLE_DISCONNECT; ret = pca954x_irq_setup(muxc); if (ret) @@ -531,8 +546,7 @@ static int pca954x_resume(struct device *dev) struct i2c_mux_core *muxc = i2c_get_clientdata(client); struct pca954x *data = i2c_mux_priv(muxc); - data->last_chan = 0; - return i2c_smbus_write_byte(client, 0); + return pca954x_init(client, data); } #endif -- 2.17.1
Re: [PATCH 27/34] rcu: Use CONFIG_PREEMPTION where appropriate
On Tue, Oct 15, 2019 at 09:18:14PM +0200, Sebastian Andrzej Siewior wrote: > The config option `CONFIG_PREEMPT' is used for the preemption model > "Low-Latency Desktop". The config option `CONFIG_PREEMPTION' is enabled > when kernel preemption is enabled which is true for the preemption model > `CONFIG_PREEMPT' and `CONFIG_PREEMPT_RT'. > > Use `CONFIG_PREEMPTION' if it applies to both preemption models and not > just to `CONFIG_PREEMPT'. > > Cc: "Paul E. McKenney" > Cc: Josh Triplett > Cc: Steven Rostedt > Cc: Mathieu Desnoyers > Cc: Lai Jiangshan > Cc: Joel Fernandes > Cc: Davidlohr Bueso > Cc: r...@vger.kernel.org > Signed-off-by: Sebastian Andrzej Siewior This one does apply, so I have queued it for review and testing, thank you! Thanx, Paul > --- > include/linux/rcupdate.h | 4 ++-- > kernel/rcu/Kconfig | 4 ++-- > kernel/rcu/rcutorture.c | 2 +- > kernel/rcu/srcutiny.c| 2 +- > kernel/rcu/tree.c| 4 ++-- > kernel/rcu/tree_exp.h| 2 +- > kernel/rcu/tree_plugin.h | 4 ++-- > 7 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 75a2eded7aa2c..1e3dad252d61f 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -154,7 +154,7 @@ static inline void exit_tasks_rcu_finish(void) { } > * > * This macro resembles cond_resched(), except that it is defined to > * report potential quiescent states to RCU-tasks even if the cond_resched() > - * machinery were to be shut off, as some advocate for PREEMPT kernels. > + * machinery were to be shut off, as some advocate for PREEMPTION kernels. > */ > #define cond_resched_tasks_rcu_qs() \ > do { \ > @@ -580,7 +580,7 @@ do { > \ > * > * You can avoid reading and understanding the next paragraph by > * following this rule: don't put anything in an rcu_read_lock() RCU > - * read-side critical section that would block in a !PREEMPT kernel. > + * read-side critical section that would block in a !PREEMPTION kernel. > * But if you want the full story, read on! > * > * In non-preemptible RCU implementations (TREE_RCU and TINY_RCU), > diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig > index 7644eda17d624..01b56177464d8 100644 > --- a/kernel/rcu/Kconfig > +++ b/kernel/rcu/Kconfig > @@ -200,8 +200,8 @@ config RCU_NOCB_CPU > specified at boot time by the rcu_nocbs parameter. For each > such CPU, a kthread ("rcuox/N") will be created to invoke > callbacks, where the "N" is the CPU being offloaded, and where > - the "p" for RCU-preempt (PREEMPT kernels) and "s" for RCU-sched > - (!PREEMPT kernels). Nothing prevents this kthread from running > + the "p" for RCU-preempt (PREEMPTION kernels) and "s" for RCU-sched > + (!PREEMPTION kernels). Nothing prevents this kthread from running > on the specified CPUs, but (1) the kthreads may be preempted > between each callback, and (2) affinity or cgroups can be used > to force the kthreads to run on whatever set of CPUs is desired. > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > index 3c9feca1eab17..c070d103f34d6 100644 > --- a/kernel/rcu/rcutorture.c > +++ b/kernel/rcu/rcutorture.c > @@ -1725,7 +1725,7 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp) > // Give the scheduler a chance, even on nohz_full CPUs. > static void rcu_torture_fwd_prog_cond_resched(unsigned long iter) > { > - if (IS_ENABLED(CONFIG_PREEMPT) && IS_ENABLED(CONFIG_NO_HZ_FULL)) { > + if (IS_ENABLED(CONFIG_PREEMPTION) && IS_ENABLED(CONFIG_NO_HZ_FULL)) { > // Real call_rcu() floods hit userspace, so emulate that. > if (need_resched() || (iter & 0xfff)) > schedule(); > diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c > index 44d6606b83257..6208c1dae5c95 100644 > --- a/kernel/rcu/srcutiny.c > +++ b/kernel/rcu/srcutiny.c > @@ -103,7 +103,7 @@ EXPORT_SYMBOL_GPL(__srcu_read_unlock); > > /* > * Workqueue handler to drive one grace period and invoke any callbacks > - * that become ready as a result. Single-CPU and !PREEMPT operation > + * that become ready as a result. Single-CPU and !PREEMPTION operation > * means that we get away with murder on synchronization. ;-) > */ > void srcu_drive_gp(struct work_struct *wp) > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 81105141b6a82..1c5de816ae9e5 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -2667,9 +2667,9 @@ EXPORT_SYMBOL_GPL(kfree_call_rcu); > > /* > * During early boot, any blocking grace-period wait automatically > - * implies a grace period. Later on, this is never the case for PREEMPT. > + * implies a grace period. Later on, this is never the case for PREEMPTION. > * > - * Howevr, because a context switch is a grace period
Re: [PATCH] rcu: move rcu_{expedited,normal} definitions into rcupdate.h
On Tue, Oct 15, 2019 at 02:48:22PM +0100, Ben Dooks wrote: > Move the rcu_{expedited,normal} definitions into rcupdate.h > to make sure they are in sync, and avoid the following > warning from sparse: > > kernel/ksysfs.c:150:5: warning: symbol 'rcu_expedited' was not declared. > Should it be static? > kernel/ksysfs.c:167:5: warning: symbol 'rcu_normal' was not declared. Should > it be static? > > Signed-off-by: Ben Dooks Good point, queued for review and testing, thank you! Thanx, Paul > --- > Cc: "Paul E. McKenney" > Cc: Josh Triplett > Cc: Steven Rostedt > Cc: Mathieu Desnoyers > Cc: Lai Jiangshan > Cc: Joel Fernandes > Cc: r...@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > include/linux/rcupdate.h | 4 > kernel/rcu/update.c | 2 -- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 75a2eded7aa2..a175d6e3ad77 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -894,4 +894,8 @@ rcu_head_after_call_rcu(struct rcu_head *rhp, > rcu_callback_t f) > return false; > } > > +/* kernel/ksysfs.c definitions */ > +extern int rcu_expedited; > +extern int rcu_normal; > + > #endif /* __LINUX_RCUPDATE_H */ > diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c > index 1861103662db..294d357abd0c 100644 > --- a/kernel/rcu/update.c > +++ b/kernel/rcu/update.c > @@ -51,9 +51,7 @@ > #define MODULE_PARAM_PREFIX "rcupdate." > > #ifndef CONFIG_TINY_RCU > -extern int rcu_expedited; /* from sysctl */ > module_param(rcu_expedited, int, 0); > -extern int rcu_normal; /* from sysctl */ > module_param(rcu_normal, int, 0); > static int rcu_normal_after_boot; > module_param(rcu_normal_after_boot, int, 0); > -- > 2.23.0 >
Re: [PATCH] rcu: rcu_segcblist.c make undeclared items static
On Tue, Oct 15, 2019 at 11:55:24AM +0100, Ben Dooks wrote: > The following are not used outside the unit they are > declared in, so make them static to avoid the following > sparse warnings: > > kernel/rcu/rcu_segcblist.c:91:6: warning: symbol 'rcu_segcblist_set_len' was > not declared. Should it be static? > kernel/rcu/rcu_segcblist.c:107:6: warning: symbol 'rcu_segcblist_add_len' was > not declared. Should it be static? > kernel/rcu/rcu_segcblist.c:137:6: warning: symbol 'rcu_segcblist_xchg_len' > was not declared. Should it be static? > > Signed-off-by: Ben Dooks Good catch, but commit 292d1bb2 ("rcu: Several rcu_segcblist functions can be static") beat you to it by a month or two. This commit is still in -rcu, but will be part of my pull request in a couple of weeks. See -rcu branch "dev": git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git Thanx, Paul > --- > Cc: "Paul E. McKenney" > Cc: Josh Triplett > Cc: Steven Rostedt > Cc: Mathieu Desnoyers > Cc: Lai Jiangshan > Cc: Joel Fernandes > Cc: r...@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > kernel/rcu/rcu_segcblist.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c > index 495c58ce1640..cbc87b804db9 100644 > --- a/kernel/rcu/rcu_segcblist.c > +++ b/kernel/rcu/rcu_segcblist.c > @@ -88,7 +88,7 @@ struct rcu_head *rcu_cblist_dequeue(struct rcu_cblist *rclp) > } > > /* Set the length of an rcu_segcblist structure. */ > -void rcu_segcblist_set_len(struct rcu_segcblist *rsclp, long v) > +static void rcu_segcblist_set_len(struct rcu_segcblist *rsclp, long v) > { > #ifdef CONFIG_RCU_NOCB_CPU > atomic_long_set(>len, v); > @@ -104,7 +104,7 @@ void rcu_segcblist_set_len(struct rcu_segcblist *rsclp, > long v) > * This increase is fully ordered with respect to the callers accesses > * both before and after. > */ > -void rcu_segcblist_add_len(struct rcu_segcblist *rsclp, long v) > +static void rcu_segcblist_add_len(struct rcu_segcblist *rsclp, long v) > { > #ifdef CONFIG_RCU_NOCB_CPU > smp_mb__before_atomic(); /* Up to the caller! */ > @@ -134,7 +134,7 @@ void rcu_segcblist_inc_len(struct rcu_segcblist *rsclp) > * with the actual number of callbacks on the structure. This exchange is > * fully ordered with respect to the callers accesses both before and after. > */ > -long rcu_segcblist_xchg_len(struct rcu_segcblist *rsclp, long v) > +static long rcu_segcblist_xchg_len(struct rcu_segcblist *rsclp, long v) > { > #ifdef CONFIG_RCU_NOCB_CPU > return atomic_long_xchg(>len, v); > -- > 2.23.0 >
Re: [PATCH] net: usb: sr9800: fix uninitialized local variable
From: Valentin Vidic Date: Tue, 15 Oct 2019 22:20:20 +0200 > Make sure res does not contain random value if the call to > sr_read_cmd fails for some reason. > > Reported-by: syzbot+f1842130bbcfb335b...@syzkaller.appspotmail.com > Signed-off-by: Valentin Vidic Applied. But often in situation like this a failed read can more aptly be indicated by an all-1's value.
Re: [PATCH net] net: bcmgenet: Fix RGMII_MODE_EN value for GENET v1/2/3
From: Florian Fainelli Date: Tue, 15 Oct 2019 10:45:47 -0700 > The RGMII_MODE_EN bit value was 0 for GENET versions 1 through 3, and > became 6 for GENET v4 and above, account for that difference. > > Fixes: aa09677cba42 ("net: bcmgenet: add MDIO routines") > Signed-off-by: Florian Fainelli Applied and queued up for -stable.
Re: [PATCH net-next] net: bcmgenet: Add a shutdown callback
From: Florian Fainelli Date: Tue, 15 Oct 2019 10:36:24 -0700 > Make sure that we completely quiesce the network device, including its > DMA to avoid having it continue to receive packets while there is no > software alive to service those. > > Signed-off-by: Florian Fainelli Applied.
Re: [PATCH] net: stmmac: make tc_flow_parsers static
From: "Ben Dooks (Codethink)" Date: Tue, 15 Oct 2019 17:17:48 +0100 > The tc_flow_parsers is not used outside of the driver, so > make it static to avoid the following sparse warning: > > drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c:516:3: warning: symbol > 'tc_flow_parsers' was not declared. Should it be static? > > Signed-off-by: Ben Dooks Applied.
Re: [PATCH] davinci_cpdma: make cpdma_chan_split_pool static
From: "Ben Dooks (Codethink)" Date: Tue, 15 Oct 2019 17:15:58 +0100 > The cpdma_chan_split_pool() function is not used outside of > the driver, so make it static to avoid the following sparse > warning: > > drivers/net/ethernet/ti/davinci_cpdma.c:725:5: warning: symbol > 'cpdma_chan_split_pool' was not declared. Should it be static? > > Signed-off-by: Ben Dooks Applied, thanks.
Re: [PATCH] vsock/virtio: remove unused 'work' field from 'struct virtio_vsock_pkt'
From: Stefano Garzarella Date: Tue, 15 Oct 2019 17:00:51 +0200 > The 'work' field was introduced with commit 06a8fc78367d0 > ("VSOCK: Introduce virtio_vsock_common.ko") > but it is never used in the code, so we can remove it to save > memory allocated in the per-packet 'struct virtio_vsock_pkt' > > Suggested-by: Michael S. Tsirkin > Signed-off-by: Stefano Garzarella Michael, will you take this? I assume so... Thanks.
Re: [PATCH 6/7] rcu: rename some CONFIG_PREEMPTION to CONFIG_PREEMPT_RCU
On Tue, Oct 15, 2019 at 10:28:48AM +, Lai Jiangshan wrote: > CONFIG_PREEMPTION and CONFIG_PREEMPT_RCU are always identical, > but some code depends on CONFIG_PREEMPTION to access to > rcu_preempt functionalitis. This patch changes CONFIG_PREEMPTION > to CONFIG_PREEMPT_RCU in these cases. > > Signed-off-by: Lai Jiangshan > Signed-off-by: Lai Jiangshan I believe that this does not cause problems with Sebastian's patch "[PATCH 27/34] rcu: Use CONFIG_PREEMPTION where appropriate", but could you please check? Thanx, Paul > --- > kernel/rcu/tree.c | 4 ++-- > kernel/rcu/tree_stall.h | 6 +++--- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 7db5ea06a9ed..81eb64fcf5ab 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -1926,7 +1926,7 @@ rcu_report_unblock_qs_rnp(struct rcu_node *rnp, > unsigned long flags) > struct rcu_node *rnp_p; > > raw_lockdep_assert_held_rcu_node(rnp); > - if (WARN_ON_ONCE(!IS_ENABLED(CONFIG_PREEMPTION)) || > + if (WARN_ON_ONCE(!IS_ENABLED(CONFIG_PREEMPT_RCU)) || > WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp)) || > rnp->qsmask != 0) { > raw_spin_unlock_irqrestore_rcu_node(rnp, flags); > @@ -2294,7 +2294,7 @@ static void force_qs_rnp(int (*f)(struct rcu_data *rdp)) > mask = 0; > raw_spin_lock_irqsave_rcu_node(rnp, flags); > if (rnp->qsmask == 0) { > - if (!IS_ENABLED(CONFIG_PREEMPTION) || > + if (!IS_ENABLED(CONFIG_PREEMPT_RCU) || > rcu_preempt_blocked_readers_cgp(rnp)) { > /* >* No point in scanning bits because they > diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h > index 0b75426ebb3e..55f9b84790d3 100644 > --- a/kernel/rcu/tree_stall.h > +++ b/kernel/rcu/tree_stall.h > @@ -163,7 +163,7 @@ static void rcu_iw_handler(struct irq_work *iwp) > // > // Printing RCU CPU stall warnings > > -#ifdef CONFIG_PREEMPTION > +#ifdef CONFIG_PREEMPT_RCU > > /* > * Dump detailed information for all tasks blocking the current RCU > @@ -215,7 +215,7 @@ static int rcu_print_task_stall(struct rcu_node *rnp) > return ndetected; > } > > -#else /* #ifdef CONFIG_PREEMPTION */ > +#else /* #ifdef CONFIG_PREEMPT_RCU */ > > /* > * Because preemptible RCU does not exist, we never have to check for > @@ -233,7 +233,7 @@ static int rcu_print_task_stall(struct rcu_node *rnp) > { > return 0; > } > -#endif /* #else #ifdef CONFIG_PREEMPTION */ > +#endif /* #else #ifdef CONFIG_PREEMPT_RCU */ > > /* > * Dump stacks of all tasks running on stalled CPUs. First try using > -- > 2.20.1 >
RE: [PATCH v5 1/6] psci: Export psci_ops.conduit symbol as modules will use it.
Hi Mark, > -Original Message- > From: Mark Rutland > Sent: Wednesday, October 16, 2019 1:25 AM > To: Jianyong Wu (Arm Technology China) > Cc: net...@vger.kernel.org; yangbo...@nxp.com; john.stu...@linaro.org; > t...@linutronix.de; pbonz...@redhat.com; sean.j.christopher...@intel.com; > m...@kernel.org; richardcoch...@gmail.com; w...@kernel.org; Suzuki > Poulose ; linux-kernel@vger.kernel.org; linux- > arm-ker...@lists.infradead.org; kvm...@lists.cs.columbia.edu; > k...@vger.kernel.org; Steve Capper ; Kaly Xin > (Arm Technology China) ; Justin He (Arm Technology > China) ; nd > Subject: Re: [PATCH v5 1/6] psci: Export psci_ops.conduit symbol as modules > will use it. > > On Tue, Oct 15, 2019 at 06:48:17PM +0800, Jianyong Wu wrote: > > If arm_smccc_1_1_invoke used in modules, psci_ops.conduit should be > > export. > > > > Signed-off-by: Jianyong Wu > > I have a patch queued [1] in the arm64 tree which adds > arm_smccc_1_1_get_conduit() for this purpose. > > Please use that, adding an EXPORT_SYMBOL() if necessary. > Great, I will apply it next version. Thanks Jianyong Wu > Thanks, > Mark. > > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?h= > for-next/smccc-conduit- > cleanup=6b7fe77c334ae59fed9500140e08f4f896b36871 > > > --- > > drivers/firmware/psci/psci.c | 6 ++ > > include/linux/arm-smccc.h| 2 +- > > include/linux/psci.h | 1 + > > 3 files changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/psci/psci.c > > b/drivers/firmware/psci/psci.c index f82ccd39a913..35c4eaab1451 100644 > > --- a/drivers/firmware/psci/psci.c > > +++ b/drivers/firmware/psci/psci.c > > @@ -212,6 +212,12 @@ static unsigned long > psci_migrate_info_up_cpu(void) > > 0, 0, 0); > > } > > > > +enum psci_conduit psci_get_conduit(void) { > > + return psci_ops.conduit; > > +} > > +EXPORT_SYMBOL(psci_get_conduit); > > + > > static void set_conduit(enum psci_conduit conduit) { > > switch (conduit) { > > diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h > > index 552cbd49abe8..a6e4d3e3d10a 100644 > > --- a/include/linux/arm-smccc.h > > +++ b/include/linux/arm-smccc.h > > @@ -357,7 +357,7 @@ asmlinkage void __arm_smccc_hvc(unsigned long > a0, unsigned long a1, > > * The return value also provides the conduit that was used. > > */ > > #define arm_smccc_1_1_invoke(...) ({ > \ > > - int method = psci_ops.conduit; \ > > + int method = psci_get_conduit();\ > > switch (method) { \ > > case PSCI_CONDUIT_HVC: > \ > > arm_smccc_1_1_hvc(__VA_ARGS__); > \ > > diff --git a/include/linux/psci.h b/include/linux/psci.h index > > a8a15613c157..e5cedc986049 100644 > > --- a/include/linux/psci.h > > +++ b/include/linux/psci.h > > @@ -42,6 +42,7 @@ struct psci_operations { > > enum smccc_version smccc_version; > > }; > > > > +extern enum psci_conduit psci_get_conduit(void); > > extern struct psci_operations psci_ops; > > > > #if defined(CONFIG_ARM_PSCI_FW) > > -- > > 2.17.1 > >
Re: [PATCH net] net: i82596: fix dma_alloc_attr for sni_82596
From: Thomas Bogendoerfer Date: Tue, 15 Oct 2019 16:42:45 +0200 > Commit 7f683b920479 ("i825xx: switch to switch to dma_alloc_attrs") > switched dma allocation over to dma_alloc_attr, but didn't convert > the SNI part to request consistent DMA memory. This broke sni_82596 > since driver doesn't do dma_cache_sync for performance reasons. > Fix this by using different DMA_ATTRs for lasi_82596 and sni_82596. > > Fixes: 7f683b920479 ("i825xx: switch to switch to dma_alloc_attrs") > Signed-off-by: Thomas Bogendoerfer Applied and queued up for -stable.
Re: [PATCH] usb: typec: Add sysfs node to show cc orientation
On 10/15/19 8:43 PM, pumahsu wrote: > Export the Type-C cc orientation so that user space can > get this information. > > Signed-off-by: pumahsu Hi, what the * is cc orientation? > --- > Documentation/ABI/testing/sysfs-class-typec | 7 +++ > drivers/usb/typec/class.c | 11 +++ > 2 files changed, 18 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-class-typec > b/Documentation/ABI/testing/sysfs-class-typec > index d7647b258c3c..419f952c991d 100644 > --- a/Documentation/ABI/testing/sysfs-class-typec > +++ b/Documentation/ABI/testing/sysfs-class-typec > @@ -108,6 +108,13 @@ Contact: Heikki Krogerus > > Description: > Revision number of the supported USB Type-C specification. > > +What:/sys/class/typec//cc_orientation > +Date:September 2019 > +Contact: Puma Hsu > +Description: > + Indicates which cc orientation is active now, or 0 when > + nothing is connected. > + > > USB Type-C partner devices (eg. /sys/class/typec/port0-partner/) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index 7d8805d9bf37..00edae63da8e 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -1238,6 +1238,16 @@ static ssize_t usb_power_delivery_revision_show(struct > device *dev, > } > static DEVICE_ATTR_RO(usb_power_delivery_revision); > > +static ssize_t cc_orientation_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct typec_port *p = to_typec_port(dev); > + > + return sprintf(buf, "%d\n", typec_get_orientation(p)); > +} > +static DEVICE_ATTR_RO(cc_orientation); > + > static struct attribute *typec_attrs[] = { > _attr_data_role.attr, > _attr_power_operation_mode.attr, > @@ -1248,6 +1258,7 @@ static struct attribute *typec_attrs[] = { > _attr_usb_typec_revision.attr, > _attr_vconn_source.attr, > _attr_port_type.attr, > + _attr_cc_orientation.attr, > NULL, > }; > ATTRIBUTE_GROUPS(typec); > -- ~Randy
Re: [PATCH 4/7] rcu: remove the declaration of call_rcu() in tree.h
On Tue, Oct 15, 2019 at 10:28:46AM +, Lai Jiangshan wrote: > call_rcu() is external RCU API declared in include/linux/, > and doesn't need to be (re-)declared in internal files again. > > Signed-off-by: Lai Jiangshan > Signed-off-by: Lai Jiangshan Good catch! Queued for testing and review, thank you! Thanx, Paul > --- > kernel/rcu/tree.h | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h > index f8e6c70cceef..823f475c5e35 100644 > --- a/kernel/rcu/tree.h > +++ b/kernel/rcu/tree.h > @@ -412,7 +412,6 @@ static bool rcu_preempt_has_tasks(struct rcu_node *rnp); > static int rcu_print_task_exp_stall(struct rcu_node *rnp); > static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); > static void rcu_flavor_sched_clock_irq(int user); > -void call_rcu(struct rcu_head *head, rcu_callback_t func); > static void dump_blkd_tasks(struct rcu_node *rnp, int ncheck); > static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); > static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); > -- > 2.20.1 >
[PATCH v3 1/3] bpf: use check_zeroed_user() in bpf_check_uarg_tail_zero()
In v5.4-rc2 we added a new helper (cf. [1]) check_zeroed_user() which does what bpf_check_uarg_tail_zero() is doing generically. We're slowly switching such codepaths over to use check_zeroed_user() instead of using their own hand-rolled version. [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: b...@vger.kernel.org Acked-by: Aleksa Sarai Signed-off-by: Christian Brauner --- /* v1 */ Link: https://lore.kernel.org/r/20191009160907.10981-2-christian.brau...@ubuntu.com /* v2 */ Link: https://lore.kernel.org/r/20191016004138.24845-2-christian.brau...@ubuntu.com - Alexei Starovoitov : - Add a comment in bpf_check_uarg_tail_zero() to clarify that copy_struct_from_user() should be used whenever possible instead. /* v3 */ - Christian Brauner : - use correct checks for check_zeroed_user() --- kernel/bpf/syscall.c | 25 + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 82eabd4e38ad..40edcaeccd71 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -58,35 +58,28 @@ static const struct bpf_map_ops * const bpf_map_types[] = { * There is a ToCToU between this function call and the following * copy_from_user() call. However, this is not a concern since this function is * meant to be a future-proofing of bits. + * + * Note, instead of using bpf_check_uarg_tail_zero() followed by + * copy_from_user() use the dedicated copy_struct_from_user() helper which + * performs both tasks whenever possible. */ int bpf_check_uarg_tail_zero(void __user *uaddr, size_t expected_size, size_t actual_size) { - unsigned char __user *addr; - unsigned char __user *end; - unsigned char val; + size_t size = min(expected_size, actual_size); + size_t rest = max(expected_size, actual_size) - size; int err; if (unlikely(actual_size > PAGE_SIZE)) /* silly large */ return -E2BIG; - if (unlikely(!access_ok(uaddr, actual_size))) - return -EFAULT; - if (actual_size <= expected_size) return 0; - addr = uaddr + expected_size; - end = uaddr + actual_size; - - for (; addr < end; addr++) { - err = get_user(val, addr); - if (err) - return err; - if (val) - return -E2BIG; - } + err = check_zeroed_user(uaddr + expected_size, rest); + if (err <= 0) + return err ?: -E2BIG; return 0; } -- 2.23.0
[PATCH v3 3/3] bpf: use copy_struct_from_user() in bpf() syscall
In v5.4-rc2 we added a new helper (cf. [1]) copy_struct_from_user(). This helper is intended for all codepaths that copy structs from userspace that are versioned by size. The bpf() syscall does exactly what copy_struct_from_user() is doing. Note that copy_struct_from_user() is calling min() already. So technically, the min_t() call could go. But the size is used further below so leave it. [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: b...@vger.kernel.org Acked-by: Aleksa Sarai Signed-off-by: Christian Brauner --- /* v1 */ Link: https://lore.kernel.org/r/20191009160907.10981-4-christian.brau...@ubuntu.com /* v2 */ Link: https://lore.kernel.org/r/20191016004138.24845-4-christian.brau...@ubuntu.com - Alexei Starovoitov : - remove unneeded initialization /* v3 */ unchanged --- kernel/bpf/syscall.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 151447f314ca..0920593eacd0 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2814,20 +2814,17 @@ static int bpf_task_fd_query(const union bpf_attr *attr, SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size) { - union bpf_attr attr = {}; + union bpf_attr attr; int err; if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN)) return -EPERM; - err = bpf_check_uarg_tail_zero(uattr, sizeof(attr), size); - if (err) - return err; size = min_t(u32, size, sizeof(attr)); - /* copy attributes from user space, may be less than sizeof(bpf_attr) */ - if (copy_from_user(, uattr, size) != 0) - return -EFAULT; + err = copy_struct_from_user(, sizeof(attr), uattr, size); + if (err) + return err; err = security_bpf(cmd, , size); if (err < 0) -- 2.23.0
[PATCH v3 0/3] bpf: switch to new usercopy helpers
Hey everyone, In v5.4-rc2 we added two new helpers check_zeroed_user() and copy_struct_from_user() including selftests (cf. [1]). It is a generic interface designed to copy a struct from userspace. The helpers will be especially useful for structs versioned by size of which we have quite a few. The most obvious benefit is that this helper lets us get rid of duplicate code. We've already switched over sched_setattr(), perf_event_open(), and clone3(). More importantly it will also help to ensure that users implementing versioning-by-size end up with the same core semantics. This point is especially crucial since we have at least one case where versioning-by-size is used but with slighly different semantics: sched_setattr(), perf_event_open(), and clone3() all do do similar checks to copy_struct_from_user() while rt_sigprocmask(2) always rejects differently-sized struct arguments. This little series switches over bpf codepaths that have hand-rolled implementations of these helpers. This series can also be pulled: The following changes since commit 5bc60de50dfea235634fdf38cbc992fb968d113b: selftests: bpf: Don't try to read files without read permission (2019-10-15 16:27:25 -0700) are available in the Git repository at: g...@gitolite.kernel.org:pub/scm/linux/kernel/git/brauner/linux tags/bpf-copy-struct-from-user for you to fetch changes up to 31a197d406cc01451e98312665d116c2dbb08202: bpf: use copy_struct_from_user() in bpf() syscall (2019-10-16 05:32:38 +0200) bpf-copy-struct-from-user Christian Brauner (3): bpf: use check_zeroed_user() in bpf_check_uarg_tail_zero() bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd() bpf: use copy_struct_from_user() in bpf() syscall kernel/bpf/syscall.c | 45 - 1 file changed, 16 insertions(+), 29 deletions(-) Thanks! Christian /* v1 */ Link: https://lore.kernel.org/r/20191009160907.10981-1-christian.brau...@ubuntu.com /* v2 */ Link: https://lore.kernel.org/r/20191016004138.24845-1-christian.brau...@ubuntu.com - rebase onto bpf-next /* Reference */ [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") Christian Brauner (3): bpf: use check_zeroed_user() in bpf_check_uarg_tail_zero() bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd() bpf: use copy_struct_from_user() in bpf() syscall kernel/bpf/syscall.c | 45 1 file changed, 16 insertions(+), 29 deletions(-) -- 2.23.0
[PATCH v3 2/3] bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd()
In v5.4-rc2 we added a new helper (cf. [1]) copy_struct_from_user(). This helper is intended for all codepaths that copy structs from userspace that are versioned by size. bpf_prog_get_info_by_fd() does exactly what copy_struct_from_user() is doing. Note that copy_struct_from_user() is calling min() already. So technically, the min_t() call could go. But the info_len is used further below so leave it. [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: b...@vger.kernel.org Acked-by: Aleksa Sarai Signed-off-by: Christian Brauner --- /* v1 */ Link: https://lore.kernel.org/r/20191009160907.10981-3-christian.brau...@ubuntu.com /* v2 */ Link: https://lore.kernel.org/r/20191016004138.24845-3-christian.brau...@ubuntu.com - Alexei Starovoitov : - remove unneeded initialization /* v3 */ unchanged --- kernel/bpf/syscall.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 40edcaeccd71..151447f314ca 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2306,20 +2306,17 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, union bpf_attr __user *uattr) { struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info); - struct bpf_prog_info info = {}; + struct bpf_prog_info info; u32 info_len = attr->info.info_len; struct bpf_prog_stats stats; char __user *uinsns; u32 ulen; int err; - err = bpf_check_uarg_tail_zero(uinfo, sizeof(info), info_len); + info_len = min_t(u32, sizeof(info), info_len); + err = copy_struct_from_user(, sizeof(info), uinfo, info_len); if (err) return err; - info_len = min_t(u32, sizeof(info), info_len); - - if (copy_from_user(, uinfo, info_len)) - return -EFAULT; info.type = prog->type; info.id = prog->aux->id; -- 2.23.0
[PATCH] usb: typec: Add sysfs node to show cc orientation
Export the Type-C cc orientation so that user space can get this information. Signed-off-by: pumahsu --- Documentation/ABI/testing/sysfs-class-typec | 7 +++ drivers/usb/typec/class.c | 11 +++ 2 files changed, 18 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec index d7647b258c3c..419f952c991d 100644 --- a/Documentation/ABI/testing/sysfs-class-typec +++ b/Documentation/ABI/testing/sysfs-class-typec @@ -108,6 +108,13 @@ Contact: Heikki Krogerus Description: Revision number of the supported USB Type-C specification. +What: /sys/class/typec//cc_orientation +Date: September 2019 +Contact: Puma Hsu +Description: + Indicates which cc orientation is active now, or 0 when + nothing is connected. + USB Type-C partner devices (eg. /sys/class/typec/port0-partner/) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 7d8805d9bf37..00edae63da8e 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1238,6 +1238,16 @@ static ssize_t usb_power_delivery_revision_show(struct device *dev, } static DEVICE_ATTR_RO(usb_power_delivery_revision); +static ssize_t cc_orientation_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct typec_port *p = to_typec_port(dev); + + return sprintf(buf, "%d\n", typec_get_orientation(p)); +} +static DEVICE_ATTR_RO(cc_orientation); + static struct attribute *typec_attrs[] = { _attr_data_role.attr, _attr_power_operation_mode.attr, @@ -1248,6 +1258,7 @@ static struct attribute *typec_attrs[] = { _attr_usb_typec_revision.attr, _attr_vconn_source.attr, _attr_port_type.attr, + _attr_cc_orientation.attr, NULL, }; ATTRIBUTE_GROUPS(typec); -- 2.23.0.700.g56cf767bdb-goog
Re: [PATCH 3/7] rcu: trace_rcu_utilization() paired
On Tue, Oct 15, 2019 at 10:28:45AM +, Lai Jiangshan wrote: > The notations include "Start" and "End", it is better > when there are paired. > > Signed-off-by: Lai Jiangshan > Signed-off-by: Lai Jiangshan > --- > kernel/rcu/tree.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index c351fc280945..7830d5a06e69 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -2484,8 +2484,8 @@ static void rcu_cpu_kthread(unsigned int cpu) > char work, *workp = this_cpu_ptr(_data.rcu_cpu_has_work); > int spincnt; > > + trace_rcu_utilization(TPS("Start CPU kthread@rcu_run")); > for (spincnt = 0; spincnt < 10; spincnt++) { > - trace_rcu_utilization(TPS("Start CPU kthread@rcu_run")); > local_bh_disable(); > *statusp = RCU_KTHREAD_RUNNING; > local_irq_disable(); This one is good -- great catch, by the way! > @@ -2501,6 +2501,7 @@ static void rcu_cpu_kthread(unsigned int cpu) > return; > } > } > + trace_rcu_utilization(TPS("End CPU kthread@rcu_run")); > *statusp = RCU_KTHREAD_YIELDING; > trace_rcu_utilization(TPS("Start CPU kthread@rcu_yield")); But here the addition of "rcu_run" is redundant with the pre-existing rcu_yield. So I folded the first hunk into the previous patch and dropped this one. As always, please let me know if I am missing something. Thanx, Paul > schedule_timeout_interruptible(2); > -- > 2.20.1 >
Re: [PATCH 13/14] cpufreq: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM
On 16-10-19, 04:56, Frederic Weisbecker wrote: > Now that we have a vtime safe kcpustat accessor for CPUTIME_SYSTEM, use > it to start fixing frozen kcpustat values on nohz_full CPUs. > > Reported-by: Yauheni Kaliuta > Signed-off-by: Frederic Weisbecker > Cc: Rafael J. Wysocki > Cc: Viresh Kumar > Cc: Yauheni Kaliuta > Cc: Thomas Gleixner > Cc: Rik van Riel > Cc: Peter Zijlstra > Cc: Wanpeng Li > Cc: Ingo Molnar > --- > drivers/cpufreq/cpufreq.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index c52d6fa32aac..a37ebfd7e0e8 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -120,7 +120,7 @@ static inline u64 get_cpu_idle_time_jiffy(unsigned int > cpu, u64 *wall) > cur_wall_time = jiffies64_to_nsecs(get_jiffies_64()); > > busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; > - busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; > + busy_time += kcpustat_field(_cpu(cpu), CPUTIME_SYSTEM, cpu); > busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; > busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; > busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; Acked-by: Viresh Kumar -- viresh
Re: [PATCH] ACPI: processor: Avoid NULL pointer dereferences at init time
On 15-10-19, 19:35, Rafael J. Wysocki wrote: > rom: Rafael J. Wysocki > > If there are neither processor objects nor processor device objects > in the ACPI tables, the per-CPU processors table will not be > initialized and attempting to dereference pointers from there will > cause the kernel to crash. This happens in acpi_processor_ppc_init() > and acpi_thermal_cpufreq_init() after commit d15ce412737a ("ACPI: > cpufreq: Switch to QoS requests instead of cpufreq notifier") > which didn't add the requisite NULL pointer checks in there. > > Add the NULL pointer checks to acpi_processor_ppc_init() and > acpi_thermal_cpufreq_init(), and to the corresponding "exit" > routines. > > While at it, drop redundant return instructions from > acpi_processor_ppc_init() and acpi_thermal_cpufreq_init(). > > Fixes: d15ce412737a ("ACPI: cpufreq: Switch to QoS requests instead of > cpufreq notifier") > Reported-by: Srinivas Pandruvada > Signed-off-by: Rafael J. Wysocki > --- > drivers/acpi/processor_perflib.c | 10 ++ > drivers/acpi/processor_thermal.c | 10 ++ > 2 files changed, 12 insertions(+), 8 deletions(-) Acked-by: Viresh Kumar -- viresh
Re: [PATCH 2/7] rcu: fix tracepoint string when RCU CPU kthread runs
On Tue, Oct 15, 2019 at 10:23:57AM +, Lai Jiangshan wrote: > "rcu_wait" is incorrct here, use "rcu_run" instead. > > Signed-off-by: Lai Jiangshan > Signed-off-by: Lai Jiangshan > --- > kernel/rcu/tree.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 278798e58698..c351fc280945 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -2485,7 +2485,7 @@ static void rcu_cpu_kthread(unsigned int cpu) > int spincnt; > > for (spincnt = 0; spincnt < 10; spincnt++) { > - trace_rcu_utilization(TPS("Start CPU kthread@rcu_wait")); > + trace_rcu_utilization(TPS("Start CPU kthread@rcu_run")); > local_bh_disable(); > *statusp = RCU_KTHREAD_RUNNING; > local_irq_disable(); > @@ -2496,7 +2496,7 @@ static void rcu_cpu_kthread(unsigned int cpu) > rcu_core(); > local_bh_enable(); > if (*workp == 0) { > - trace_rcu_utilization(TPS("End CPU kthread@rcu_wait")); > + trace_rcu_utilization(TPS("End CPU kthread@rcu_run")); This one needs to stay as it was because this is where we wait when out of work. So I took the first hunk and dropped this second hunk. Please let me know if I am missing something. Thanx, Paul > *statusp = RCU_KTHREAD_WAITING; > return; > } > -- > 2.20.1 >
[RFC][PATCH v3 00/11] HiKey960 USB support
I'm just trying to pick up a patch series submitted previously by Yu Chen to get HiKey960 dev-board's USB functionality working. The current full patchset can be found here: https://git.linaro.org/people/john.stultz/android-dev.git/log/?id=305b332b46901c82d762e44d2ef8c96107a0c94e Previously I sent this series out as two separate series, to try to make the review a little easier. However, the partial series was causing some confusion as well, so this time I've sent almost all of it in one go. NOTE: I unfortunately don't have any deep knowledge of the hardware other then the previously submitted code and what I can intuit from testing, but I tried to document the previously undocumented bindings as best I could, fixed up a few minor checkpatch issues and tried to address previous feedback as best I could. I'd greatly appreciate feedback or thoughts! thanks -john New in v3: * Avoiding adding a hisi specific dwc3 binding and instead trying to make the dwc core binding more flexible as suggsted by Rob Herring. * Made the GCTL soft reset unconditional as suggested by Jack Pham. * Given the negative feedback on the usb class role-switch notifier method for the hub logic to hook into, I've reworked the hub logic to be an usb-role-switch intermediary. * Lots of minor fixups and cleanups, some reported by the kbuild test robot Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org John Stultz (6): dt-bindings: usb: rt1711h: Add connector bindings dt-bindings: usb: dwc3: Allow clock list & resets to be more flexible usb: dwc3: Rework clock initialization to be more flexible usb: dwc3: Rework resets initialization to be more flexible dt-bindings: usb: generic: Add role-switch-default-host binding usb: dwc3: Add host-mode as default support Yu Chen (5): usb: dwc3: Execute GCTL Core Soft Reset while switch modes usb: dwc3: Increase timeout for CmdAct cleared by device controller usb: dwc3: Registering a role switch in the DRD code. dt-bindings: misc: Add bindings for HiSilicon usb hub and data role switch functionality on HiKey960 misc: hisi_hikey_usb: Driver to support usb functionality of Hikey960 .../bindings/misc/hisilicon-hikey-usb.txt | 40 .../devicetree/bindings/usb/dwc3.txt | 5 +- .../devicetree/bindings/usb/generic.txt | 5 + .../bindings/usb/richtek,rt1711h.txt | 29 +++ drivers/misc/Kconfig | 6 + drivers/misc/Makefile | 1 + drivers/misc/hisi_hikey_usb.c | 178 ++ drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/core.c | 38 ++-- drivers/usb/dwc3/core.h | 6 + drivers/usb/dwc3/drd.c| 78 +++- drivers/usb/dwc3/gadget.c | 2 +- 12 files changed, 369 insertions(+), 20 deletions(-) create mode 100644 Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt create mode 100644 drivers/misc/hisi_hikey_usb.c -- 2.17.1
Re: [PATCH 1/7] rcu: fix incorrect conditional compilation
On Tue, Oct 15, 2019 at 10:23:56AM +, Lai Jiangshan wrote: > DO NOT pick it to stable tree. > (Since the title has "fix", this statement may help stop > AI pick it to stable tree) > > The tokens SRCU and TINY_RCU are not defined by any configurations, > they should be CONFIG_SRCU and CONFIG_TINY_RCU. But there is no > harm when "TINY_RCU" is wrongly used, which are always non-defined, > which makes "!defined(TINY_RCU)" always true, which means > the code block is always inclued, and the included code block > doesn't cause any compilation error so far when CONFIG_TINY_RCU. > It is also the reason this change doesn't need for stable. > > Signed-off-by: Lai Jiangshan > Signed-off-by: Lai Jiangshan Applied for review and testing, thank you! Thanx, Paul > --- > kernel/rcu/rcu.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h > index a7ab2a023dd3..05f936ed167a 100644 > --- a/kernel/rcu/rcu.h > +++ b/kernel/rcu/rcu.h > @@ -254,7 +254,7 @@ void rcu_test_sync_prims(void); > */ > extern void resched_cpu(int cpu); > > -#if defined(SRCU) || !defined(TINY_RCU) > +#if defined(CONFIG_SRCU) || !defined(CONFIG_TINY_RCU) > > #include > > @@ -391,7 +391,7 @@ do { > \ > #define raw_lockdep_assert_held_rcu_node(p) \ > lockdep_assert_held(_PRIVATE(p, lock)) > > -#endif /* #if defined(SRCU) || !defined(TINY_RCU) */ > +#endif /* #if defined(CONFIG_SRCU) || !defined(CONFIG_TINY_RCU) */ > > #ifdef CONFIG_SRCU > void srcu_init(void); > -- > 2.20.1 >
[RFC][PATCH v3 03/11] usb: dwc3: Increase timeout for CmdAct cleared by device controller
From: Yu Chen It needs more time for the device controller to clear the CmdAct of DEPCMD on Hisilicon Kirin Soc. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 86dc1db788a9..168eb4a0a9b0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -270,7 +270,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, { const struct usb_endpoint_descriptor *desc = dep->endpoint.desc; struct dwc3 *dwc = dep->dwc; - u32 timeout = 1000; + u32 timeout = 5000; u32 saved_config = 0; u32 reg; -- 2.17.1
[RFC][PATCH v3 05/11] usb: dwc3: Rework clock initialization to be more flexible
The dwc3 core binding specifies three clocks: ref, bus_early, and suspend which are all controlled in the driver together. However some variants of the hardware my not have all three clks So this patch reworks the reading of the clks from the dts to use devm_clk_bulk_get_all() will will fetch all the clocks specified in the dts together. This patch was reccomended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware when the only unique bits were clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz --- v3: Rework dwc3 core rather then adding another dwc-of-simple binding. --- drivers/usb/dwc3/core.c | 20 +--- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a039e35ec7ad..4d4f1836b62c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -305,12 +305,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) return 0; } -static const struct clk_bulk_data dwc3_core_clks[] = { - { .id = "ref" }, - { .id = "bus_early" }, - { .id = "suspend" }, -}; - /* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure @@ -1418,11 +1412,6 @@ static int dwc3_probe(struct platform_device *pdev) if (!dwc) return -ENOMEM; - dwc->clks = devm_kmemdup(dev, dwc3_core_clks, sizeof(dwc3_core_clks), -GFP_KERNEL); - if (!dwc->clks) - return -ENOMEM; - dwc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1458,17 +1447,18 @@ static int dwc3_probe(struct platform_device *pdev) return PTR_ERR(dwc->reset); if (dev->of_node) { - dwc->num_clks = ARRAY_SIZE(dwc3_core_clks); - - ret = devm_clk_bulk_get(dev, dwc->num_clks, dwc->clks); + ret = devm_clk_bulk_get_all(dev, >clks); if (ret == -EPROBE_DEFER) return ret; /* * Clocks are optional, but new DT platforms should support all * clocks as required by the DT-binding. */ - if (ret) + if (ret < 0) dwc->num_clks = 0; + else + dwc->num_clks = ret; + } ret = reset_control_deassert(dwc->reset); -- 2.17.1
[RFC][PATCH v3 08/11] dt-bindings: usb: generic: Add role-switch-default-host binding
Add binding to configure the default role the controller assumes is host mode when the usb role is USB_ROLE_NONE. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Signed-off-by: John Stultz --- Documentation/devicetree/bindings/usb/generic.txt | 5 + 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index cf5a1ad456e6..013782fde293 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -34,6 +34,11 @@ Optional properties: the USB data role (USB host or USB device) for a given USB connector, such as Type-C, Type-B(micro). see connector/usb-connector.txt. + - role-switch-default-host: boolean, indicating if usb-role-switch is enabled + the device default operation mode of controller while + usb role is USB_ROLE_NONE is host mode. If this is not + set or false, it will be assumed the default is device + mode. This is an attribute to a USB controller such as: -- 2.17.1
[RFC][PATCH v3 06/11] usb: dwc3: Rework resets initialization to be more flexible
The dwc3 core binding specifies one reset. However some variants of the hardware my not have more. So this patch reworks the reading of the resets to fetch all the resets specified in the dts together. This patch was reccomended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware when the only unique bits were clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz --- v3: Rework dwc3 core rather then adding another dwc-of-simple binding. --- drivers/usb/dwc3/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4d4f1836b62c..ef52ffa5d6cb 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1442,7 +1442,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_get_properties(dwc); - dwc->reset = devm_reset_control_get_optional_shared(dev, NULL); + dwc->reset = devm_reset_control_array_get(dev, true, true); if (IS_ERR(dwc->reset)) return PTR_ERR(dwc->reset); -- 2.17.1
[PATCH v4 4/7] iommu/mediatek: Delete the leaf in the tlb_flush
In our tlb range flush, we don't care the "leaf". Remove it to simplify the code. no functional change. "granule" also is unnecessary for us, Keep it satisfy the format of tlb_flush_walk. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/mtk_iommu.c | 21 - 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 81ac95f..1d7254c 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -174,8 +174,7 @@ static void mtk_iommu_tlb_flush_all(void *cookie) } static void mtk_iommu_tlb_add_flush_nosync(unsigned long iova, size_t size, - size_t granule, bool leaf, - void *cookie) + size_t granule, void *cookie) { struct mtk_iommu_data *data = cookie; @@ -223,19 +222,7 @@ static void mtk_iommu_tlb_flush_walk(unsigned long iova, size_t size, unsigned long flags; spin_lock_irqsave(>tlb_lock, flags); - mtk_iommu_tlb_add_flush_nosync(iova, size, granule, false, cookie); - mtk_iommu_tlb_sync(cookie); - spin_unlock_irqrestore(>tlb_lock, flags); -} - -static void mtk_iommu_tlb_flush_leaf(unsigned long iova, size_t size, -size_t granule, void *cookie) -{ - struct mtk_iommu_data *data = cookie; - unsigned long flags; - - spin_lock_irqsave(>tlb_lock, flags); - mtk_iommu_tlb_add_flush_nosync(iova, size, granule, true, cookie); + mtk_iommu_tlb_add_flush_nosync(iova, size, granule, cookie); mtk_iommu_tlb_sync(cookie); spin_unlock_irqrestore(>tlb_lock, flags); } @@ -253,7 +240,7 @@ static void mtk_iommu_tlb_flush_page_nosync(struct iommu_iotlb_gather *gather, static const struct iommu_flush_ops mtk_iommu_flush_ops = { .tlb_flush_all = mtk_iommu_tlb_flush_all, .tlb_flush_walk = mtk_iommu_tlb_flush_walk, - .tlb_flush_leaf = mtk_iommu_tlb_flush_leaf, + .tlb_flush_leaf = mtk_iommu_tlb_flush_walk, .tlb_add_page = mtk_iommu_tlb_flush_page_nosync, }; @@ -475,7 +462,7 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, spin_lock_irqsave(>tlb_lock, flags); mtk_iommu_tlb_add_flush_nosync(gather->start, length, gather->pgsize, - false, data); + data); mtk_iommu_tlb_sync(data); spin_unlock_irqrestore(>tlb_lock, flags); } -- 1.9.1
[RFC][PATCH v3 11/11] misc: hisi_hikey_usb: Driver to support usb functionality of Hikey960
From: Yu Chen The HiKey960 has a fairly complex USB configuration due to it needing to support a USB-C port for host/device mode and multiple USB-A ports in host mode using a single USB controller. See schematics here: https://github.com/96boards/documentation/raw/master/consumer/hikey/hikey960/hardware-docs/HiKey960_Schematics.pdf This driver acts as a usb-role-switch intermediary, intercepting the role switch notifications from the tcpm code, and passing them on to the dwc3 core. In doing so, it also controls the onboard hub and power gpios in order to properly route the data lines between the USB-C port and the onboard hub to the USB-A ports. NOTE: It was noted that controlling the TYPEC_VBUS_POWER_OFF and TYPEC_VBUS_POWER_ON values here is not reccomended. I'm looking for a way to remove that bit from the logic here, but wanted to still get feedback on this approach. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Signed-off-by: Yu Chen [jstultz: Major rework to make the driver a usb-role-switch intermediary] Signed-off-by: John Stultz --- v3: * Major rework to make the driver a usb-role-switch intermediary rather then trying to do notifier callbacks from the role switch logic --- drivers/misc/Kconfig | 6 ++ drivers/misc/Makefile | 1 + drivers/misc/hisi_hikey_usb.c | 178 ++ 3 files changed, 185 insertions(+) create mode 100644 drivers/misc/hisi_hikey_usb.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index c55b63750757..bf42d1e234ea 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -466,6 +466,12 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config HISI_HIKEY_USB + tristate "USB functionality of HiSilicon Hikey Platform" + depends on OF && GPIOLIB + help + If you say yes here you get support for usb functionality of HiSilicon Hikey Platform. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index c1860d35dc7e..e5e85ad0dd57 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -57,3 +57,4 @@ obj-y += cardreader/ obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_HABANA_AI)+= habanalabs/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o +obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o diff --git a/drivers/misc/hisi_hikey_usb.c b/drivers/misc/hisi_hikey_usb.c new file mode 100644 index ..32015bc9ccf6 --- /dev/null +++ b/drivers/misc/hisi_hikey_usb.c @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Support for usb functionality of Hikey series boards + * based on Hisilicon Kirin Soc. + * + * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd. + * http://www.huawei.com + * + * Authors: Yu Chen + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEVICE_DRIVER_NAME "hisi_hikey_usb" + +#define HUB_VBUS_POWER_ON 1 +#define HUB_VBUS_POWER_OFF 0 +#define USB_SWITCH_TO_HUB 1 +#define USB_SWITCH_TO_TYPEC 0 +#define TYPEC_VBUS_POWER_ON 1 +#define TYPEC_VBUS_POWER_OFF 0 + +struct hisi_hikey_usb { + struct gpio_desc *otg_switch; + struct gpio_desc *typec_vbus; + struct gpio_desc *hub_vbus; + + struct usb_role_switch *hub_role_sw; + struct usb_role_switch *dev_role_sw; + struct notifier_block nb; +}; + +static void hub_power_ctrl(struct hisi_hikey_usb *hisi_hikey_usb, int value) +{ + gpiod_set_value_cansleep(hisi_hikey_usb->hub_vbus, value); +} + +static void usb_switch_ctrl(struct hisi_hikey_usb *hisi_hikey_usb, + int switch_to) +{ + gpiod_set_value_cansleep(hisi_hikey_usb->otg_switch, switch_to); +} + +static void usb_typec_power_ctrl(struct hisi_hikey_usb *hisi_hikey_usb, +int value) +{ + gpiod_set_value_cansleep(hisi_hikey_usb->typec_vbus, value); +} + +static int hub_usb_role_switch_set(struct device *dev, enum usb_role role) +{ + struct hisi_hikey_usb *hisi_hikey_usb = dev_get_drvdata(dev); + + if (!hisi_hikey_usb || !hisi_hikey_usb->dev_role_sw) + return -EINVAL; + + switch (role) { + case USB_ROLE_NONE: + usb_typec_power_ctrl(hisi_hikey_usb, TYPEC_VBUS_POWER_OFF); + usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_HUB); + hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_ON); + break; + case USB_ROLE_HOST: +
[RFC][PATCH v3 02/11] usb: dwc3: Execute GCTL Core Soft Reset while switch modes
From: Yu Chen On the HiKey960, we need to do a GCTL soft reset when switching modes. Jack Pham also noted that in the Synopsys databook it mentions performing a GCTL CoreSoftReset when changing the PrtCapDir between device & host modes. So this patch always does a GCTL Core Soft Reset when changing the mode. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- v3: Remove quirk conditional, as Jack Pham noted the Synopsis databook states this should be done generally. Also, at Jacks' suggestion, make the reset call before changing the prtcap direction. --- drivers/usb/dwc3/core.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 999ce5e84d3c..a039e35ec7ad 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -112,6 +112,19 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) dwc->current_dr_role = mode; } +static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc) +{ + u32 reg; + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg |= DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg &= ~DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); +} + static void __dwc3_set_mode(struct work_struct *work) { struct dwc3 *dwc = work_to_dwc(work); @@ -154,6 +167,9 @@ static void __dwc3_set_mode(struct work_struct *work) spin_lock_irqsave(>lock, flags); + /* Execute a GCTL Core Soft Reset when switch mode */ + dwc3_gctl_core_soft_reset(dwc); + dwc3_set_prtcap(dwc, dwc->desired_dr_role); spin_unlock_irqrestore(>lock, flags); -- 2.17.1
[RFC][PATCH v3 01/11] dt-bindings: usb: rt1711h: Add connector bindings
Add connector binding documentation for Richtek RT1711H Type-C chip driver It was noted by Rob Herring that the rt1711h binding docs doesn't include the connector binding. Thus this patch adds such documentation following the details in Documentation/devicetree/bindings/usb/typec-tcpci.txt Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: John Stultz --- .../bindings/usb/richtek,rt1711h.txt | 29 +++ 1 file changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt b/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt index d4cf53c071d9..e3fc57e605ed 100644 --- a/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt +++ b/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt @@ -6,10 +6,39 @@ Required properties: - interrupts : where a is the interrupt number and b represents an encoding of the sense and level information for the interrupt. +Required sub-node: +- connector: The "usb-c-connector" attached to the tcpci chip, the bindings + of connector node are specified in + Documentation/devicetree/bindings/connector/usb-connector.txt + Example : rt1711h@4e { compatible = "richtek,rt1711h"; reg = <0x4e>; interrupt-parent = <>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + + usb_con: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + sink-pdos = ; + op-sink-microwatt = <1000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + usb_con_ss: endpoint { + remote-endpoint = <_data_ss>; + }; + }; + }; + }; }; -- 2.17.1
[PATCH v4 6/7] iommu/mediatek: Get rid of the pgtlock
Now we have tlb_lock for the HW tlb flush, then pgtable code hasn't needed the external "pgtlock" for a while. this patch remove the "pgtlock". Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 25 +++-- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0e5f41f..c2b7ed5 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -101,8 +101,6 @@ #define MTK_M4U_TO_PORT(id)((id) & 0x1f) struct mtk_iommu_domain { - spinlock_t pgtlock; /* lock for page table */ - struct io_pgtable_cfg cfg; struct io_pgtable_ops *iop; @@ -295,8 +293,6 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) { struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); - spin_lock_init(>pgtlock); - dom->cfg = (struct io_pgtable_cfg) { .quirks = IO_PGTABLE_QUIRK_ARM_NS | IO_PGTABLE_QUIRK_NO_PERMS | @@ -395,18 +391,13 @@ static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova, { struct mtk_iommu_domain *dom = to_mtk_domain(domain); struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); - unsigned long flags; - int ret; /* The "4GB mode" M4U physically can not use the lower remap of Dram. */ if (data->enable_4GB) paddr |= BIT_ULL(32); - spin_lock_irqsave(>pgtlock, flags); - ret = dom->iop->map(dom->iop, iova, paddr, size, prot); - spin_unlock_irqrestore(>pgtlock, flags); - - return ret; + /* Synchronize with the tlb_lock */ + return dom->iop->map(dom->iop, iova, paddr, size, prot); } static size_t mtk_iommu_unmap(struct iommu_domain *domain, @@ -414,14 +405,8 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) { struct mtk_iommu_domain *dom = to_mtk_domain(domain); - unsigned long flags; - size_t unmapsz; - - spin_lock_irqsave(>pgtlock, flags); - unmapsz = dom->iop->unmap(dom->iop, iova, size, gather); - spin_unlock_irqrestore(>pgtlock, flags); - return unmapsz; + return dom->iop->unmap(dom->iop, iova, size, gather); } static void mtk_iommu_flush_iotlb_all(struct iommu_domain *domain) @@ -447,13 +432,9 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain, { struct mtk_iommu_domain *dom = to_mtk_domain(domain); struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); - unsigned long flags; phys_addr_t pa; - spin_lock_irqsave(>pgtlock, flags); pa = dom->iop->iova_to_phys(dom->iop, iova); - spin_unlock_irqrestore(>pgtlock, flags); - if (data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) pa &= ~BIT_ULL(32); -- 1.9.1
[RFC][PATCH v3 10/11] dt-bindings: misc: Add bindings for HiSilicon usb hub and data role switch functionality on HiKey960
From: Yu Chen This patch adds binding documentation to support usb hub and usb data role switch of Hisilicon HiKey960 Board. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- v3: Reworked as usb-role-switch intermediary --- .../bindings/misc/hisilicon-hikey-usb.txt | 40 +++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt diff --git a/Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt b/Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt new file mode 100644 index ..1e131b38230d --- /dev/null +++ b/Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.txt @@ -0,0 +1,40 @@ +Support usb hub and usb data role switch of Hisilicon HiKey960 Board. + +- + +Required properties: +- compatible: "hisilicon,gpio_hubv1" +- typec-vbus-gpios: gpio to control the vbus of typeC port +- otg-switch-gpios: gpio to switch DP & DM between the hub and typeC port +- hub-vdd33-en-gpios: gpio to enable the power of hub +- pinctrl-names: pin configuration state name ("default") +- pinctrl-0: pinctrl config +- usb-role-switch: flags the driver as a role switch provider +- ports: two endpoints to connect the usb core role switch provider +to the usb-c tcpm driver. + +Example +- + hisi_hikey_usb: hisi_hikey_usb { + compatible = "hisilicon,gpio_hubv1"; + typec-vbus-gpios = < 2 GPIO_ACTIVE_HIGH>; + otg-switch-gpios = < 6 GPIO_ACTIVE_HIGH>; + hub-vdd33-en-gpios = < 6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <_pmx_func>; + usb-role-switch; + + port { + #address-cells = <1>; + #size-cells = <0>; + + hikey_usb_ep0: endpoint@0 { + reg = <0>; + remote-endpoint = <_role_switch>; + }; + hikey_usb_ep1: endpoint@1 { + reg = <1>; + remote-endpoint = <_ep>; + }; + }; + }; -- 2.17.1
[PATCH v4 2/7] iommu/mediatek: Add a new tlb_lock for tlb_flush
The commit 4d689b619445 ("iommu/io-pgtable-arm-v7s: Convert to IOMMU API TLB sync") help move the tlb_sync of unmap from v7s into the iommu framework. It helps add a new function "mtk_iommu_iotlb_sync", But it lacked the lock, then it will cause the variable "tlb_flush_active" may be changed unexpectedly, we could see this warning log randomly: mtk-iommu 10205000.iommu: Partial TLB flush timed out, falling back to full flush The HW requires tlb_flush/tlb_sync in pairs strictly, this patch adds a new tlb_lock for tlb operations to fix this issue. Fixes: 4d689b619445 ("iommu/io-pgtable-arm-v7s: Convert to IOMMU API TLB sync") Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 23 ++- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 76b9388..c2f6c78 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -219,22 +219,37 @@ static void mtk_iommu_tlb_sync(void *cookie) static void mtk_iommu_tlb_flush_walk(unsigned long iova, size_t size, size_t granule, void *cookie) { + struct mtk_iommu_data *data = cookie; + unsigned long flags; + + spin_lock_irqsave(>tlb_lock, flags); mtk_iommu_tlb_add_flush_nosync(iova, size, granule, false, cookie); mtk_iommu_tlb_sync(cookie); + spin_unlock_irqrestore(>tlb_lock, flags); } static void mtk_iommu_tlb_flush_leaf(unsigned long iova, size_t size, size_t granule, void *cookie) { + struct mtk_iommu_data *data = cookie; + unsigned long flags; + + spin_lock_irqsave(>tlb_lock, flags); mtk_iommu_tlb_add_flush_nosync(iova, size, granule, true, cookie); mtk_iommu_tlb_sync(cookie); + spin_unlock_irqrestore(>tlb_lock, flags); } static void mtk_iommu_tlb_flush_page_nosync(struct iommu_iotlb_gather *gather, unsigned long iova, size_t granule, void *cookie) { + struct mtk_iommu_data *data = cookie; + unsigned long flags; + + spin_lock_irqsave(>tlb_lock, flags); mtk_iommu_tlb_add_flush_nosync(iova, granule, granule, true, cookie); + spin_unlock_irqrestore(>tlb_lock, flags); } static const struct iommu_flush_ops mtk_iommu_flush_ops = { @@ -453,7 +468,12 @@ static void mtk_iommu_flush_iotlb_all(struct iommu_domain *domain) static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) { - mtk_iommu_tlb_sync(mtk_iommu_get_m4u_data()); + struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); + unsigned long flags; + + spin_lock_irqsave(>tlb_lock, flags); + mtk_iommu_tlb_sync(data); + spin_unlock_irqrestore(>tlb_lock, flags); } static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain, @@ -733,6 +753,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) if (ret) return ret; + spin_lock_init(>tlb_lock); list_add_tail(>list, ); if (!iommu_present(_bus_type)) diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index fc0f16e..8cae22d 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -58,6 +58,7 @@ struct mtk_iommu_data { struct iommu_group *m4u_group; boolenable_4GB; booltlb_flush_active; + spinlock_t tlb_lock; /* lock for tlb range flush */ struct iommu_device iommu; const struct mtk_iommu_plat_data *plat_data; -- 1.9.1
[RFC][PATCH v3 09/11] usb: dwc3: Add host-mode as default support
Support configuring the default role the controller assumes as host mode when the usb role is USB_ROLE_NONE This patch was split out from a larger patch originally by Yu Chen Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Signed-off-by: John Stultz --- v3: Split this patch out from addition of usb-role-switch handling --- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/drd.c | 20 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 6f19e9891767..3c879c9ab1aa 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -953,6 +953,8 @@ struct dwc3_scratchpad_array { * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW * @role_sw: usb_role_switch handle + * @role_switch_default_mode: default operation mode of controller while + * usb role is USB_ROLE_NONE. * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY @@ -1087,6 +1089,7 @@ struct dwc3 { struct notifier_block edev_nb; enum usb_phy_interface hsphy_mode; struct usb_role_switch *role_sw; + enum usb_dr_moderole_switch_default_mode; u32 fladj; u32 irq_gadget; diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 61d4fd8aead4..0e3466fe5ac4 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -489,7 +489,10 @@ static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role) mode = DWC3_GCTL_PRTCAP_DEVICE; break; default: - mode = DWC3_GCTL_PRTCAP_DEVICE; + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) + mode = DWC3_GCTL_PRTCAP_HOST; + else + mode = DWC3_GCTL_PRTCAP_DEVICE; break; } @@ -515,7 +518,10 @@ static enum usb_role dwc3_usb_role_switch_get(struct device *dev) role = dwc->current_otg_role; break; default: - role = USB_ROLE_DEVICE; + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) + role = USB_ROLE_HOST; + else + role = USB_ROLE_DEVICE; break; } spin_unlock_irqrestore(>lock, flags); @@ -534,8 +540,14 @@ int dwc3_drd_init(struct dwc3 *dwc) struct usb_role_switch_desc dwc3_role_switch = {NULL}; u32 mode; - mode = DWC3_GCTL_PRTCAP_DEVICE; - + if (device_property_read_bool(dwc->dev, + "role-switch-default-host")) { + dwc->role_switch_default_mode = USB_DR_MODE_HOST; + mode = DWC3_GCTL_PRTCAP_HOST; + } else { + dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL; + mode = DWC3_GCTL_PRTCAP_DEVICE; + } dwc3_role_switch.fwnode = dev_fwnode(dwc->dev); dwc3_role_switch.set = dwc3_usb_role_switch_set; dwc3_role_switch.get = dwc3_usb_role_switch_get; -- 2.17.1
[PATCH v4 5/7] iommu/mediatek: Move the tlb_sync into tlb_flush
Right now, the tlb_add_flush_nosync and tlb_sync always appear together. we merge the two functions into one(also move the tlb_lock into the new function). No functional change. Signed-off-by: Chao Hao Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 45 ++--- drivers/iommu/mtk_iommu.h | 1 - 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 1d7254c..0e5f41f 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -173,12 +173,16 @@ static void mtk_iommu_tlb_flush_all(void *cookie) } } -static void mtk_iommu_tlb_add_flush_nosync(unsigned long iova, size_t size, +static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size, size_t granule, void *cookie) { struct mtk_iommu_data *data = cookie; + unsigned long flags; + int ret; + u32 tmp; for_each_m4u(data) { + spin_lock_irqsave(>tlb_lock, flags); writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0, data->base + REG_MMU_INV_SEL); @@ -187,21 +191,8 @@ static void mtk_iommu_tlb_add_flush_nosync(unsigned long iova, size_t size, data->base + REG_MMU_INVLD_END_A); writel_relaxed(F_MMU_INV_RANGE, data->base + REG_MMU_INVALIDATE); - data->tlb_flush_active = true; - } -} - -static void mtk_iommu_tlb_sync(void *cookie) -{ - struct mtk_iommu_data *data = cookie; - int ret; - u32 tmp; - - for_each_m4u(data) { - /* Avoid timing out if there's nothing to wait for */ - if (!data->tlb_flush_active) - return; + /* tlb sync */ ret = readl_poll_timeout_atomic(data->base + REG_MMU_CPE_DONE, tmp, tmp != 0, 10, 10); if (ret) { @@ -211,22 +202,10 @@ static void mtk_iommu_tlb_sync(void *cookie) } /* Clear the CPE status */ writel_relaxed(0, data->base + REG_MMU_CPE_DONE); - data->tlb_flush_active = false; + spin_unlock_irqrestore(>tlb_lock, flags); } } -static void mtk_iommu_tlb_flush_walk(unsigned long iova, size_t size, -size_t granule, void *cookie) -{ - struct mtk_iommu_data *data = cookie; - unsigned long flags; - - spin_lock_irqsave(>tlb_lock, flags); - mtk_iommu_tlb_add_flush_nosync(iova, size, granule, cookie); - mtk_iommu_tlb_sync(cookie); - spin_unlock_irqrestore(>tlb_lock, flags); -} - static void mtk_iommu_tlb_flush_page_nosync(struct iommu_iotlb_gather *gather, unsigned long iova, size_t granule, void *cookie) @@ -239,8 +218,8 @@ static void mtk_iommu_tlb_flush_page_nosync(struct iommu_iotlb_gather *gather, static const struct iommu_flush_ops mtk_iommu_flush_ops = { .tlb_flush_all = mtk_iommu_tlb_flush_all, - .tlb_flush_walk = mtk_iommu_tlb_flush_walk, - .tlb_flush_leaf = mtk_iommu_tlb_flush_walk, + .tlb_flush_walk = mtk_iommu_tlb_flush_range_sync, + .tlb_flush_leaf = mtk_iommu_tlb_flush_range_sync, .tlb_add_page = mtk_iommu_tlb_flush_page_nosync, }; @@ -455,16 +434,12 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, { struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); size_t length = gather->end - gather->start; - unsigned long flags; if (gather->start == ULONG_MAX) return; - spin_lock_irqsave(>tlb_lock, flags); - mtk_iommu_tlb_add_flush_nosync(gather->start, length, gather->pgsize, + mtk_iommu_tlb_flush_range_sync(gather->start, length, gather->pgsize, data); - mtk_iommu_tlb_sync(data); - spin_unlock_irqrestore(>tlb_lock, flags); } static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain, diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index 8cae22d..ea949a3 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -57,7 +57,6 @@ struct mtk_iommu_data { struct mtk_iommu_domain *m4u_dom; struct iommu_group *m4u_group; boolenable_4GB; - booltlb_flush_active; spinlock_t tlb_lock; /* lock for tlb range flush */ struct iommu_device iommu; -- 1.9.1
[PATCH v4 3/7] iommu/mediatek: Use gather to achieve the tlb range flush
Use the iommu_gather mechanism to achieve the tlb range flush. Gather the iova range in the "tlb_add_page", then flush the merged iova range in iotlb_sync. Suggested-by: Tomasz Figa Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index c2f6c78..81ac95f 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -245,11 +245,9 @@ static void mtk_iommu_tlb_flush_page_nosync(struct iommu_iotlb_gather *gather, void *cookie) { struct mtk_iommu_data *data = cookie; - unsigned long flags; + struct iommu_domain *domain = >m4u_dom->domain; - spin_lock_irqsave(>tlb_lock, flags); - mtk_iommu_tlb_add_flush_nosync(iova, granule, granule, true, cookie); - spin_unlock_irqrestore(>tlb_lock, flags); + iommu_iotlb_gather_add_page(domain, gather, iova, granule); } static const struct iommu_flush_ops mtk_iommu_flush_ops = { @@ -469,9 +467,15 @@ static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) { struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); + size_t length = gather->end - gather->start; unsigned long flags; + if (gather->start == ULONG_MAX) + return; + spin_lock_irqsave(>tlb_lock, flags); + mtk_iommu_tlb_add_flush_nosync(gather->start, length, gather->pgsize, + false, data); mtk_iommu_tlb_sync(data); spin_unlock_irqrestore(>tlb_lock, flags); } -- 1.9.1
Re: [PATCH net-next v2] net: bcmgenet: Generate a random MAC if none is valid
From: Florian Fainelli Date: Mon, 14 Oct 2019 14:20:00 -0700 > Instead of having a hard failure and stopping the driver's probe > routine, generate a random Ethernet MAC address to keep going. > > Signed-off-by: Florian Fainelli Applied to net-next, thank you.
[RFC][PATCH v3 04/11] dt-bindings: usb: dwc3: Allow clock list & resets to be more flexible
Rather then adding another device specific binding to support hikey960, Rob Herring suggested we expand the current dwc3 binding to allow for variable numbers of clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz --- Documentation/devicetree/bindings/usb/dwc3.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 66780a47ad85..29768b0ca923 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -7,7 +7,8 @@ Required properties: - compatible: must be "snps,dwc3" - reg : Address and length of the register set for the device - interrupts: Interrupts used by the dwc3 controller. - - clock-names: should contain "ref", "bus_early", "suspend" + - clock-names: list of clock names. Ideally should be "ref", +"bus_early", "suspend" but may be less or more. - clocks: list of phandle and clock specifier pairs corresponding to entries in the clock-names property. @@ -36,7 +37,7 @@ Optional properties: - phys: from the *Generic PHY* bindings - phy-names: from the *Generic PHY* bindings; supported names are "usb2-phy" or "usb3-phy". - - resets: a single pair of phandle and reset specifier + - resets: set of phandle and reset specifier pairs - snps,usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable - snps,dis-start-transfer-quirk: when set, disable isoc START TRANSFER command -- 2.17.1
[RFC][PATCH v3 07/11] usb: dwc3: Registering a role switch in the DRD code.
From: Yu Chen The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-...@vger.kernel.org Cc: devicet...@vger.kernel.org Suggested-by: Heikki Krogerus Signed-off-by: Yu Chen Signed-off-by: John Stultz --- v2: Fix role_sw and role_switch_default_mode descriptions as reported by kbuild test robot v3: Split out the role-switch-default-host logic into its own patch --- drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/core.h | 3 ++ drivers/usb/dwc3/drd.c | 66 +++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 89abc6078703..1104745c41a9 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -44,6 +44,7 @@ config USB_DWC3_DUAL_ROLE bool "Dual Role mode" depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3)) depends on (EXTCON=y || EXTCON=USB_DWC3) + select USB_ROLE_SWITCH help This is the default mode of working of DWC3 controller where both host and gadget features are enabled. diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 1c8b349379af..6f19e9891767 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -951,6 +952,7 @@ struct dwc3_scratchpad_array { * @hsphy_mode: UTMI phy mode, one of following: * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW + * @role_sw: usb_role_switch handle * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY @@ -1084,6 +1086,7 @@ struct dwc3 { struct extcon_dev *edev; struct notifier_block edev_nb; enum usb_phy_interface hsphy_mode; + struct usb_role_switch *role_sw; u32 fladj; u32 irq_gadget; diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index c946d64142ad..61d4fd8aead4 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -476,6 +476,52 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) return edev; } +static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role) +{ + struct dwc3 *dwc = dev_get_drvdata(dev); + u32 mode; + + switch (role) { + case USB_ROLE_HOST: + mode = DWC3_GCTL_PRTCAP_HOST; + break; + case USB_ROLE_DEVICE: + mode = DWC3_GCTL_PRTCAP_DEVICE; + break; + default: + mode = DWC3_GCTL_PRTCAP_DEVICE; + break; + } + + dwc3_set_mode(dwc, mode); + return 0; +} + +static enum usb_role dwc3_usb_role_switch_get(struct device *dev) +{ + struct dwc3 *dwc = dev_get_drvdata(dev); + unsigned long flags; + enum usb_role role; + + spin_lock_irqsave(>lock, flags); + switch (dwc->current_dr_role) { + case DWC3_GCTL_PRTCAP_HOST: + role = USB_ROLE_HOST; + break; + case DWC3_GCTL_PRTCAP_DEVICE: + role = USB_ROLE_DEVICE; + break; + case DWC3_GCTL_PRTCAP_OTG: + role = dwc->current_otg_role; + break; + default: + role = USB_ROLE_DEVICE; + break; + } + spin_unlock_irqrestore(>lock, flags); + return role; +} + int dwc3_drd_init(struct dwc3 *dwc) { int ret, irq; @@ -484,7 +530,22 @@ int dwc3_drd_init(struct dwc3 *dwc) if (IS_ERR(dwc->edev)) return PTR_ERR(dwc->edev); - if (dwc->edev) { + if (device_property_read_bool(dwc->dev, "usb-role-switch")) { + struct usb_role_switch_desc dwc3_role_switch = {NULL}; + u32 mode; + + mode = DWC3_GCTL_PRTCAP_DEVICE; + + dwc3_role_switch.fwnode = dev_fwnode(dwc->dev); + dwc3_role_switch.set = dwc3_usb_role_switch_set; + dwc3_role_switch.get = dwc3_usb_role_switch_get; + dwc->role_sw = usb_role_switch_register(dwc->dev, + _role_switch); + if (IS_ERR(dwc->role_sw)) + return PTR_ERR(dwc->role_sw); + + dwc3_set_mode(dwc, mode); + } else if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev,
Re: [PATCH v2] rtc: ds1685: add indirect access method and remove plat_read/plat_write
On 10/14/2019 17:46, Thomas Bogendoerfer wrote: > SGI Octane (IP30) doesn't have RTC register directly mapped into CPU > address space, but accesses RTC registers with an address and data > register. This is now supported by additional access functions, which > are selected by a new field in platform data. Removed plat_read/plat_write > since there is no user and their usage could introduce lifetime issue, > when functions are placed in different modules. > > Signed-off-by: Thomas Bogendoerfer > --- > Changes in v2: > > - check if rtc->read and rtc->write are setup > - spell out indirect in function names and explain difference > between standard and indirect functions > > arch/mips/sgi-ip32/ip32-platform.c | 2 +- > drivers/rtc/rtc-ds1685.c | 78 > +- > include/linux/rtc/ds1685.h | 8 ++-- > 3 files changed, 58 insertions(+), 30 deletions(-) > > diff --git a/arch/mips/sgi-ip32/ip32-platform.c > b/arch/mips/sgi-ip32/ip32-platform.c > index 5a2a82148d8d..c3909bd8dd1a 100644 > --- a/arch/mips/sgi-ip32/ip32-platform.c > +++ b/arch/mips/sgi-ip32/ip32-platform.c > @@ -115,7 +115,7 @@ ip32_rtc_platform_data[] = { > .bcd_mode = true, > .no_irq = false, > .uie_unsupported = false, > - .alloc_io_resources = true, > + .access_type = ds1685_reg_direct, > .plat_prepare_poweroff = ip32_prepare_poweroff, > }, > }; > diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c > index 349a8d1caca1..98d06b3ee913 100644 > --- a/drivers/rtc/rtc-ds1685.c > +++ b/drivers/rtc/rtc-ds1685.c > @@ -31,7 +31,10 @@ > > > /* --- */ > -/* Standard read/write functions if platform does not provide overrides */ > +/* > + * Standard read/write > + * all registers are mapped in CPU address space > + */ > > /** > * ds1685_read - read a value from an rtc register. > @@ -59,6 +62,35 @@ ds1685_write(struct ds1685_priv *rtc, int reg, u8 value) > } > /* --- */ > > +/* > + * Indirect read/write functions > + * access happens via address and data register mapped in CPU address space > + */ > + > +/** > + * ds1685_indirect_read - read a value from an rtc register. > + * @rtc: pointer to the ds1685 rtc structure. > + * @reg: the register address to read. > + */ > +static u8 > +ds1685_indirect_read(struct ds1685_priv *rtc, int reg) > +{ > + writeb(reg, rtc->regs); > + return readb(rtc->data); > +} > + > +/** > + * ds1685_indirect_write - write a value to an rtc register. > + * @rtc: pointer to the ds1685 rtc structure. > + * @reg: the register address to write. > + * @value: value to write to the register. > + */ > +static void > +ds1685_indirect_write(struct ds1685_priv *rtc, int reg, u8 value) > +{ > + writeb(reg, rtc->regs); > + writeb(value, rtc->data); > +} > > /* --- */ > /* Inlined functions */ > @@ -1062,42 +1094,36 @@ ds1685_rtc_probe(struct platform_device *pdev) > if (!rtc) > return -ENOMEM; > > - /* > - * Allocate/setup any IORESOURCE_MEM resources, if required. Not all > - * platforms put the RTC in an easy-access place. Like the SGI Octane, > - * which attaches the RTC to a "ByteBus", hooked to a SuperIO chip > - * that sits behind the IOC3 PCI metadevice. > - */ > - if (pdata->alloc_io_resources) { > + /* Setup resources and access functions */ > + switch (pdata->access_type) { > + case ds1685_reg_direct: > + rtc->regs = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(rtc->regs)) > + return PTR_ERR(rtc->regs); > + rtc->read = ds1685_read; > + rtc->write = ds1685_write; > + break; > + case ds1685_reg_indirect: > rtc->regs = devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(rtc->regs)) > return PTR_ERR(rtc->regs); > + rtc->data = devm_platform_ioremap_resource(pdev, 1); > + if (IS_ERR(rtc->data)) > + return PTR_ERR(rtc->data); > + rtc->read = ds1685_indirect_read; > + rtc->write = ds1685_indirect_write; > + break; > } > > + if (!rtc->read || !rtc->write) > + return -ENXIO; > + > /* Get the register step size. */ > if (pdata->regstep > 0) > rtc->regstep = pdata->regstep; > else > rtc->regstep = 1; > > - /* Platform read function, else default if mmio setup */ > - if (pdata->plat_read) > - rtc->read = pdata->plat_read; > - else > - if (pdata->alloc_io_resources) > - rtc->read = ds1685_read; > - else > -
Re: [PATCH v2 0/3] bpf: switch to new usercopy helpers
On Tue, Oct 15, 2019 at 07:14:42PM -0700, Alexei Starovoitov wrote: > On Tue, Oct 15, 2019 at 5:41 PM Christian Brauner > wrote: > > > > Hey everyone, > > > > In v5.4-rc2 we added two new helpers check_zeroed_user() and > > copy_struct_from_user() including selftests (cf. [1]). It is a generic > > interface designed to copy a struct from userspace. The helpers will be > > especially useful for structs versioned by size of which we have quite a > > few. > > Was it tested? > Either your conversion is incorrect or that generic helper is broken. > ./test_progs -n 2 > and > ./test_btf > are catching the bug: > BTF prog info raw test[8] (line_info (No subprog. zero tailing > line_info): do_test_info_raw:6205:FAIL prog_fd:-1 > expected_prog_load_failure:0 errno:7 > nonzero tailing record in line_infoprocessed 0 insns (limit 100) > max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 Ugh, I misrememberd what the helper I helped design returns. The fix is: diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 5db9887a8f4c..0920593eacd0 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -78,11 +78,8 @@ int bpf_check_uarg_tail_zero(void __user *uaddr, return 0; err = check_zeroed_user(uaddr + expected_size, rest); - if (err < 0) - return err; - - if (err) - return -E2BIG; + if (err <= 0) + return err ?: -E2BIG; return 0; } aka check_zeroed_user() returns 0 if non-zero bytes are present, 1 if no non-zero bytes were present, and -errno on error. I'll send a fixed version. The tests pass for me with this. Christian
RE: [EXT] Re: [v2,2/2] i2c: mux: pca954x: add property idle-state
> > On 2019-10-15 06:48, Biwen Li wrote: > > This adds property idle-state > > > > Signed-off-by: Biwen Li > > --- > > Change in v2: > > - update subject and description > > - add property idle-state > > > > drivers/i2c/muxes/i2c-mux-pca954x.c | 47 > > ++--- > > 1 file changed, 30 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c > > b/drivers/i2c/muxes/i2c-mux-pca954x.c > > index 923aa3a5a3dc..8ec586342b92 100644 > > --- a/drivers/i2c/muxes/i2c-mux-pca954x.c > > +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c > > @@ -86,7 +86,7 @@ struct pca954x { > > > > u8 last_chan; /* last register value */ > > /* MUX_IDLE_AS_IS, MUX_IDLE_DISCONNECT or >= 0 for channel */ > > - s8 idle_state; > > + s32 idle_state; > > > > struct i2c_client *client; > > > > @@ -256,7 +256,7 @@ static int pca954x_deselect_mux(struct > > i2c_mux_core *muxc, u32 chan) { > > struct pca954x *data = i2c_mux_priv(muxc); > > struct i2c_client *client = data->client; > > - s8 idle_state; > > + s32 idle_state; > > > > idle_state = READ_ONCE(data->idle_state); > > if (idle_state >= 0) > > @@ -402,6 +402,25 @@ static void pca954x_cleanup(struct > i2c_mux_core *muxc) > > i2c_mux_del_adapters(muxc); > > } > > > > +static int pca954x_init(struct i2c_client *client, struct pca954x > > +*data) { > > + /* > > + * Write the mux register at addr to verify > > + * that the mux is in fact present. This also > > + * initializes the mux to disconnected state. > > + */ > > This comment belongs in pca954x_probe, before the call to this function. > However, the comment may now be be wrong since the mux is not always > initialized to the disconnected state. Got it, I will update it in v3. > > > + if (data->idle_state >= 0) { > > + /* Always enable multiplexer */ > > While I understand that it is important for your case that the mux is always > enabled, this is just a side effect of having a specific idle-state. I > suggest that > you remove this comment. Got it, I will remove it in v3. > > > + if (data->chip->muxtype == pca954x_ismux) > > + data->last_chan = data->idle_state | > data->chip->enable; > > + else > > + data->last_chan = 1 << data->idle_state; > > The meat of this "if" is still duplicated, I was suggesting a helper that > only did > the regval calculation so that the new helper could also be used from > pca954x_select_chan.o > > > + } else { > > + /* Disconnect multiplexer */ > > + data->last_chan = 0; /* force the first selection */ > > These two comments should be combined. Got it. > > > + } > > + return i2c_smbus_write_byte(client, data->last_chan); } > > /* > > * I2C init/probing/exit functions > > */ > > @@ -411,7 +430,6 @@ static int pca954x_probe(struct i2c_client *client, > > struct i2c_adapter *adap = client->adapter; > > struct device *dev = >dev; > > struct device_node *np = dev->of_node; > > - bool idle_disconnect_dt; > > struct gpio_desc *gpio; > > struct i2c_mux_core *muxc; > > struct pca954x *data; > > @@ -462,22 +480,18 @@ static int pca954x_probe(struct i2c_client > *client, > > } > > } > > > > - /* Write the mux register at addr to verify > > - * that the mux is in fact present. This also > > - * initializes the mux to disconnected state. > > - */ > > - if (i2c_smbus_write_byte(client, 0) < 0) { > > + if (of_property_read_u32(np, "idle-state", >idle_state)) > > + data->idle_state = MUX_IDLE_AS_IS; > > + > > + if (of_property_read_bool(np, "i2c-mux-idle-disconnect")) > > + data->idle_state = MUX_IDLE_DISCONNECT; > > I think you should ignore i2c-mux-idle-disconnect if idle-state is present. > I.e. move this "if" statement into the body of the former "if". Also, you have > broken things if np is NULL. Got it, I will modify it in v3. > > Cheers, > Peter > > > + > > + ret = pca954x_init(client, data); > > + if (ret < 0) { > > dev_warn(dev, "probe failed\n"); > > return -ENODEV; > > } > > > > - data->last_chan = 0; /* force the first selection */ > > - data->idle_state = MUX_IDLE_AS_IS; > > - > > - idle_disconnect_dt = np && > > - of_property_read_bool(np, "i2c-mux-idle-disconnect"); > > - if (idle_disconnect_dt) > > - data->idle_state = MUX_IDLE_DISCONNECT; > > > > ret = pca954x_irq_setup(muxc); > > if (ret) > > @@ -531,8 +545,7 @@ static int pca954x_resume(struct device *dev) > > struct i2c_mux_core *muxc = i2c_get_clientdata(client); > > struct pca954x *data = i2c_mux_priv(muxc); > > > > - data->last_chan = 0; > > - return i2c_smbus_write_byte(client, 0); > > + return pca954x_init(client,
RE: [EXT] Re: [v2,1/2] dt-bindings: i2c: add property idle-state
> > On 2019-10-15 06:48, Biwen Li wrote: > > This adds property idle-state > > > > Signed-off-by: Biwen Li > > --- > > Change in v2: > > - update subject and description > > - add property idle-state > > > > Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt > > b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt > > index 30ac6a60f041..2c7875d338fb 100644 > > --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt > > +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt > > @@ -34,6 +34,7 @@ Optional Properties: > > - first cell is the pin number > > - second cell is used to specify flags. > > See also > > Documentation/devicetree/bindings/interrupt-controller/interrupts.txt > > + - idle-state: Please refer to > > + Documentation/devicetree/bindings/mux/mux-controller.txt > > > > Example: > > > > > > As per my comments on the code, you should mention that idle-state, if > present, overrides i2c-mux-idle-disconnect. I also think you should keep > idle-state and i2c-mux-idle-disconnect right next to each other. Got it, I will adjust it in v3. > > Cheers, > Peter
Re: [PATCH V2] arm64: psci: Reduce waiting time of cpu_psci_cpu_kill()
On 2019/10/16 0:23, Will Deacon wrote: > Hi, > > On Sat, Sep 21, 2019 at 07:21:17PM +0800, Yunfeng Ye wrote: >> If psci_ops.affinity_info() fails, it will sleep 10ms, which will not >> take so long in the right case. Use usleep_range() instead of msleep(), >> reduce the waiting time, and give a chance to busy wait before sleep. > > Can you elaborate on "the right case" please? It's not clear to me > exactly what problem you're solving here. > The situation is that when the power is off, we have a battery to save some information, but the battery power is limited, so we reduce the power consumption by turning off the cores, and need fastly to complete the core shutdown. However, the time of cpu_psci_cpu_kill() will take 10ms. We have tested the time that it does not need 10ms, and most case is about 50us-500us. if we reduce the time of cpu_psci_cpu_kill(), we can reduce 10% - 30% of the total time. So change msleep (10) to usleep_range() to reduce the waiting time. In addition, we don't want to be scheduled during the sleeping time, some threads may take a long time and don't give up the CPU, which affects the time of core shutdown, Therefore, we add a chance to busy-wait max 1ms. thanks. > I've also added Sudeep to the thread, since I'd like his ack on the change. > > Will > >> arch/arm64/kernel/psci.c | 17 + >> 1 file changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c >> index c9f72b2..99b3122 100644 >> --- a/arch/arm64/kernel/psci.c >> +++ b/arch/arm64/kernel/psci.c >> @@ -82,6 +82,7 @@ static void cpu_psci_cpu_die(unsigned int cpu) >> static int cpu_psci_cpu_kill(unsigned int cpu) >> { >> int err, i; >> +unsigned long timeout; >> >> if (!psci_ops.affinity_info) >> return 0; >> @@ -91,16 +92,24 @@ static int cpu_psci_cpu_kill(unsigned int cpu) >> * while it is dying. So, try again a few times. >> */ >> >> -for (i = 0; i < 10; i++) { >> +i = 0; >> +timeout = jiffies + msecs_to_jiffies(100); >> +do { >> err = psci_ops.affinity_info(cpu_logical_map(cpu), 0); >> if (err == PSCI_0_2_AFFINITY_LEVEL_OFF) { >> pr_info("CPU%d killed.\n", cpu); >> return 0; >> } >> >> -msleep(10); >> -pr_info("Retrying again to check for CPU kill\n"); >> -} >> +/* busy-wait max 1ms */ >> +if (i++ < 100) { >> +cond_resched(); >> +udelay(10); >> +continue; >> +} >> + >> +usleep_range(100, 1000); >> +} while (time_before(jiffies, timeout)); >> >> pr_warn("CPU%d may not have shut down cleanly (AFFINITY_INFO reports >> %d)\n", >> cpu, err); >> -- >> 2.7.4.huawei.3 >> > > . >
RE: [PATCH v3] clk: imx7ulp: do not export out IMX7ULP_CLK_MIPI_PLL clock
Hi Anson, Please see my below comments. Best regards, Fancy Fang -Original Message- From: Anson Huang Sent: Tuesday, October 15, 2019 11:28 AM To: Fancy Fang ; sb...@kernel.org; shawn...@kernel.org Cc: linux-...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-kernel@vger.kernel.org; mturque...@baylibre.com; s.ha...@pengutronix.de; ker...@pengutronix.de; dl-linux-imx Subject: RE: [PATCH v3] clk: imx7ulp: do not export out IMX7ULP_CLK_MIPI_PLL clock Hi, Fancy > Subject: [PATCH v3] clk: imx7ulp: do not export out > IMX7ULP_CLK_MIPI_PLL clock > > The mipi pll clock comes from the MIPI PHY PLL output, so it should > not be a fixed clock. > > MIPI PHY PLL is in the MIPI DSI space, and it is used as the bit clock > for transferring the pixel data out and its output clock is configured > according to the display mode. > > So it should be used only for MIPI DSI and not be exported out for > other usages. > > Signed-off-by: Fancy Fang > --- > ChangeLog v2->v3: > * Keep 'IMX7ULP_CLK_MIPI_PLL' macro definition. > > ChangeLog v1->v2: > * Keep other clock indexes unchanged as Shawn suggested. > > Documentation/devicetree/bindings/clock/imx7ulp-clock.txt | 1 - > drivers/clk/imx/clk-imx7ulp.c | 3 +-- > 2 files changed, 1 insertion(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt > b/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt > index a4f8cd478f92..93d89adb7afe 100644 > --- a/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt > +++ b/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt > @@ -82,7 +82,6 @@ pcc2: pcc2@403f { >< IMX7ULP_CLK_APLL_PFD0>, >< IMX7ULP_CLK_UPLL>, >< IMX7ULP_CLK_SOSC_BUS_CLK>, > - < IMX7ULP_CLK_MIPI_PLL>, >< IMX7ULP_CLK_FIRC_BUS_CLK>, >< IMX7ULP_CLK_ROSC>, >< IMX7ULP_CLK_SPLL_BUS_CLK>; > diff --git a/drivers/clk/imx/clk-imx7ulp.c > b/drivers/clk/imx/clk-imx7ulp.c index 2022d9bead91..459b120b71d5 > 100644 > --- a/drivers/clk/imx/clk-imx7ulp.c > +++ b/drivers/clk/imx/clk-imx7ulp.c > @@ -28,7 +28,7 @@ static const char * const scs_sels[]= > { "dummy", "sosc", "sirc", "firc", "dumm > static const char * const ddr_sels[] = { "apll_pfd_sel", "upll", }; > static const char * const nic_sels[] = { "firc", "ddr_clk", }; > static const char * const periph_plat_sels[] = { "dummy", "nic1_bus_clk", > "nic1_clk", "ddr_clk", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", }; > -static const char * const periph_bus_sels[] = { "dummy", "sosc_bus_clk", > "mpll", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", > "spll_bus_clk", }; > +static const char * const periph_bus_sels[] = { "dummy", "sosc_bus_clk", > "dummy", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", > "spll_bus_clk", }; The reference manual does have mpll as clock option, so do you mean it will NOT be supported anymore, is mpll used inside MIPI PHY? [FF] Yes. The mpll comes from the MIPI PHY PLL which is an internal PLL clock in MIPI space. And besides, this clock frequency can be changed or disabled dynamically when you change display mode or disable display. So it should not be used as other peripherals's root clock. This is why I want to hide this mpll from other peripherals to make things easier to be handled. Anson > static const char * const arm_sels[] = { "divcore", "dummy", > "dummy", "hsrun_divcore", }; > > /* used by sosc/sirc/firc/ddr/spll/apll dividers */ @@ -75,7 +75,6 @@ > static void __init imx7ulp_clk_scg1_init(struct device_node *np) > clks[IMX7ULP_CLK_SOSC] = > imx_obtain_fixed_clk_hw(np, "sosc"); > clks[IMX7ULP_CLK_SIRC] = > imx_obtain_fixed_clk_hw(np, "sirc"); > clks[IMX7ULP_CLK_FIRC] = > imx_obtain_fixed_clk_hw(np, "firc"); > - clks[IMX7ULP_CLK_MIPI_PLL] = imx_obtain_fixed_clk_hw(np, > "mpll"); > clks[IMX7ULP_CLK_UPLL] = > imx_obtain_fixed_clk_hw(np, "upll"); > > /* SCG1 */ > -- > 2.17.1
Re: [PATCH v2 0/3] net: phy: switch to using fwnode_gpiod_get_index
From: Dmitry Torokhov Date: Mon, 14 Oct 2019 10:40:19 -0700 > This series switches phy drivers form using fwnode_get_named_gpiod() and > gpiod_get_from_of_node() that are scheduled to be removed in favor > of fwnode_gpiod_get_index() that behaves more like standard > gpiod_get_index() and will potentially handle secondary software > nodes in cases we need to augment platform firmware. > > Linus, as David would prefer not to pull in the immutable branch but > rather route the patches through the tree that has the new API, could > you please take them with his ACKs? Indeed, please do, also for series: Acked-by: David S. Miller
Re: [PATCH v2] net: dsa: sja1105: Use the correct style for SPDX License Identifier
From: Nishad Kamdar Date: Mon, 14 Oct 2019 21:51:20 +0530 > This patch corrects the SPDX License Identifier style > in header files related to Distributed Switch Architecture > drivers for NXP SJA1105 series Ethernet switch support. > It uses an expilict block comment for the SPDX License > Identifier. > > Changes made by using a script provided by Joe Perches here: > https://lkml.org/lkml/2019/2/7/46. > > Suggested-by: Joe Perches > Signed-off-by: Nishad Kamdar > --- > Changes in v2: > - Modify the commit message to reflect the changes done. > - Correct some indentation errors. Applied, thanks.
[PATCH -next v2] arm64: mm: Fix unused variable warning in zone_sizes_init
When building arm64 allnoconfig, CONFIG_ZONE_DMA and CONFIG_ZONE_DMA32 get disabled so there is a warning about max_dma being unused. ../arch/arm64/mm/init.c:215:16: warning: unused variable 'max_dma' [-Wunused-variable] unsigned long max_dma = min; ^ 1 warning generated. Add an ifdef around the variable to fix this. Fixes: 1a8e1cef7603 ("arm64: use both ZONE_DMA and ZONE_DMA32") Signed-off-by: Nathan Chancellor --- v1 -> v2: * Fix check for CONFIG_ZONE_DMA32 as pointed out by Will. arch/arm64/mm/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 44f07fdf7a59..359c3b08b968 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -212,7 +212,9 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) struct memblock_region *reg; unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; unsigned long max_dma32 = min; +#if defined(CONFIG_ZONE_DMA) || defined(CONFIG_ZONE_DMA32) unsigned long max_dma = min; +#endif memset(zone_size, 0, sizeof(zone_size)); -- 2.23.0
Re: About patch NFS: Fix O_DIRECT accounting of number of bytes read/written
On Wed, 2019-10-16 at 01:00 +, Su, Yanjun wrote: > Hi trond, > Because My mail system cant receive nfs mail list’s mails, I reply > your patch here. > I have some question for the patch. > > > No. Basic O_DIRECT does not guarantee atomicity of requests, which > > is > > why we do not have generic locking at the VFS level when reading > > and > > writing. The only guarantee being offered is that O_DIRECT and > > buffered > > writes do not collide. > Do you mean other fs also cant guarantee atomicity of O_DIRECT > request or just nfs? > > > IOW: I think the basic premise for this test is just broken (as I > > commented in the patch series I sent) because it is assuming a > > behaviour that is simply not guaranteed. > So the generic/465 of xfstests can’t apply to nfs for now, am I > right? As far as I can see, it is does not belong in the 'generic' category at all. > > > BTW: note that buffered writes have the same property. They are > > ordered > > when being written into the page cache, meaning that reads on the > > same > > client will see no holes, however if you try to read from another > > client, then you will see the same behaviour, with temporary holes > > magically appearing in the file. > As you say, nfs buffered write also has the hole problem with > multiple r/w on different clients. > I want to know if the problem exists in other local fs such as > xfs,ext4? > There is no VFS locking that enforces any serialisation for O_DIRECT. So unless the filesystem implements its own serialisation (which xfs does) then there is no guarantee. -- Trond Myklebust Linux NFS client maintainer, Hammerspace trond.mykleb...@hammerspace.com
Re: [PATCH -next] arm64: mm: Fix unused variable warning in zone_sizes_init
On Wed, Oct 16, 2019 at 04:00:52AM +0100, Will Deacon wrote: > On Tue, Oct 15, 2019 at 03:43:04PM -0700, Nathan Chancellor wrote: > > When building arm64 allnoconfig, CONFIG_ZONE_DMA and CONFIG_ZONE_DMA32 > > get disabled so there is a warning about max_dma being unused. > > > > ../arch/arm64/mm/init.c:215:16: warning: unused variable 'max_dma' > > [-Wunused-variable] > > unsigned long max_dma = min; > > ^ > > 1 warning generated. > > > > Add an ifdef around the variable to fix this. > > > > Fixes: 1a8e1cef7603 ("arm64: use both ZONE_DMA and ZONE_DMA32") > > Signed-off-by: Nathan Chancellor > > --- > > arch/arm64/mm/init.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > index 44f07fdf7a59..c3d6657b9942 100644 > > --- a/arch/arm64/mm/init.c > > +++ b/arch/arm64/mm/init.c > > @@ -212,7 +212,9 @@ static void __init zone_sizes_init(unsigned long min, > > unsigned long max) > > struct memblock_region *reg; > > unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; > > unsigned long max_dma32 = min; > > +#if defined(CONFIG_ZONE_DMA) || defined(CONFIG_ZONE_DMA) > > unsigned long max_dma = min; > > +#endif > > This looks bogus to me :/ You're referring to CONFIG_ZONE_DMA twice, and I > can't see how that symbol even exists on arm64. > > Will Gah, sorry, one of those CONFIGs should be CONFIG_ZONE_DMA32. I will send a v2 to fix that shortly. Note, this patch is targetting for-next/zone-dma, which reintroduces CONFIG_ZONE_DMA. Sorry if the patch tag and Fixes tag didn't make that clear, let me know how I can better convey that in the future! Cheers, Nathan
[PATCH net-next] r8152: support request_firmware for RTL8153
This patch supports loading additional firmware file through request_firmware(). A firmware file may include a header followed by several blocks which have different types of firmware. Currently, the supported types are RTL_FW_END, RTL_FW_PLA, and RTL_FW_USB. The firmware is used to fix some compatible or hardware issues. For example, the device couldn't be found after rebooting several times. The supported chips are RTL_VER_04 (rtl8153a-2.fw) RTL_VER_05 (rtl8153a-3.fw) RTL_VER_06 (rtl8153a-4.fw) RTL_VER_09 (rtl8153b-2.fw) Signed-off-by: Hayes Wang Reviewed-by: Prashant Malani --- drivers/net/usb/r8152.c | 768 +++- 1 file changed, 756 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 54a83f734ede..55d0bcb00aef 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -24,9 +24,11 @@ #include #include #include +#include +#include /* Information for net-next */ -#define NETNEXT_VERSION"10" +#define NETNEXT_VERSION"11" /* Information for net */ #define NET_VERSION"10" @@ -54,8 +56,11 @@ #define PLA_BDC_CR 0xd1a0 #define PLA_TEREDO_TIMER 0xd2cc #define PLA_REALWOW_TIMER 0xd2e8 +#define PLA_UPHY_TIMER 0xd388 #define PLA_SUSPEND_FLAG 0xd38a #define PLA_INDICATE_FALG 0xd38c +#define PLA_MACDBG_PRE 0xd38c /* RTL_VER_04 only */ +#define PLA_MACDBG_POST0xd38e /* RTL_VER_04 only */ #define PLA_EXTRA_STATUS 0xd398 #define PLA_EFUSE_DATA 0xdd00 #define PLA_EFUSE_CMD 0xdd02 @@ -110,7 +115,12 @@ #define USB_CONNECT_TIMER 0xcbf8 #define USB_MSC_TIMER 0xcbfc #define USB_BURST_SIZE 0xcfc0 +#define USB_FW_FIX_EN0 0xcfca +#define USB_FW_FIX_EN1 0xcfcc #define USB_LPM_CONFIG 0xcfd8 +#define USB_CSTMR 0xcfef /* RTL8153A */ +#define USB_FW_CTRL0xd334 /* RTL8153B */ +#define USB_FC_TIMER 0xd340 #define USB_USB_CTRL 0xd406 #define USB_PHY_CTRL 0xd408 #define USB_TX_AGG 0xd40a @@ -126,6 +136,7 @@ #define USB_LPM_CTRL 0xd41a #define USB_BMU_RESET 0xd4b0 #define USB_U1U2_TIMER 0xd4da +#define USB_FW_TASK0xd4e8 /* RTL8153B */ #define USB_UPS_CTRL 0xd800 #define USB_POWER_CUT 0xd80a #define USB_MISC_0 0xd81a @@ -133,18 +144,19 @@ #define USB_AFE_CTRL2 0xd824 #define USB_UPS_CFG0xd842 #define USB_UPS_FLAGS 0xd848 +#define USB_WDT1_CTRL 0xe404 #define USB_WDT11_CTRL 0xe43c -#define USB_BP_BA 0xfc26 -#define USB_BP_0 0xfc28 -#define USB_BP_1 0xfc2a -#define USB_BP_2 0xfc2c -#define USB_BP_3 0xfc2e -#define USB_BP_4 0xfc30 -#define USB_BP_5 0xfc32 -#define USB_BP_6 0xfc34 -#define USB_BP_7 0xfc36 -#define USB_BP_EN 0xfc38 -#define USB_BP_8 0xfc38 +#define USB_BP_BA PLA_BP_BA +#define USB_BP_0 PLA_BP_0 +#define USB_BP_1 PLA_BP_1 +#define USB_BP_2 PLA_BP_2 +#define USB_BP_3 PLA_BP_3 +#define USB_BP_4 PLA_BP_4 +#define USB_BP_5 PLA_BP_5 +#define USB_BP_6 PLA_BP_6 +#define USB_BP_7 PLA_BP_7 +#define USB_BP_EN PLA_BP_EN /* RTL8153A */ +#define USB_BP_8 0xfc38 /* RTL8153B */ #define USB_BP_9 0xfc3a #define USB_BP_10 0xfc3c #define USB_BP_11 0xfc3e @@ -346,7 +358,12 @@ /* PLA_INDICATE_FALG */ #define UPCOMING_RUNTIME_D3BIT(0) +/* PLA_MACDBG_PRE and PLA_MACDBG_POST */ +#define DEBUG_OE BIT(0) +#define DEBUG_LTSSM0x0082 + /* PLA_EXTRA_STATUS */ +#define U3P3_CHECK_EN BIT(7) /* RTL_VER_05 only */ #define LINK_CHANGE_FLAG BIT(8) /* USB_USB2PHY */ @@ -368,6 +385,12 @@ #define STAT_SPEED_HIGH0x #define STAT_SPEED_FULL0x0002 +/* USB_FW_FIX_EN0 */ +#define FW_FIX_SUSPEND BIT(14) + +/* USB_FW_FIX_EN1 */ +#define FW_IP_RESET_EN BIT(9) + /* USB_LPM_CONFIG */ #define LPM_U1U2_ENBIT(0) @@ -392,12 +415,24 @@ #define OWN_UPDATE BIT(0) #define OWN_CLEAR BIT(1) +/* USB_FW_TASK */ +#define FC_PATCH_TASK BIT(1) + /* USB_UPS_CTRL */ #define POWER_CUT 0x0100 /* USB_PM_CTRL_STATUS */ #define RESUME_INDICATE0x0001 +/* USB_CSTMR */ +#define FORCE_SUPERBIT(0) + +/* USB_FW_CTRL */ +#define FLOW_CTRL_PATCH_OPTBIT(1) + +/* USB_FC_TIMER */ +#define CTRL_TIMER_EN BIT(15) + /* USB_USB_CTRL */ #define RX_AGG_DISABLE 0x0010 #define RX_ZERO_EN
Re: [PATCH -next] arm64: mm: Fix unused variable warning in zone_sizes_init
On Tue, Oct 15, 2019 at 03:43:04PM -0700, Nathan Chancellor wrote: > When building arm64 allnoconfig, CONFIG_ZONE_DMA and CONFIG_ZONE_DMA32 > get disabled so there is a warning about max_dma being unused. > > ../arch/arm64/mm/init.c:215:16: warning: unused variable 'max_dma' > [-Wunused-variable] > unsigned long max_dma = min; > ^ > 1 warning generated. > > Add an ifdef around the variable to fix this. > > Fixes: 1a8e1cef7603 ("arm64: use both ZONE_DMA and ZONE_DMA32") > Signed-off-by: Nathan Chancellor > --- > arch/arm64/mm/init.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 44f07fdf7a59..c3d6657b9942 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -212,7 +212,9 @@ static void __init zone_sizes_init(unsigned long min, > unsigned long max) > struct memblock_region *reg; > unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; > unsigned long max_dma32 = min; > +#if defined(CONFIG_ZONE_DMA) || defined(CONFIG_ZONE_DMA) > unsigned long max_dma = min; > +#endif This looks bogus to me :/ You're referring to CONFIG_ZONE_DMA twice, and I can't see how that symbol even exists on arm64. Will
[PATCH 07/14] context_tracking: Introduce context_tracking_enabled_cpu()
This allows us to check if a remote CPU runs context tracking (ie: is nohz_full). We'll need that to reliably support "nice" accounting on kcpustat. Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- include/linux/context_tracking_state.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 08f125f6b31b..587717705727 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -31,6 +31,11 @@ static inline bool context_tracking_enabled(void) return static_branch_unlikely(_tracking_key); } +static inline bool context_tracking_enabled_cpu(int cpu) +{ + return per_cpu(context_tracking.active, cpu); +} + static inline bool context_tracking_enabled_this_cpu(void) { return __this_cpu_read(context_tracking.active); @@ -43,6 +48,7 @@ static inline bool context_tracking_in_user(void) #else static inline bool context_tracking_in_user(void) { return false; } static inline bool context_tracking_enabled(void) { return false; } +static inline bool context_tracking_enabled_cpu(int cpu) { return false; } static inline bool context_tracking_enabled_this_cpu(void) { return false; } #endif /* CONFIG_CONTEXT_TRACKING */ -- 2.23.0
[PATCH 04/14] context_tracking: Remove context_tracking_active()
This function is a leftover from old removal or rename. We can drop it. Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- include/linux/context_tracking_state.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index f128dc3be0df..f4633c2c29a5 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -42,7 +42,6 @@ static inline bool context_tracking_in_user(void) } #else static inline bool context_tracking_in_user(void) { return false; } -static inline bool context_tracking_active(void) { return false; } static inline bool context_tracking_is_enabled(void) { return false; } static inline bool context_tracking_cpu_is_enabled(void) { return false; } #endif /* CONFIG_CONTEXT_TRACKING */ -- 2.23.0
[PATCH 11/14] sched/kcpustat: Introduce vtime-aware kcpustat accessor for CPUTIME_SYSTEM
Kcpustat is not correctly supported on nohz_full CPUs. The tick doesn't fire and the cputime therefore doesn't move forward. The issue has shown up after the vanishing of the remaining 1Hz which has made the stall visible. We are solving that with checking the task running on a CPU through RCU and reading its vtime delta that we add to the raw kcpustat values. We make sure that we fetch a coherent raw-kcpustat/vtime-delta couple sequence while checking that the CPU referred by the target vtime is the correct one, under the locked vtime seqcount. Only CPUTIME_SYSTEM is handled here as a start because it's the trivial case. User and guest time will require more preparation work to correctly handle niceness. Reported-by: Yauheni Kaliuta Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- include/linux/kernel_stat.h | 11 + kernel/sched/cputime.c | 83 + 2 files changed, 94 insertions(+) diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index 7ee2bb43b251..79781196eb25 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h @@ -78,6 +78,17 @@ static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu) return kstat_cpu(cpu).irqs_sum; } +#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN +extern u64 kcpustat_field(struct kernel_cpustat *kcpustat, + enum cpu_usage_stat usage, int cpu); +#else +static inline u64 kcpustat_field(struct kernel_cpustat *kcpustat, +enum cpu_usage_stat usage, int cpu) +{ + return kcpustat->cpustat[usage]; +} +#endif + extern void account_user_time(struct task_struct *, u64); extern void account_guest_time(struct task_struct *, u64); extern void account_system_time(struct task_struct *, int, u64); diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index b931a19df093..bff5bf33d27e 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -911,4 +911,87 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime) *utime += vtime->utime + delta; } while (read_seqcount_retry(>seqcount, seq)); } + +static int kcpustat_field_vtime(u64 *cpustat, + struct vtime *vtime, + enum cpu_usage_stat usage, + int cpu, u64 *val) +{ + unsigned int seq; + int err; + + do { + seq = read_seqcount_begin(>seqcount); + + /* +* We raced against context switch, fetch the +* kcpustat task again. +*/ + if (vtime->cpu != cpu && vtime->cpu != -1) { + err = -EAGAIN; + continue; + } + + /* +* Two possible things here: +* 1) We are seeing the scheduling out task (prev) or any past one. +* 2) We are seeing the scheduling in task (next) but it hasn't +*passed though vtime_task_switch() yet so the pending +*cputime of the prev task may not be flushed yet. +* +* Case 1) is ok but 2) is not. So wait for a safe VTIME state. +*/ + if (vtime->state == VTIME_INACTIVE) { + err = -EAGAIN; + continue; + } + + err = 0; + + *val = cpustat[usage]; + + if (vtime->state == VTIME_SYS) + *val += vtime->stime + vtime_delta(vtime); + + } while (read_seqcount_retry(>seqcount, seq)); + + return err; +} + +u64 kcpustat_field(struct kernel_cpustat *kcpustat, + enum cpu_usage_stat usage, int cpu) +{ + u64 val; + int err; + u64 *cpustat = kcpustat->cpustat; + + if (!vtime_accounting_enabled_cpu(cpu)) + return cpustat[usage]; + + /* Only support sys vtime for now */ + if (usage != CPUTIME_SYSTEM) + return cpustat[usage]; + + rcu_read_lock(); + + do { + struct rq *rq = cpu_rq(cpu); + struct task_struct *curr; + struct vtime *vtime; + + curr = rcu_dereference(rq->curr); + if (WARN_ON_ONCE(!curr)) { + val = cpustat[usage]; + break; + } + + vtime = >vtime; + err = kcpustat_field_vtime(cpustat, vtime, usage, cpu, ); + } while (err == -EAGAIN); + + rcu_read_unlock(); + + return val; +} + #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */ -- 2.23.0
[PATCH 06/14] context_tracking: Rename context_tracking_is_cpu_enabled() to context_tracking_enabled_this_cpu()
Standardize the naming on top of the context_tracking_enabled_*() base. Also make it clear we are checking the context tracking state of the *current* CPU with this function. We'll need to add an API to check that state on remote CPUs as well, so we must disambiguate the naming. Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- include/linux/context_tracking.h | 2 +- include/linux/context_tracking_state.h | 4 ++-- include/linux/vtime.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index f1601bac08dc..c9065ad518a7 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h @@ -118,7 +118,7 @@ static inline void guest_enter_irqoff(void) * one time slice). Lets treat guest mode as quiescent state, just like * we do with user-mode execution. */ - if (!context_tracking_cpu_is_enabled()) + if (!context_tracking_enabled_this_cpu()) rcu_virt_note_context_switch(smp_processor_id()); } diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 91250bdf2060..08f125f6b31b 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -31,7 +31,7 @@ static inline bool context_tracking_enabled(void) return static_branch_unlikely(_tracking_key); } -static inline bool context_tracking_cpu_is_enabled(void) +static inline bool context_tracking_enabled_this_cpu(void) { return __this_cpu_read(context_tracking.active); } @@ -43,7 +43,7 @@ static inline bool context_tracking_in_user(void) #else static inline bool context_tracking_in_user(void) { return false; } static inline bool context_tracking_enabled(void) { return false; } -static inline bool context_tracking_cpu_is_enabled(void) { return false; } +static inline bool context_tracking_enabled_this_cpu(void) { return false; } #endif /* CONFIG_CONTEXT_TRACKING */ #endif diff --git a/include/linux/vtime.h b/include/linux/vtime.h index 0fc7f11f7aa4..54e91511250b 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h @@ -34,7 +34,7 @@ static inline bool vtime_accounting_enabled(void) static inline bool vtime_accounting_cpu_enabled(void) { if (vtime_accounting_enabled()) { - if (context_tracking_cpu_is_enabled()) + if (context_tracking_enabled_this_cpu()) return true; } -- 2.23.0
[PATCH 12/14] procfs: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM
Now that we have a vtime safe kcpustat accessor for CPUTIME_SYSTEM, use it to start fixing frozen kcpustat values on nohz_full CPUs. Reported-by: Yauheni Kaliuta Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- fs/proc/stat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 80c305f206bb..5c6bd0ae3802 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -124,7 +124,7 @@ static int show_stat(struct seq_file *p, void *v) user += kcs->cpustat[CPUTIME_USER]; nice += kcs->cpustat[CPUTIME_NICE]; - system += kcs->cpustat[CPUTIME_SYSTEM]; + system += kcpustat_field(kcs, CPUTIME_SYSTEM, i); idle += get_idle_time(kcs, i); iowait += get_iowait_time(kcs, i); irq += kcs->cpustat[CPUTIME_IRQ]; @@ -162,7 +162,7 @@ static int show_stat(struct seq_file *p, void *v) /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ user = kcs->cpustat[CPUTIME_USER]; nice = kcs->cpustat[CPUTIME_NICE]; - system = kcs->cpustat[CPUTIME_SYSTEM]; + system = kcpustat_field(kcs, CPUTIME_SYSTEM, i); idle = get_idle_time(kcs, i); iowait = get_iowait_time(kcs, i); irq = kcs->cpustat[CPUTIME_IRQ]; -- 2.23.0
[PATCH 09/14] sched/vtime: Introduce vtime_accounting_enabled_cpu()
This allows us to check if a remote CPU runs vtime accounting (ie: is nohz_full). We'll need that to reliably support reading kcpustat on nohz_full CPUs. Also simplify a bit the condition in the local flavoured function while at it. Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- include/linux/vtime.h | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/vtime.h b/include/linux/vtime.h index eb2e7a19054b..e2733bf33541 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h @@ -31,14 +31,14 @@ static inline bool vtime_accounting_enabled(void) return context_tracking_enabled(); } +static inline bool vtime_accounting_enabled_cpu(int cpu) +{ + return (vtime_accounting_enabled() && context_tracking_enabled_cpu(cpu)); +} + static inline bool vtime_accounting_enabled_this_cpu(void) { - if (vtime_accounting_enabled()) { - if (context_tracking_enabled_this_cpu()) - return true; - } - - return false; + return (vtime_accounting_enabled() && context_tracking_enabled_this_cpu()); } extern void vtime_task_switch_generic(struct task_struct *prev); @@ -51,6 +51,7 @@ static inline void vtime_task_switch(struct task_struct *prev) #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ +static inline bool vtime_accounting_enabled_cpu(int cpu) {return false; } static inline bool vtime_accounting_enabled_this_cpu(void) { return false; } static inline void vtime_task_switch(struct task_struct *prev) { } -- 2.23.0
[PATCH 08/14] sched/vtime: Rename vtime_accounting_cpu_enabled() to vtime_accounting_enabled_this_cpu()
Standardize the naming on top of the vtime_accounting_enabled_*() base. Also make it clear we are checking the vtime state of the *current* CPU with this function. We'll need to add an API to check that state on remote CPUs as well, so we must disambiguate the naming. Signed-off-by: Frederic Weisbecker Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- include/linux/context_tracking.h | 4 ++-- include/linux/vtime.h| 10 +- kernel/sched/cputime.c | 2 +- kernel/time/tick-sched.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index c9065ad518a7..64ec82851aa3 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h @@ -103,7 +103,7 @@ static inline void context_tracking_init(void) { } /* must be called with irqs disabled */ static inline void guest_enter_irqoff(void) { - if (vtime_accounting_cpu_enabled()) + if (vtime_accounting_enabled_this_cpu()) vtime_guest_enter(current); else current->flags |= PF_VCPU; @@ -127,7 +127,7 @@ static inline void guest_exit_irqoff(void) if (context_tracking_enabled()) __context_tracking_exit(CONTEXT_GUEST); - if (vtime_accounting_cpu_enabled()) + if (vtime_accounting_enabled_this_cpu()) vtime_guest_exit(current); else current->flags &= ~PF_VCPU; diff --git a/include/linux/vtime.h b/include/linux/vtime.h index 54e91511250b..eb2e7a19054b 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h @@ -11,11 +11,11 @@ struct task_struct; /* - * vtime_accounting_cpu_enabled() definitions/declarations + * vtime_accounting_enabled_this_cpu() definitions/declarations */ #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) -static inline bool vtime_accounting_cpu_enabled(void) { return true; } +static inline bool vtime_accounting_enabled_this_cpu(void) { return true; } extern void vtime_task_switch(struct task_struct *prev); #elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN) @@ -31,7 +31,7 @@ static inline bool vtime_accounting_enabled(void) return context_tracking_enabled(); } -static inline bool vtime_accounting_cpu_enabled(void) +static inline bool vtime_accounting_enabled_this_cpu(void) { if (vtime_accounting_enabled()) { if (context_tracking_enabled_this_cpu()) @@ -45,13 +45,13 @@ extern void vtime_task_switch_generic(struct task_struct *prev); static inline void vtime_task_switch(struct task_struct *prev) { - if (vtime_accounting_cpu_enabled()) + if (vtime_accounting_enabled_this_cpu()) vtime_task_switch_generic(prev); } #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ -static inline bool vtime_accounting_cpu_enabled(void) { return false; } +static inline bool vtime_accounting_enabled_this_cpu(void) { return false; } static inline void vtime_task_switch(struct task_struct *prev) { } #endif diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 34086afc3518..b931a19df093 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -475,7 +475,7 @@ void account_process_tick(struct task_struct *p, int user_tick) u64 cputime, steal; struct rq *rq = this_rq(); - if (vtime_accounting_cpu_enabled()) + if (vtime_accounting_enabled_this_cpu()) return; if (sched_clock_irqtime) { diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 955851748dc3..c2748232f607 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1119,7 +1119,7 @@ static void tick_nohz_account_idle_ticks(struct tick_sched *ts) #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE unsigned long ticks; - if (vtime_accounting_cpu_enabled()) + if (vtime_accounting_enabled_this_cpu()) return; /* * We stopped the tick in idle. Update process times would miss the -- 2.23.0
[PATCH 14/14] leds: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM
Now that we have a vtime safe kcpustat accessor for CPUTIME_SYSTEM, use it to start fixing frozen kcpustat values on nohz_full CPUs. Reported-by: Yauheni Kaliuta Signed-off-by: Frederic Weisbecker Cc: Jacek Anaszewski Cc: Pavel Machek Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- drivers/leds/trigger/ledtrig-activity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c index 6a72b7e13719..ddfc5edd07c8 100644 --- a/drivers/leds/trigger/ledtrig-activity.c +++ b/drivers/leds/trigger/ledtrig-activity.c @@ -59,7 +59,7 @@ static void led_activity_function(struct timer_list *t) for_each_possible_cpu(i) { curr_used += kcpustat_cpu(i).cpustat[CPUTIME_USER] + kcpustat_cpu(i).cpustat[CPUTIME_NICE] - + kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM] + + kcpustat_field(_cpu(i), CPUTIME_SYSTEM, i) + kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ] + kcpustat_cpu(i).cpustat[CPUTIME_IRQ]; cpus++; -- 2.23.0
[PATCH 13/14] cpufreq: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEM
Now that we have a vtime safe kcpustat accessor for CPUTIME_SYSTEM, use it to start fixing frozen kcpustat values on nohz_full CPUs. Reported-by: Yauheni Kaliuta Signed-off-by: Frederic Weisbecker Cc: Rafael J. Wysocki Cc: Viresh Kumar Cc: Yauheni Kaliuta Cc: Thomas Gleixner Cc: Rik van Riel Cc: Peter Zijlstra Cc: Wanpeng Li Cc: Ingo Molnar --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c52d6fa32aac..a37ebfd7e0e8 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -120,7 +120,7 @@ static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) cur_wall_time = jiffies64_to_nsecs(get_jiffies_64()); busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; - busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; + busy_time += kcpustat_field(_cpu(cpu), CPUTIME_SYSTEM, cpu); busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; -- 2.23.0