Re: [PATCH] clocksource/drivers/sp804: make CONFIG_ARM_TIMER_SP804 selectable again
Helmut, On Fri, 16 Aug 2019, Helmut Grohne wrote: > I also note that there are likely more instances for this pattern. > Should they be fixed in a similar way? You can find a lot using the > following incantation: > > $ git describe --tags > v5.3-rc4 > $ git ls-files -- "*/Kconfig" | xargs git grep --cached 'bool .* if > COMPILE_TEST$' -- | wc -l > 185 > $ > > Seems like an anti-pattern to me. It is particularly common in the > clocksource subtree. After some rumaging I figured out that the idea behind this is that the platforms which need those clocksources use 'select $CLOCKSOURCE' which works despite the 'if COMPILE_TEST'. The 'if COMPILE_TEST' is there to hide the config option when there is no platform which needs it and expose it for compile test purposes. So if your particular platform does not use 'select ARM_TIMER_SP804' then the right fix is to add it to that platform. Thanks, tglx
Re: [PATCH] MAINTAINERS, x86/CPU: Tony Luck will maintain asm/intel-family.h
On Thu, 15 Aug 2019, Luck, Tony wrote: > >From 093bf8cd02f4c7a3fa256c2cf7302014190e2840 Mon Sep 17 00:00:00 2001 > From: Tony Luck > Date: Thu, 15 Aug 2019 11:16:24 -0700 > Subject: [PATCH] x86/cpu: Explain Intel model naming convention > > Dave Hansen spelled out the rules in an e-mail: > > https://lkml.kernel.org/r/91eefbe4-e32b-d762-be4d-672ff915d...@intel.com > > Copy those right into the file to > make it easy for people to find them. > > Suggested-by: Borislav Petkov > Signed-off-by: Tony Luck > --- > arch/x86/include/asm/intel-family.h | 15 +++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/include/asm/intel-family.h > b/arch/x86/include/asm/intel-family.h > index 0278aa66ef62..fe7c205233f1 100644 > --- a/arch/x86/include/asm/intel-family.h > +++ b/arch/x86/include/asm/intel-family.h > @@ -11,6 +11,21 @@ > * While adding a new CPUID for a new microarchitecture, add a new > * group to keep logically sorted out in chronological order. Within > * that group keep the CPUID for the variants sorted by model number. > + * > + * The defined symbol names have the following form: > + * INTEL_FAM6{OPTFAMILY}_{MICROARCH}{OPTDIFF} > + * where: > + * OPTFAMILY Describes the family of CPUs that this belongs to. Default > + * is assumed to be "_CORE" (and should be omitted). Other values > + * currently in use are _ATOM and _XEON_PHI > + * MICROARCH Is the code name for the micro-architecture for this core. > + * N.B. Not the platform name. > + * OPTDIFF If needed, a short string to differentiate by market segment. > + * Exact strings here will vary over time. _DESKTOP, _MOBILE, and > + * _X (short for Xeon server) should be used when they are > + * appropriate. > + * > + * The #define line may optionally include a comment including platform > names. > */ Acked-by: Thomas Gleixner
Re: [RFC PATCH 00/15] acrn: add the ACRN driver module
On Fri, Aug 16, 2019 at 08:39:25AM +0200, Borislav Petkov wrote: > On Fri, Aug 16, 2019 at 10:25:41AM +0800, Zhao Yakui wrote: > > The first three patches are the changes under x86/acrn, which adds the > > required APIs for the driver and reports the X2APIC caps. > > The remaining patches add the ACRN driver module, which accepts the ioctl > > from user-space and then communicate with the low-level ACRN hypervisor > > by using hypercall. > > I have a problem with that: you're adding interfaces to arch/x86/ and > its users go into staging. Why? Why not directly put the driver where > it belongs, clean it up properly and submit it like everything else is > submitted? > > I don't want to have stuff in arch/x86/ which is used solely by code in > staging and the latter is lingering there indefinitely because no one is > cleaning it up... I agree, stuff in drivers/staging/ must be self-contained, with no changes outside of the code's subdirectory needed in order for it to work. That way it is trivial for us to delete it when it never gets cleaned up :) You never say _why_ this should go into drivers/staging/, nor do you have a TODO file like all other staging code that explains exactly what needs to be done to get it out of there. thanks, greg k-h
Re: [PATCH] csky: Fixup ioremap function losing
On Thu, Aug 15, 2019 at 07:28:57PM +0800, guo...@kernel.org wrote: > From: Guo Ren > > Implement the following apis to meet usage in different scenarios. > > - ioremap (NonCache + StrongOrder) > - ioremap_nocache (NonCache + StrongOrder) > - ioremap_wc (NonCache + WeakOrder ) > - ioremap_cache( Cache + WeakOrder ) > > Also change flag VM_ALLOC to VM_IOREMAP in get_vm_area_caller. Looks generally fine, but two comments: - do you have a need for ioremap_cache? We are generally try to phase it out in favour of memremap, and it is generally only used by arch specific code. - I have a big series pending to clean up the mess with our ioremap_* functions, including adding a generic implementation that csky should be able to use. Unless this patch is urgent it might make sense to rebase it on top. Here is my current tree, I plan to post it soon: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/generic-ioremap
Re: [RFC PATCH 04/15] drivers/acrn: add the basic framework of acrn char device driver
On Fri, Aug 16, 2019 at 10:25:45AM +0800, Zhao Yakui wrote: > ACRN hypervisor service module is the important middle layer that allows > the Linux kernel to communicate with the ACRN hypervisor. It includes > the management of virtualized CPU/memory/device/interrupt for other ACRN > guest. The user-space applications can use the provided ACRN ioctls to > interact with ACRN hypervisor through different hypercalls. > > Add one basic framework firstly and the following patches will > add the corresponding implementations, which includes the management of > virtualized CPU/memory/interrupt and the emulation of MMIO/IO/PCI access. > The device file of /dev/acrn_hsm can be accessed in user-space to > communicate with ACRN module. > > Co-developed-by: Jason Chen CJ > Signed-off-by: Jason Chen CJ > Co-developed-by: Jack Ren > Signed-off-by: Jack Ren > Co-developed-by: Mingqiang Chi > Signed-off-by: Mingqiang Chi > Co-developed-by: Liu Shuo > Signed-off-by: Liu Shuo > Signed-off-by: Zhao Yakui > --- > drivers/staging/Kconfig | 2 + Also, your subject line for all of these patches are wrong, it is not drivers/acrn :( And you forgot to cc: the staging maintainer :( As I have said with NUMEROUS Intel patches in the past, I now refuse to take patches from you all WITHOUT having it signed-off-by someone from the Intel "OTC" group (or whatever the Intel Linux group is called these days). They are a resource you can not ignore, and if you do, you just end up making the rest of the kernel community grumpy by having us do their work for them :( Please work with them. greg k-h
Re: possible deadlock in static_key_slow_dec
syzbot has found a reproducer for the following crash on: HEAD commit:17da61ae Add linux-next specific files for 20190814 git tree: linux-next console output: https://syzkaller.appspot.com/x/log.txt?x=158810ac60 kernel config: https://syzkaller.appspot.com/x/.config?x=4733704ca85aaa66 dashboard link: https://syzkaller.appspot.com/bug?extid=b011e55d1b4c015100d2 compiler: gcc (GCC) 9.0.0 20181231 (experimental) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13b5b49660 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=147935ee60 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+b011e55d1b4c01510...@syzkaller.appspotmail.com == WARNING: possible circular locking dependency detected 5.3.0-rc4-next-20190814 #66 Not tainted -- syz-executor590/9351 is trying to acquire lock: 88f5eef0 (cpu_hotplug_lock.rw_sem){}, at: __static_key_slow_dec kernel/jump_label.c:254 [inline] 88f5eef0 (cpu_hotplug_lock.rw_sem){}, at: static_key_slow_dec+0x54/0xa0 kernel/jump_label.c:270 but task is already holding lock: 8880a96354d0 (&mm->mmap_sem#2){}, at: vm_mmap_pgoff+0x173/0x230 mm/util.c:494 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&mm->mmap_sem#2){}: down_write+0x93/0x150 kernel/locking/rwsem.c:1534 mpol_rebind_mm+0x25/0xd0 mm/mempolicy.c:382 cpuset_attach+0x226/0x420 kernel/cgroup/cpuset.c:2204 cgroup_migrate_execute+0xc56/0x1350 kernel/cgroup/cgroup.c:2524 cgroup_migrate+0x14f/0x1f0 kernel/cgroup/cgroup.c:2780 cgroup_attach_task+0x57f/0x860 kernel/cgroup/cgroup.c:2817 __cgroup1_procs_write.constprop.0+0x321/0x400 kernel/cgroup/cgroup-v1.c:522 cgroup1_procs_write+0x2b/0x40 kernel/cgroup/cgroup-v1.c:535 cgroup_file_write+0x241/0x790 kernel/cgroup/cgroup.c:3754 kernfs_fop_write+0x2b8/0x480 fs/kernfs/file.c:315 __vfs_write+0x8a/0x110 fs/read_write.c:494 vfs_write+0x268/0x5d0 fs/read_write.c:558 ksys_write+0x14f/0x290 fs/read_write.c:611 __do_sys_write fs/read_write.c:623 [inline] __se_sys_write fs/read_write.c:620 [inline] __x64_sys_write+0x73/0xb0 fs/read_write.c:620 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #1 (&cpuset_rwsem){}: percpu_down_read include/linux/percpu-rwsem.h:40 [inline] cpuset_read_lock+0x3e/0x150 kernel/cgroup/cpuset.c:340 __sched_setscheduler+0xca2/0x2110 kernel/sched/core.c:4718 _sched_setscheduler+0x10a/0x1b0 kernel/sched/core.c:4890 sched_setscheduler_nocheck+0xb/0x10 kernel/sched/core.c:4936 __kthread_create_on_node+0x32a/0x460 kernel/kthread.c:349 kthread_create_on_node+0xbb/0xf0 kernel/kthread.c:388 create_worker+0x25c/0x570 kernel/workqueue.c:1929 workqueue_prepare_cpu+0xa1/0x100 kernel/workqueue.c:4982 cpuhp_invoke_callback+0x21a/0x1c60 kernel/cpu.c:172 cpuhp_up_callbacks kernel/cpu.c:593 [inline] _cpu_up+0x289/0x550 kernel/cpu.c:1153 do_cpu_up+0x171/0x190 kernel/cpu.c:1188 cpu_up+0x1b/0x20 kernel/cpu.c:1196 smp_init+0x248/0x261 kernel/smp.c:593 kernel_init_freeable+0x339/0x5be init/main.c:1185 kernel_init+0x12/0x1c5 init/main.c:1110 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 -> #0 (cpu_hotplug_lock.rw_sem){}: check_prev_add kernel/locking/lockdep.c:2476 [inline] check_prevs_add kernel/locking/lockdep.c:2581 [inline] validate_chain kernel/locking/lockdep.c:2971 [inline] __lock_acquire+0x25b6/0x4e70 kernel/locking/lockdep.c:3955 lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4487 percpu_down_read include/linux/percpu-rwsem.h:40 [inline] cpus_read_lock+0x3e/0x150 kernel/cpu.c:292 __static_key_slow_dec kernel/jump_label.c:254 [inline] static_key_slow_dec+0x54/0xa0 kernel/jump_label.c:270 sw_perf_event_destroy+0x8b/0x130 kernel/events/core.c:8482 _free_event+0x354/0x13a0 kernel/events/core.c:4470 put_event+0x47/0x60 kernel/events/core.c:4564 perf_mmap_close+0x585/0xe00 kernel/events/core.c:5567 remove_vma+0xb2/0x180 mm/mmap.c:183 remove_vma_list mm/mmap.c:2615 [inline] __do_munmap+0x7b0/0x10f0 mm/mmap.c:2859 do_munmap mm/mmap.c:2867 [inline] mmap_region+0x227/0x1760 mm/mmap.c:1745 do_mmap+0x853/0x1180 mm/mmap.c:1575 do_mmap_pgoff include/linux/mm.h:2395 [inline] vm_mmap_pgoff+0x1c5/0x230 mm/util.c:496 ksys_mmap_pgoff+0x4aa/0x630 mm/mmap.c:1625 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:100 [inline] __se_sys_mmap arch/x86/kernel/sys_x86_64.c:91 [inline] __x64_sys_mmap+0xe9/0x1b0 arch/x86/kernel/sys_x86
Re: [PATCH v4 14/21] ARM: dts: imx6ull-colibri: Add sleep mode to fec
On Mon, Aug 12, 2019 at 5:22 PM Philippe Schenker wrote: > > Do not change the clock as the power for this phy is switched > with that clock. > > Signed-off-by: Philippe Schenker > Acked-by: Marcel Ziswiler Reviewed-by: Oleksandr Suvorov > > --- > > Changes in v4: > - Add Marcel Ziswiler's Ack > > Changes in v3: None > Changes in v2: None > > arch/arm/boot/dts/imx6ull-colibri.dtsi | 18 +- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boot/dts/imx6ull-colibri.dtsi > b/arch/arm/boot/dts/imx6ull-colibri.dtsi > index d56728f03c35..1019ce69a242 100644 > --- a/arch/arm/boot/dts/imx6ull-colibri.dtsi > +++ b/arch/arm/boot/dts/imx6ull-colibri.dtsi > @@ -62,8 +62,9 @@ > }; > > &fec2 { > - pinctrl-names = "default"; > + pinctrl-names = "default", "sleep"; > pinctrl-0 = <&pinctrl_enet2>; > + pinctrl-1 = <&pinctrl_enet2_sleep>; > phy-mode = "rmii"; > phy-handle = <ðphy1>; > status = "okay"; > @@ -220,6 +221,21 @@ > >; > }; > > + pinctrl_enet2_sleep: enet2sleepgrp { > + fsl,pins = < > + MX6UL_PAD_GPIO1_IO06__GPIO1_IO060x0 > + MX6UL_PAD_GPIO1_IO07__GPIO1_IO070x0 > + MX6UL_PAD_ENET2_RX_DATA0__GPIO2_IO080x0 > + MX6UL_PAD_ENET2_RX_DATA1__GPIO2_IO090x0 > + MX6UL_PAD_ENET2_RX_EN__GPIO2_IO10 0x0 > + MX6UL_PAD_ENET2_RX_ER__GPIO2_IO15 0x0 > + MX6UL_PAD_ENET2_TX_CLK__ENET2_REF_CLK2 0x4001b031 > + MX6UL_PAD_ENET2_TX_DATA0__GPIO2_IO110x0 > + MX6UL_PAD_ENET2_TX_DATA1__GPIO2_IO120x0 > + MX6UL_PAD_ENET2_TX_EN__GPIO2_IO13 0x0 > + >; > + }; > + > pinctrl_ecspi1_cs: ecspi1-cs-grp { > fsl,pins = < > MX6UL_PAD_LCD_DATA21__GPIO3_IO260x000a0 > -- > 2.22.0 > -- Best regards Oleksandr Suvorov Toradex AG Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 4800 (main line)
Re: [PATCH] powerpc: Allow flush_(inval_)dcache_range to work across ranges >4GB
On Fri, Aug 16, 2019 at 11:42:22AM +1000, Michael Ellerman wrote: > Greg Kroah-Hartman writes: > > On Thu, Aug 15, 2019 at 02:55:42PM +1000, Alastair D'Silva wrote: > >> From: Alastair D'Silva > >> > >> Heads Up: This patch cannot be submitted to Linus's tree, as the affected > >> assembler functions have already been converted to C. > > That was done in upstream commit: > > 22e9c88d486a ("powerpc/64: reuse PPC32 static inline flush_dcache_range()") > > Which is a larger change that we don't want to backport. This patch is a > minimal fix for stable trees. > > > >> When calling flush_(inval_)dcache_range with a size >4GB, we were masking > >> off the upper 32 bits, so we would incorrectly flush a range smaller > >> than intended. > >> > >> This patch replaces the 32 bit shifts with 64 bit ones, so that > >> the full size is accounted for. > >> > >> Signed-off-by: Alastair D'Silva > >> --- > >> arch/powerpc/kernel/misc_64.S | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > > Acked-by: Michael Ellerman > > > > > > > This is not the correct way to submit patches for inclusion in the > > stable kernel tree. Please read: > > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html > > for how to do this properly. > > > > > > Hi Greg, > > This is "option 3", submit the patch directly, and the patch "deviates > from the original upstream patch" because the upstream patch was a > wholesale conversion from asm to C. > > This patch applies cleanly to v4.14 and v4.19. > > The change log should have mentioned which upstream patch it is not a > backport of, is there anything else we should have done differently to > avoid the formletter bot :) That is exactly what you should have done. It needs to be VERY explicit as to why this is being submitted different from what upstream did, and to what trees it needs to go to and who is going to be responsible for when it breaks. And it will break :) thanks, greg k-h
Re: [PATCH 4.14 00/69] 4.14.139-stable review
On Thu, Aug 15, 2019 at 08:37:33PM -0600, shuah wrote: > On 8/14/19 11:00 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 4.14.139 release. > > There are 69 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Fri 16 Aug 2019 04:55:34 PM UTC. > > Anything received after that time might be too late. > > > > The whole patch series can be found in one patch at: > > > > https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.139-rc1.gz > > or in the git tree and branch at: > > > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > > linux-4.14.y > > and the diffstat can be found below. > > > > thanks, > > > > greg k-h > > > > Compiled and booted on my test system. No dmesg regressions. Thanks for testing all of these and letting me know. greg k-h
Re: [PATCH 5.2 000/144] 5.2.9-stable review
On Fri, Aug 16, 2019 at 12:39:21AM -0600, Kelsey Skunberg wrote: > On Wed, Aug 14, 2019 at 06:59:16PM +0200, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 5.2.9 release. > > There are 144 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Fri 16 Aug 2019 04:55:34 PM UTC. > > Anything received after that time might be too late. > > > > The whole patch series can be found in one patch at: > > > > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.9-rc1.gz > > or in the git tree and branch at: > > > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > > linux-5.2.y > > and the diffstat can be found below. > > > > thanks, > > > > greg k-h > > Compiled and booted with no dmesg regressions on my system. Wonderful, thanks for testing them all and letting me know. greg k-h
Re: [PATCH] KVM: x86/MMU: Zap all when removing memslot if VM has assigned device
On 15/08/19 17:12, Sean Christopherson wrote: > Alex Williamson reported regressions with device assignment when KVM > changed its memslot removal logic to zap only the SPTEs for the memslot > being removed. The source of the bug is unknown at this time, and root > causing the issue will likely be a slow process. In the short term, fix > the regression by zapping all SPTEs when removing a memslot from a VM > with assigned device(s). > > Fixes: 4e103134b862 ("KVM: x86/mmu: Zap only the relevant pages when removing > a memslot", 2019-02-05) > Reported-by: Alex Willamson > Cc: sta...@vger.kernel.org > Signed-off-by: Sean Christopherson > --- > > An alternative idea to a full revert. I assume this would be easy to > backport, and also easy to revert or quirk depending on where the bug > is hiding. We're not sure that it only happens with assigned devices; it's just that assigned BARs are the memslots that are more likely to be reprogrammed at boot. So this patch feels unsafe. Paolo > > arch/x86/kvm/mmu.c | 11 +++ > 1 file changed, 11 insertions(+) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index 8f72526e2f68..358b93882ac6 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -5659,6 +5659,17 @@ static void > kvm_mmu_invalidate_zap_pages_in_memslot(struct kvm *kvm, > bool flush; > gfn_t gfn; > > + /* > + * Zapping only the removed memslot introduced regressions for VMs with > + * assigned devices. It is unknown what piece of code is buggy. Until > + * the source of the bug is identified, zap everything if the VM has an > + * assigned device. > + */ > + if (kvm_arch_has_assigned_device(kvm)) { > + kvm_mmu_zap_all(kvm); > + return; > + } > + > spin_lock(&kvm->mmu_lock); > > if (list_empty(&kvm->arch.active_mmu_pages)) >
[PATCH v3 0/10] Add mt7629 and fix mt7628 pwm
From: sam shih Changes since v2: - use num-pwms instead of mediatek,num-pwms. - rename the member from num_pwms to fallback_num_pwms to make it more obvious that it doesn't represent the actually used value. - add a dev_warn and a expressive comment to help other developers to not start adding num_pwms in the compatible_data. Changes since v1: - add some checks for backwards compatibility. Sam Shih (3): pwm: mediatek: add new property and fix mt7628 pwm dt-bindings: pwm: update bindings for MT7628 SoC arm: dts: mediatek: add mt7629 pwm support .../devicetree/bindings/pwm/pwm-mediatek.txt | 3 +++ arch/arm/boot/dts/mt7629.dtsi | 14 ++ drivers/pwm/pwm-mediatek.c| 15 ++- 3 files changed, 31 insertions(+), 1 deletion(-) Ryder Lee (7): pwm: mediatek: add a property "num-pwms" pwm: mediatek: allocate the clks array dynamically pwm: mediatek: use pwm_mediatek as common prefix dt-bindings: pwm: add a property "num-pwms" arm64: dts: mt7622: add a property "num-pwms" for PWM node arm: dts: mt7623: add a property "num-pwms" for PWM node dt-bindings: pwm: update bindings for MT7629 SoC .../devicetree/bindings/pwm/pwm-mediatek.txt | 8 +- arch/arm/boot/dts/mt7623.dtsi | 1 + arch/arm64/boot/dts/mediatek/mt7622.dtsi | 1 + drivers/pwm/pwm-mediatek.c| 226 +- 4 files changed, 126 insertions(+), 110 deletions(-) -- 2.17.1
[PATCH v3 4/10] dt-bindings: pwm: add a property "num-pwms"
From: Ryder Lee This adds a property "num-pwms" in example so that we could specify the number of PWM channels via device tree. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih Reviewed-by: Matthias Brugger --- Documentation/devicetree/bindings/pwm/pwm-mediatek.txt | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt index 991728cb46cb..ea95b490a913 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt @@ -14,12 +14,12 @@ Required properties: has no clocks - "top": the top clock generator - "main": clock used by the PWM core - - "pwm1-8": the eight per PWM clocks for mt2712 - - "pwm1-6": the six per PWM clocks for mt7622 - - "pwm1-5": the five per PWM clocks for mt7623 + - "pwm1-N": the PWM clocks for each channel + where N starting from 1 to the maximum number of PWM channels - pinctrl-names: Must contain a "default" entry. - pinctrl-0: One property must exist for each entry in pinctrl-names. See pinctrl/pinctrl-bindings.txt for details of the property values. + - num-pwms: the number of PWM channels. Example: pwm0: pwm@11006000 { @@ -37,4 +37,5 @@ Example: "pwm3", "pwm4", "pwm5"; pinctrl-names = "default"; pinctrl-0 = <&pwm0_pins>; + num-pwms = <5>; }; -- 2.17.1
[PATCH v3 5/10] arm64: dts: mt7622: add a property "num-pwms" for PWM node
From: Ryder Lee This adds a property "num-pwms" for PWM controller. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih --- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/mediatek/mt7622.dtsi b/arch/arm64/boot/dts/mediatek/mt7622.dtsi index d1e13d340e26..9a043938881f 100644 --- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi @@ -439,6 +439,7 @@ <&pericfg CLK_PERI_PWM6_PD>; clock-names = "top", "main", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5", "pwm6"; + num-pwms = <6>; status = "disabled"; }; -- 2.17.1
[PATCH v3 3/10] pwm: mediatek: use pwm_mediatek as common prefix
From: Ryder Lee Use pwm_mediatek as common prefix to match the filename. No functional change intended. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih --- drivers/pwm/pwm-mediatek.c | 119 +++-- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 47585b68483d..d696df7a58fa 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -1,12 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * Mediatek Pulse Width Modulator driver + * MediaTek Pulse Width Modulator driver * * Copyright (C) 2015 John Crispin * Copyright (C) 2017 Zhi Mao * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. */ #include @@ -35,41 +33,43 @@ #define PWM_CLK_DIV_MAX7 -struct mtk_pwm_platform_data { +struct pwm_mediatek_of_data { unsigned int fallback_npwms; bool pwm45_fixup; bool has_clks; }; /** - * struct mtk_pwm_chip - struct representing PWM chip + * struct pwm_mediatek_chip - struct representing PWM chip * @chip: linux PWM chip representation * @regs: base address of PWM chip * @clk_top: the top clock generator * @clk_main: the clock used by PWM core * @clk_pwms: the clock used by each PWM channel */ -struct mtk_pwm_chip { +struct pwm_mediatek_chip { struct pwm_chip chip; void __iomem *regs; struct clk *clk_top; struct clk *clk_main; struct clk **clk_pwms; - const struct mtk_pwm_platform_data *soc; + const struct pwm_mediatek_of_data *soc; }; -static const unsigned int mtk_pwm_reg_offset[] = { +static const unsigned int pwm_mediatek_reg_offset[] = { 0x0010, 0x0050, 0x0090, 0x00d0, 0x0110, 0x0150, 0x0190, 0x0220 }; -static inline struct mtk_pwm_chip *to_mtk_pwm_chip(struct pwm_chip *chip) +static inline struct pwm_mediatek_chip * +to_pwm_mediatek_chip(struct pwm_chip *chip) { - return container_of(chip, struct mtk_pwm_chip, chip); + return container_of(chip, struct pwm_mediatek_chip, chip); } -static int mtk_pwm_clk_enable(struct pwm_chip *chip, struct pwm_device *pwm) +static int pwm_mediatek_clk_enable(struct pwm_chip *chip, + struct pwm_device *pwm) { - struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); + struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); int ret; if (!pc->soc->has_clks) @@ -97,9 +97,10 @@ static int mtk_pwm_clk_enable(struct pwm_chip *chip, struct pwm_device *pwm) return ret; } -static void mtk_pwm_clk_disable(struct pwm_chip *chip, struct pwm_device *pwm) +static void pwm_mediatek_clk_disable(struct pwm_chip *chip, +struct pwm_device *pwm) { - struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); + struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); if (!pc->soc->has_clks) return; @@ -109,30 +110,30 @@ static void mtk_pwm_clk_disable(struct pwm_chip *chip, struct pwm_device *pwm) clk_disable_unprepare(pc->clk_top); } -static inline u32 mtk_pwm_readl(struct mtk_pwm_chip *chip, unsigned int num, - unsigned int offset) +static inline u32 pwm_mediatek_readl(struct pwm_mediatek_chip *chip, +unsigned int num, unsigned int offset) { - return readl(chip->regs + mtk_pwm_reg_offset[num] + offset); + return readl(chip->regs + pwm_mediatek_reg_offset[num] + offset); } -static inline void mtk_pwm_writel(struct mtk_pwm_chip *chip, - unsigned int num, unsigned int offset, - u32 value) +static inline void pwm_mediatek_writel(struct pwm_mediatek_chip *chip, + unsigned int num, unsigned int offset, + u32 value) { - writel(value, chip->regs + mtk_pwm_reg_offset[num] + offset); + writel(value, chip->regs + pwm_mediatek_reg_offset[num] + offset); } -static int mtk_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, - int duty_ns, int period_ns) +static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm, + int duty_ns, int period_ns) { - struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); + struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); struct clk *clk = pc->soc->has_clks ? pc->clk_pwms[pwm->hwpwm] : NULL; u32 clkdiv = 0, cnt_period, cnt_duty, reg_width = PWMDWIDTH, reg_thres = PWMTHRES; u64 resolution; int ret; - ret = mtk_pwm_clk_enable(chip, pwm); + ret = pwm_mediatek_clk_enable(chip, pwm); if (ret < 0) return ret; @@ -149,7 +
[PATCH v3 8/10] pwm: mediatek: add new property and fix mt7628 pwm
From: sam shih This fix mt7628 pwm during configure from userspace. The SoC is legacy MIPS and has no complex clock tree. This patch add property clock-frequency to the SoC specific data and legacy MIPS SoC need to configure it in DT. This property is use for period calculation. Signed-off-by: Sam Shih --- drivers/pwm/pwm-mediatek.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index d696df7a58fa..922a7543a2b1 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -53,6 +53,7 @@ struct pwm_mediatek_chip { struct clk *clk_top; struct clk *clk_main; struct clk **clk_pwms; + unsigned int clk_freq; const struct pwm_mediatek_of_data *soc; }; @@ -139,7 +140,10 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm, /* Using resolution in picosecond gets accuracy higher */ resolution = (u64)NSEC_PER_SEC * 1000; - do_div(resolution, clk_get_rate(clk)); + if (pc->soc->has_clks) + do_div(resolution, clk_get_rate(clk)); + else + do_div(resolution, pc->clk_freq); cnt_period = DIV_ROUND_CLOSEST_ULL((u64)period_ns * 1000, resolution); while (cnt_period > 8191) { @@ -216,6 +220,7 @@ static int pwm_mediatek_probe(struct platform_device *pdev) struct pwm_mediatek_chip *pc; struct resource *res; unsigned int npwms; + unsigned int clk_freq; int ret; pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); @@ -265,6 +270,14 @@ static int pwm_mediatek_probe(struct platform_device *pdev) if (IS_ERR(pc->clk_pwms[i])) return PTR_ERR(pc->clk_pwms[i]); } + } else { + ret = of_property_read_u32(np, "clock-frequency", + &clk_freq); + if (ret < 0) { + dev_err(&pdev->dev, "failed to get clk_freq\n"); + return ret; + } + pc->clk_freq = clk_freq; } platform_set_drvdata(pdev, pc); -- 2.17.1
[PATCH v3 7/10] dt-bindings: pwm: update bindings for MT7629 SoC
From: Ryder Lee This updates bindings for MT7629 pwm controller. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih Reviewed-by: Matthias Brugger --- Documentation/devicetree/bindings/pwm/pwm-mediatek.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt index ea95b490a913..c7bd5633d1eb 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt @@ -6,6 +6,7 @@ Required properties: - "mediatek,mt7622-pwm": found on mt7622 SoC. - "mediatek,mt7623-pwm": found on mt7623 SoC. - "mediatek,mt7628-pwm": found on mt7628 SoC. + - "mediatek,mt7629-pwm", "mediatek,mt7622-pwm": found on mt7629 SoC. - reg: physical base address and length of the controller's registers. - #pwm-cells: must be 2. See pwm.txt in this directory for a description of the cell format. -- 2.17.1
[PATCH v3 1/10] pwm: mediatek: add a property "num-pwms"
From: Ryder Lee This adds a property "num-pwms" to avoid having an endless list of compatibles with no differences for the same driver. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih --- drivers/pwm/pwm-mediatek.c | 35 ++- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index eb6674ce995f..f9d67fb66adb 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -55,7 +55,7 @@ static const char * const mtk_pwm_clk_name[MTK_CLK_MAX] = { }; struct mtk_pwm_platform_data { - unsigned int num_pwms; + unsigned int fallback_npwms; bool pwm45_fixup; bool has_clks; }; @@ -226,27 +226,36 @@ static const struct pwm_ops mtk_pwm_ops = { static int mtk_pwm_probe(struct platform_device *pdev) { - const struct mtk_pwm_platform_data *data; + struct device_node *np = pdev->dev.of_node; struct mtk_pwm_chip *pc; struct resource *res; - unsigned int i; + unsigned int i, npwms; int ret; pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); if (!pc) return -ENOMEM; - data = of_device_get_match_data(&pdev->dev); - if (data == NULL) - return -EINVAL; - pc->soc = data; + pc->soc = of_device_get_match_data(&pdev->dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pc->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(pc->regs)) return PTR_ERR(pc->regs); - for (i = 0; i < data->num_pwms + 2 && pc->soc->has_clks; i++) { + ret = of_property_read_u32(np, "num-pwms", &npwms); + if (ret < 0) { + /* It's deprecated, we should specify num_pwms via DT now. */ + if (pc->soc->fallback_npwms) { + npwms = pc->soc->fallback_npwms; + dev_warn(&pdev->dev, "DT is outdated, please update it\n"); + } else { + dev_err(&pdev->dev, "failed to get number of PWMs\n"); + return ret; + } + } + + for (i = 0; i < npwms + 2 && pc->soc->has_clks; i++) { pc->clks[i] = devm_clk_get(&pdev->dev, mtk_pwm_clk_name[i]); if (IS_ERR(pc->clks[i])) { dev_err(&pdev->dev, "clock: %s fail: %ld\n", @@ -260,7 +269,7 @@ static int mtk_pwm_probe(struct platform_device *pdev) pc->chip.dev = &pdev->dev; pc->chip.ops = &mtk_pwm_ops; pc->chip.base = -1; - pc->chip.npwm = data->num_pwms; + pc->chip.npwm = npwms; ret = pwmchip_add(&pc->chip); if (ret < 0) { @@ -279,25 +288,25 @@ static int mtk_pwm_remove(struct platform_device *pdev) } static const struct mtk_pwm_platform_data mt2712_pwm_data = { - .num_pwms = 8, + .fallback_npwms = 8, .pwm45_fixup = false, .has_clks = true, }; static const struct mtk_pwm_platform_data mt7622_pwm_data = { - .num_pwms = 6, + .fallback_npwms = 6, .pwm45_fixup = false, .has_clks = true, }; static const struct mtk_pwm_platform_data mt7623_pwm_data = { - .num_pwms = 5, + .fallback_npwms = 5, .pwm45_fixup = true, .has_clks = true, }; static const struct mtk_pwm_platform_data mt7628_pwm_data = { - .num_pwms = 4, + .fallback_npwms = 4, .pwm45_fixup = true, .has_clks = false, }; -- 2.17.1
[PATCH v3 2/10] pwm: mediatek: allocate the clks array dynamically
From: Ryder Lee Instead of using fixed size of arrays, allocate the memory for them based on the information we get from the chips. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih --- drivers/pwm/pwm-mediatek.c | 76 +++--- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index f9d67fb66adb..47585b68483d 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -35,25 +35,6 @@ #define PWM_CLK_DIV_MAX7 -enum { - MTK_CLK_MAIN = 0, - MTK_CLK_TOP, - MTK_CLK_PWM1, - MTK_CLK_PWM2, - MTK_CLK_PWM3, - MTK_CLK_PWM4, - MTK_CLK_PWM5, - MTK_CLK_PWM6, - MTK_CLK_PWM7, - MTK_CLK_PWM8, - MTK_CLK_MAX, -}; - -static const char * const mtk_pwm_clk_name[MTK_CLK_MAX] = { - "main", "top", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5", "pwm6", "pwm7", - "pwm8" -}; - struct mtk_pwm_platform_data { unsigned int fallback_npwms; bool pwm45_fixup; @@ -64,12 +45,16 @@ struct mtk_pwm_platform_data { * struct mtk_pwm_chip - struct representing PWM chip * @chip: linux PWM chip representation * @regs: base address of PWM chip - * @clks: list of clocks + * @clk_top: the top clock generator + * @clk_main: the clock used by PWM core + * @clk_pwms: the clock used by each PWM channel */ struct mtk_pwm_chip { struct pwm_chip chip; void __iomem *regs; - struct clk *clks[MTK_CLK_MAX]; + struct clk *clk_top; + struct clk *clk_main; + struct clk **clk_pwms; const struct mtk_pwm_platform_data *soc; }; @@ -90,24 +75,24 @@ static int mtk_pwm_clk_enable(struct pwm_chip *chip, struct pwm_device *pwm) if (!pc->soc->has_clks) return 0; - ret = clk_prepare_enable(pc->clks[MTK_CLK_TOP]); + ret = clk_prepare_enable(pc->clk_top); if (ret < 0) return ret; - ret = clk_prepare_enable(pc->clks[MTK_CLK_MAIN]); + ret = clk_prepare_enable(pc->clk_main); if (ret < 0) goto disable_clk_top; - ret = clk_prepare_enable(pc->clks[MTK_CLK_PWM1 + pwm->hwpwm]); + ret = clk_prepare_enable(pc->clk_pwms[pwm->hwpwm]); if (ret < 0) goto disable_clk_main; return 0; disable_clk_main: - clk_disable_unprepare(pc->clks[MTK_CLK_MAIN]); + clk_disable_unprepare(pc->clk_main); disable_clk_top: - clk_disable_unprepare(pc->clks[MTK_CLK_TOP]); + clk_disable_unprepare(pc->clk_top); return ret; } @@ -119,9 +104,9 @@ static void mtk_pwm_clk_disable(struct pwm_chip *chip, struct pwm_device *pwm) if (!pc->soc->has_clks) return; - clk_disable_unprepare(pc->clks[MTK_CLK_PWM1 + pwm->hwpwm]); - clk_disable_unprepare(pc->clks[MTK_CLK_MAIN]); - clk_disable_unprepare(pc->clks[MTK_CLK_TOP]); + clk_disable_unprepare(pc->clk_pwms[pwm->hwpwm]); + clk_disable_unprepare(pc->clk_main); + clk_disable_unprepare(pc->clk_top); } static inline u32 mtk_pwm_readl(struct mtk_pwm_chip *chip, unsigned int num, @@ -141,7 +126,7 @@ static int mtk_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, int duty_ns, int period_ns) { struct mtk_pwm_chip *pc = to_mtk_pwm_chip(chip); - struct clk *clk = pc->clks[MTK_CLK_PWM1 + pwm->hwpwm]; + struct clk *clk = pc->soc->has_clks ? pc->clk_pwms[pwm->hwpwm] : NULL; u32 clkdiv = 0, cnt_period, cnt_duty, reg_width = PWMDWIDTH, reg_thres = PWMTHRES; u64 resolution; @@ -229,7 +214,7 @@ static int mtk_pwm_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct mtk_pwm_chip *pc; struct resource *res; - unsigned int i, npwms; + unsigned int npwms; int ret; pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); @@ -255,12 +240,29 @@ static int mtk_pwm_probe(struct platform_device *pdev) } } - for (i = 0; i < npwms + 2 && pc->soc->has_clks; i++) { - pc->clks[i] = devm_clk_get(&pdev->dev, mtk_pwm_clk_name[i]); - if (IS_ERR(pc->clks[i])) { - dev_err(&pdev->dev, "clock: %s fail: %ld\n", - mtk_pwm_clk_name[i], PTR_ERR(pc->clks[i])); - return PTR_ERR(pc->clks[i]); + if (pc->soc->has_clks) { + int i; + + pc->clk_pwms = devm_kcalloc(&pdev->dev, npwms, + sizeof(*pc->clk_pwms), GFP_KERNEL); + if (!pc->clk_pwms) + return -ENOMEM; + + pc->clk_top = devm_clk_get(&pdev->dev, "top"); + if (IS_ERR(pc->clk_top)) + return PTR_ERR(pc->clk_top); + + pc->clk_main = devm_clk_get(&pdev->dev, "main"); +
Re: [PATCH v9 08/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode
On Thu, 2019-08-15 at 12:50 +0100, Will Deacon wrote: > Ok, I think speaking to Robin helped me a bit with this... > > On Thu, Aug 15, 2019 at 06:18:38PM +0800, Yong Wu wrote: > > On Thu, 2019-08-15 at 10:51 +0100, Will Deacon wrote: > > > On Thu, Aug 15, 2019 at 04:47:49PM +0800, Yong Wu wrote: > > > > On Wed, 2019-08-14 at 15:41 +0100, Will Deacon wrote: > > > > > On Sat, Aug 10, 2019 at 03:58:08PM +0800, Yong Wu wrote: > > > > > > MediaTek extend the arm v7s descriptor to support the dram over 4GB. > > > > > > > > > > > > In the mt2712 and mt8173, it's called "4GB mode", the physical > > > > > > address > > > > > > is from 0x4000_ to 0x1_3fff_, but from EMI point of view, it > > > > > > is remapped to high address from 0x1__ to 0x1__, the > > > > > > bit32 is always enabled. thus, in the M4U, we always enable the bit9 > > > > > > for all PTEs which means to enable bit32 of physical address. Here > > > > > > is > > > > > > the detailed remap relationship in the "4GB mode": > > > > > > CPU PA ->HW PA > > > > > > 0x4000_ 0x1_4000_ (Add bit32) > > > > > > 0x8000_ 0x1_8000_ ... > > > > > > 0xc000_ 0x1_c000_ ... > > > > > > 0x1__0x1__ (No change) > > [...] > > > > > > The way I would like this quirk to work is that the io-pgtable code > > > > > basically sets bit 9 in the pte when bit 32 is set in the physical > > > > > address, > > > > > and sets bit 4 in the pte when bit 33 is set in the physical address. > > > > > It > > > > > would then do the opposite when converting a pte to a physical > > > > > address. > > > > > > > > > > That way, your driver can call the page table code directly with the > > > > > high > > > > > addresses and we don't have to do any manual offsetting or range > > > > > checking > > > > > in the page table code. > > > > > > > > In this case, the mt8183 can work successfully while the "4gb > > > > mode"(mt8173/mt2712) can not. > > > > > > > > In the "4gb mode", As the remap relationship above, we should always add > > > > bit32 in pte as we did in [2]. and need add bit32 in the > > > > "iova_to_phys"(Not always add.). That means the "4gb mode" has a special > > > > flow: > > > > a. Always add bit32 in paddr_to_iopte. > > > > b. Add bit32 only when PA < 0x4000 in iopte_to_paddr. > > > > > > I think this is probably at the heart of my misunderstanding. What is so > > > special about PAs (is this HW PA or CPU PA?) below 0x4000? Is this RAM > > > or something else? > > > > SRAM and HW register that IOMMU can not access. > > Ok, so redrawing your table from above, I think we can say something like: > > > CPU Physical address > > > 0G1G 2G 3G 4G 5G > |---A---|---B---|---C---|---D---|---E---| > +--I/O--+Memory-+ > > > IOMMU output physical address > = > > 4G 5G 6G 7G 8G > |---E---|---B---|---C---|---D---| > +Memory-+ > > > Do you agree? Quite right. > If so, what happens to region 'A' (the I/O region) in the > IOMMU output physical address space. Is it accessible? No. IOMMU can not access region 'A' above. > > Anyway, I think it's the job of the driver to convert between the two > address spaces, so that: > > - On ->map(), bit 32 of the CPU physical address is set before calling > into the iopgtable code > > - The result from ->iova_to_phys() should be the result from the > iopgtable code, but with the top bit cleared for addresses over > 5G. > > This assumes that: > > 1. We're ok setting bit 9 in the ptes mapping region 'E'. > 2. The IOMMU page-table walker uses CPU physical addresses > > Are those true? Yes. Then this patch would be close to the one[1] I sent in v8. Do I need to split this patch into 2 ones?: a).the pagetable code that support 34bit PA when MTK quirk is enabled. It only has the symmetric code handle BIT32/BIT33. Besides, I will add CONFIG_PHYS_ADDR_T_64BIT in the iopte_to_addr as commented before. b) MTK code that apply the special "4gb mode" flow. And the "oas" will always is 34 bit since v7s has already supported our case. [1]http://lists.infradead.org/pipermail/linux-mediatek/2019-June/020991.html > > Thanks, > > Will
[PATCH 10/10] arm: dts: mediatek: add mt7629 pwm support
From: sam shih This adds pwm support for MT7629. Signed-off-by: Sam Shih --- arch/arm/boot/dts/mt7629.dtsi | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/mt7629.dtsi b/arch/arm/boot/dts/mt7629.dtsi index 9608bc2ccb3f..10f788a93346 100644 --- a/arch/arm/boot/dts/mt7629.dtsi +++ b/arch/arm/boot/dts/mt7629.dtsi @@ -241,6 +241,22 @@ status = "disabled"; }; + pwm: pwm@11006000 { + compatible = "mediatek,mt7629-pwm", +"mediatek,mt7622-pwm"; + reg = <0 0x11006000 0 0x1000>; + interrupts = ; + clocks = <&topckgen CLK_TOP_PWM_SEL>, +<&pericfg CLK_PERI_PWM_PD>, +<&pericfg CLK_PERI_PWM1_PD>; + clock-names = "top", "main", "pwm1"; + assigned-clocks = <&topckgen CLK_TOP_PWM_SEL>; + assigned-clock-parents = + <&topckgen CLK_TOP_UNIVPLL2_D4>; + num-pwms = <1>; + status = "disabled"; + }; + i2c: i2c@11007000 { compatible = "mediatek,mt7629-i2c", "mediatek,mt2712-i2c"; -- 2.17.1
[PATCH v3 9/10] dt-bindings: pwm: update bindings for MT7628 SoC
From: sam shih This updates bindings for MT7628 pwm controller. Signed-off-by: Sam Shih --- Documentation/devicetree/bindings/pwm/pwm-mediatek.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt index c7bd5633d1eb..bfdc438ae4d3 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-mediatek.txt @@ -21,6 +21,9 @@ Required properties: - pinctrl-0: One property must exist for each entry in pinctrl-names. See pinctrl/pinctrl-bindings.txt for details of the property values. - num-pwms: the number of PWM channels. + Optional properties: + - clock-frequency: fix clock frequency, this is only used in MT7628 SoC +for period calculation. This SoC has no complex clock tree. Example: pwm0: pwm@11006000 { -- 2.17.1
Re: [PATCH] dmaengine: ti: omap-dma: Add cleanup in omap_dma_probe()
On 16/08/2019 9.56, Wenwen Wang wrote: > If devm_request_irq() fails to disable all interrupts, no cleanup is > performed before retuning the error. To fix this issue, invoke > omap_dma_free() to do the cleanup. Thank you, Acked-by: Peter Ujfalusi > Signed-off-by: Wenwen Wang > --- > drivers/dma/ti/omap-dma.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c > index ba2489d..5158b58 100644 > --- a/drivers/dma/ti/omap-dma.c > +++ b/drivers/dma/ti/omap-dma.c > @@ -1540,8 +1540,10 @@ static int omap_dma_probe(struct platform_device *pdev) > > rc = devm_request_irq(&pdev->dev, irq, omap_dma_irq, > IRQF_SHARED, "omap-dma-engine", od); > - if (rc) > + if (rc) { > + omap_dma_free(od); > return rc; > + } > } > > if (omap_dma_glbl_read(od, CAPS_0) & CAPS_0_SUPPORT_LL123) > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
[PATCH v3 6/10] arm: dts: mt7623: add a property "num-pwms" for PWM node
From: Ryder Lee This adds a property "num-pwms" for PWM controller. Signed-off-by: Ryder Lee Signed-off-by: Sam Shih --- arch/arm/boot/dts/mt7623.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/mt7623.dtsi b/arch/arm/boot/dts/mt7623.dtsi index a79f0b6c3429..208e0d19a575 100644 --- a/arch/arm/boot/dts/mt7623.dtsi +++ b/arch/arm/boot/dts/mt7623.dtsi @@ -452,6 +452,7 @@ <&pericfg CLK_PERI_PWM5>; clock-names = "top", "main", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5"; + num-pwms = <5>; status = "disabled"; }; -- 2.17.1
Re: [PATCH 2/3] x86: cpu: Add new Intel Atom CPU type
On 16/8/2019 2:43 PM, Borislav Petkov wrote: Now to another question: you see how I put my reply to the previous mail *below* the quoted text. Why is yours ontop? Why not put it after mine since you're replying to it, like it is usually done on the mailing lists and thus not confuse the reading order? All I'm trying to say is, please do not top-post. So sorry for missing out on this point. Will always keep in mind from now on. Regards, Rahul
Re: [PATCH v6 03/11] media: uapi: h264: Add the concept of decoding mode
On 8/14/19 9:59 PM, Ezequiel Garcia wrote: > From: Boris Brezillon > > Some stateless decoders don't support per-slice decoding granularity > (or at least not in a way that would make them efficient or easy to use). > > Expose a menu to control the supported decoding modes. Drivers are > allowed to support only one decoding but they can support both too. The commit message doesn't say anything about the start_byte_offset addition and the num_slices documentation improvement. It probably should. See more comments below: > > Signed-off-by: Boris Brezillon > Reviewed-by: Paul Kocialkowski > Tested-by: Philipp Zabel > --- > Changes in v6: > * Fix spec, specifiying the decode-mode pixelformat modifier > needs to be set once, as suggested by Hans. > * Rename, as suggested by Paul. > Changes in v5: > * Improve specification as suggested by Hans. > Changes in v4: > * Typos/rewording fixes > Changes in v3: > * s/per-{slice,frame} decoding/{slice,frame}-based decoding/ > * Add Paul's R-b > Changes in v2: > * Allow decoding multiple slices in per-slice decoding mode > * Minor doc improvement/fixes > --- > .../media/uapi/v4l/ext-ctrls-codec.rst| 47 ++- > .../media/uapi/v4l/pixfmt-compressed.rst | 6 ++- > drivers/media/v4l2-core/v4l2-ctrls.c | 9 > include/media/h264-ctrls.h| 10 > 4 files changed, 69 insertions(+), 3 deletions(-) > > diff --git a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst > b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst > index c5f39dd50043..623b34f61b32 100644 > --- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst > +++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst > @@ -1747,6 +1747,11 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - > * - __u32 >- ``size`` >- > +* - __u32 > + - ``start_byte_offset`` > +Offset (in bytes) from the beginning of the OUTPUT buffer to the > start > +of the slice. If the slice starts with a start code, then this is the > +offset to such start code. This should mention that it should be set to 0 for SLICE_BASED decoding mode. > * - __u32 >- ``header_bit_size`` >- > @@ -1930,7 +1935,10 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - >- > * - __u16 >- ``num_slices`` > - - Number of slices needed to decode the current frame > + - Number of slices needed to decode the current frame/field. When > +operating in slice-based decoding mode (see > +:c:type:`v4l2_mpeg_video_h264_decode_mode`), this field > +should always be set to one. > * - __u16 >- ``nal_ref_idc`` >- NAL reference ID value coming from the NAL Unit header > @@ -2021,6 +2029,43 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - >- 0x0004 >- The DPB entry is a long term reference frame > > +``V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE (enum)`` > +Specifies the decoding mode to use. Currently exposes slice-based and > +frame-based decoding but new modes might be added later on. > +This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE > +pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE > +are required to set this control in order to specify the decoding mode > +that is expected for the buffer. > +Drivers may expose a single or multiple decoding modes, depending > +on what they can support. > + > +.. note:: > + > + This menu control is not yet part of the public kernel API and > + it is expected to change. > + > +.. c:type:: v4l2_mpeg_video_h264_decode_mode > + > +.. cssclass:: longtable > + > +.. flat-table:: > +:header-rows: 0 > +:stub-columns: 0 > +:widths: 1 1 2 > + > +* - ``V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED`` > + - 0 > + - Decoding is done at the slice granularity. > +v4l2_ctrl_h264_decode_params->num_slices should be set to 1. And start_byte_offset should be set to 0. > +The OUTPUT buffer must contain a single slice. > +* - ``V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED`` > + - 1 > + - Decoding is done at the frame granularity. > +v4l2_ctrl_h264_decode_params->num_slices should be set to the number > of > +slices forming a frame. And start_byte_offset should be filled in accordingly for each slice. Regards, Hans > +The OUTPUT buffer must contain all slices needed to decode the > +frame. The OUTPUT buffer must also contain both fields. > + > .. _v4l2-mpeg-mpeg2: > > ``V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (struct)`` > diff --git a/Documentation/media/uapi/v4l/pixfmt-compressed.rst > b/Documentation/media/uapi/v4l/pixfmt-compressed.rst > index 9b65473a2288..d666eb51741a 100644 > --- a/Documentation/media/uapi/v4l/pixfmt-compressed.rst > +++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst > @@ -60,8 +60,10 @@ Compressed Formats >
Re: [PATCH v3 1/10] pwm: mediatek: add a property "num-pwms"
On Fri, Aug 16, 2019 at 03:21:19PM +0800, Sam Shih wrote: > From: Ryder Lee > > This adds a property "num-pwms" to avoid having an endless > list of compatibles with no differences for the same driver. > > Signed-off-by: Ryder Lee > Signed-off-by: Sam Shih > --- > drivers/pwm/pwm-mediatek.c | 35 ++- > 1 file changed, 22 insertions(+), 13 deletions(-) > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c > index eb6674ce995f..f9d67fb66adb 100644 > --- a/drivers/pwm/pwm-mediatek.c > +++ b/drivers/pwm/pwm-mediatek.c > @@ -55,7 +55,7 @@ static const char * const mtk_pwm_clk_name[MTK_CLK_MAX] = { > }; > > struct mtk_pwm_platform_data { > - unsigned int num_pwms; > + unsigned int fallback_npwms; > bool pwm45_fixup; > bool has_clks; > }; > @@ -226,27 +226,36 @@ static const struct pwm_ops mtk_pwm_ops = { > > static int mtk_pwm_probe(struct platform_device *pdev) > { > - const struct mtk_pwm_platform_data *data; > + struct device_node *np = pdev->dev.of_node; > struct mtk_pwm_chip *pc; > struct resource *res; > - unsigned int i; > + unsigned int i, npwms; > int ret; > > pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); > if (!pc) > return -ENOMEM; > > - data = of_device_get_match_data(&pdev->dev); > - if (data == NULL) > - return -EINVAL; > - pc->soc = data; > + pc->soc = of_device_get_match_data(&pdev->dev); Droping the check for of_device_get_match_data returning non-NULL is unrelated to the official patch's topic. Other than that I like this patch. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH] libnvdimm: change disk name of virtio pmem disk
> > > > This patch adds prefix 'v' in disk name for virtio pmem. > > This differentiates virtio-pmem disks from the pmem disks. > > I don't think the small matter that this device does not support > MAP_SYNC warrants a separate naming scheme. That said I do think we > need to export this attribute in sysfs, likely at the region level, > and then display that information in ndctl. This is distinct from the > btt case where it is operating a different data consistency contract > than baseline pmem. o.k. I will look to add the information in sysfs and display using ndctl. Thanks, Pankaj > > > > Signed-off-by: Pankaj Gupta > > --- > > drivers/nvdimm/namespace_devs.c | 6 +- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/nvdimm/namespace_devs.c > > b/drivers/nvdimm/namespace_devs.c > > index a16e52251a30..8e5d29266fb0 100644 > > --- a/drivers/nvdimm/namespace_devs.c > > +++ b/drivers/nvdimm/namespace_devs.c > > @@ -182,8 +182,12 @@ const char *nvdimm_namespace_disk_name(struct > > nd_namespace_common *ndns, > > char *name) > > { > > struct nd_region *nd_region = to_nd_region(ndns->dev.parent); > > + const char *prefix = ""; > > const char *suffix = NULL; > > > > + if (!is_nvdimm_sync(nd_region)) > > + prefix = "v"; > > + > > if (ndns->claim && is_nd_btt(ndns->claim)) > > suffix = "s"; > > > > @@ -201,7 +205,7 @@ const char *nvdimm_namespace_disk_name(struct > > nd_namespace_common *ndns, > > sprintf(name, "pmem%d.%d%s", nd_region->id, nsidx, > > suffix ? suffix : ""); > > else > > - sprintf(name, "pmem%d%s", nd_region->id, > > + sprintf(name, "%spmem%d%s", prefix, nd_region->id, > > suffix ? suffix : ""); > > } else if (is_namespace_blk(&ndns->dev)) { > > struct nd_namespace_blk *nsblk; > > -- > > 2.20.1 > > >
Re: [PATCH 2/3] x86: cpu: Add new Intel Atom CPU type
On Fri, Aug 16, 2019 at 03:25:51PM +0800, Tanwar, Rahul wrote: > > On 16/8/2019 2:43 PM, Borislav Petkov wrote: > > Now to another question: you see how I put my reply to the previous mail > > *below* the quoted text. Why is yours ontop? Why not put it after mine > > since you're replying to it, like it is usually done on the mailing > > lists and thus not confuse the reading order? > > > > All I'm trying to say is, please do not top-post. > > So sorry for missing out on this point. Will always keep in mind from now > on. Thanks! -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Re: [PATCH v6 07/11] media: cedrus: Specify H264 startcode and decoding mode
On 8/14/19 9:59 PM, Ezequiel Garcia wrote: > The cedrus VPU is slice-based and expects V4L2_PIX_FMT_H264_SLICE > buffers to contain H264 slices with no start code. > > Expose this to userspace with the newly added menu control. > > These two controls are specified as mandatory for applications, > but we mark them as non-required on the driver side for > backwards compatibility. > > Signed-off-by: Ezequiel Garcia > --- > Changes in v6: > * Adjust to control renames. > Changes in v5: > * Clarify commit log. > Changes in v4: > * New patch. > --- > drivers/staging/media/sunxi/cedrus/cedrus.c | 20 > 1 file changed, 20 insertions(+) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c > b/drivers/staging/media/sunxi/cedrus/cedrus.c > index 7bdc413bf727..69a836aa11ef 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c > @@ -77,6 +77,26 @@ static const struct cedrus_control cedrus_controls[] = { > .codec = CEDRUS_CODEC_H264, > .required = true, > }, > + { > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE, > + .max= V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED, > + .def= V4L2_MPEG_VIDEO_H264_DECODE_MODE_SLICE_BASED, > + .menu_skip_mask = > BIT(V4L2_MPEG_VIDEO_H264_DECODE_MODE_FRAME_BASED), You don't need this: DECODE_MODE_FRAME_BASED > DECODE_MODE_SLICE_BASED (the max value). So no need to set the skip_mask since it is out of range. > + }, > + .codec = CEDRUS_CODEC_H264, > + .required = false, > + }, > + { > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_H264_START_CODE, > + .max= V4L2_MPEG_VIDEO_H264_START_CODE_NONE, > + .def= V4L2_MPEG_VIDEO_H264_START_CODE_NONE, > + .menu_skip_mask = > BIT(V4L2_MPEG_VIDEO_H264_START_CODE_ANNEX_B), Ditto. Regards, Hans > + }, > + .codec = CEDRUS_CODEC_H264, > + .required = false, > + }, > }; > > #define CEDRUS_CONTROLS_COUNTARRAY_SIZE(cedrus_controls) >
Re: [PATCH v6 09/11] media: hantro: Add core bits to support H264 decoding
On 8/14/19 9:59 PM, Ezequiel Garcia wrote: > From: Hertz Wong > > Add helpers and patch hantro_{drv,v4l2}.c to prepare addition of H264 > decoding support. > > Signed-off-by: Hertz Wong > Signed-off-by: Boris Brezillon > Tested-by: Philipp Zabel > --- > Changes in v6: > * Fixed duplicated CABAC table memcpy. > * Adjust to renamed controls. > Changes in v5: > * None. > Changes in v4: > * Rework extra_size0, exposing the size via TRY_FMT/S_FMT > to allow buffer importation, as suggested by Tomasz. > * Drop max slice limit. > * Use a ternary operator instead of substracting POCs, > to avoid an overflow as pointed out by Rasmus. > * Specify annex B slice start code. > * Add missing extra_size0 to sizeimage > * Swap the first 2 entries of list B1 when B0 and B1 match (mandated by > the spec) > * Move the update_dpb() call before the prepare_table() one to make the > POCs stored in the private table match the content of the new DPB > --- > drivers/staging/media/hantro/Makefile | 1 + > drivers/staging/media/hantro/hantro.h | 9 +- > drivers/staging/media/hantro/hantro_drv.c | 42 ++ > drivers/staging/media/hantro/hantro_h264.c | 641 + > drivers/staging/media/hantro/hantro_hw.h | 55 ++ > drivers/staging/media/hantro/hantro_v4l2.c | 10 + > 6 files changed, 757 insertions(+), 1 deletion(-) > create mode 100644 drivers/staging/media/hantro/hantro_h264.c > > diff --git a/drivers/staging/media/hantro/Makefile > b/drivers/staging/media/hantro/Makefile > index f5ec597d9e08..0f0d3afb1cca 100644 > --- a/drivers/staging/media/hantro/Makefile > +++ b/drivers/staging/media/hantro/Makefile > @@ -10,6 +10,7 @@ hantro-vpu-y += \ > rk3399_vpu_hw_mpeg2_dec.o \ > rk3399_vpu_hw_vp8_dec.o \ > hantro_jpeg.o \ > + hantro_h264.o \ > hantro_mpeg2.o \ > hantro_vp8.o > > diff --git a/drivers/staging/media/hantro/hantro.h > b/drivers/staging/media/hantro/hantro.h > index c4c86c32ea2d..f670bbde4159 100644 > --- a/drivers/staging/media/hantro/hantro.h > +++ b/drivers/staging/media/hantro/hantro.h > @@ -30,6 +30,10 @@ > #define VP8_MB_WIDTH(w) DIV_ROUND_UP(w, VP8_MB_DIM) > #define VP8_MB_HEIGHT(h) DIV_ROUND_UP(h, VP8_MB_DIM) > > +#define H264_MB_DIM 16 > +#define H264_MB_WIDTH(w) DIV_ROUND_UP(w, H264_MB_DIM) > +#define H264_MB_HEIGHT(h)DIV_ROUND_UP(h, H264_MB_DIM) > + > #define MPEG2_MB_DIM 16 > #define MPEG2_MB_WIDTH(w)DIV_ROUND_UP(w, MPEG2_MB_DIM) > #define MPEG2_MB_HEIGHT(h) DIV_ROUND_UP(h, MPEG2_MB_DIM) > @@ -43,9 +47,9 @@ struct hantro_codec_ops; > > #define HANTRO_JPEG_ENCODER BIT(0) > #define HANTRO_ENCODERS 0x > - > #define HANTRO_MPEG2_DECODER BIT(16) > #define HANTRO_VP8_DECODER BIT(17) > +#define HANTRO_H264_DECODER BIT(18) > #define HANTRO_DECODERS 0x > > /** > @@ -102,12 +106,14 @@ struct hantro_variant { > * enum hantro_codec_mode - codec operating mode. > * @HANTRO_MODE_NONE: No operating mode. Used for RAW video formats. > * @HANTRO_MODE_JPEG_ENC: JPEG encoder. > + * @HANTRO_MODE_H264_DEC: H264 decoder. > * @HANTRO_MODE_MPEG2_DEC: MPEG-2 decoder. > * @HANTRO_MODE_VP8_DEC: VP8 decoder. > */ > enum hantro_codec_mode { > HANTRO_MODE_NONE = -1, > HANTRO_MODE_JPEG_ENC, > + HANTRO_MODE_H264_DEC, > HANTRO_MODE_MPEG2_DEC, > HANTRO_MODE_VP8_DEC, > }; > @@ -246,6 +252,7 @@ struct hantro_ctx { > > /* Specific for particular codec modes. */ > union { > + struct hantro_h264_dec_hw_ctx h264_dec; > struct hantro_jpeg_enc_hw_ctx jpeg_enc; > struct hantro_mpeg2_dec_hw_ctx mpeg2_dec; > struct hantro_vp8_dec_hw_ctx vp8_dec; > diff --git a/drivers/staging/media/hantro/hantro_drv.c > b/drivers/staging/media/hantro/hantro_drv.c > index 6e2351e46750..f4cea216c926 100644 > --- a/drivers/staging/media/hantro/hantro_drv.c > +++ b/drivers/staging/media/hantro/hantro_drv.c > @@ -314,6 +314,48 @@ static const struct hantro_ctrl controls[] = { > .cfg = { > .id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER, > }, > + }, { > + .codec = HANTRO_H264_DECODER, > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, > + }, > + }, { > + .codec = HANTRO_H264_DECODER, > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, > + }, > + }, { > + .codec = HANTRO_H264_DECODER, > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_H264_SPS, > + }, > + }, { > + .codec = HANTRO_H264_DECODER, > + .cfg = { > + .id = V4L2_CID_MPEG_VIDEO_H264_PPS, > + }, > + }, { > +
Re: [PATCH v4 1/3] kasan: support backing vmalloc space with real shadow memory
Le 15/08/2019 à 02:16, Daniel Axtens a écrit : Hook into vmalloc and vmap, and dynamically allocate real shadow memory to back the mappings. Most mappings in vmalloc space are small, requiring less than a full page of shadow space. Allocating a full shadow page per mapping would therefore be wasteful. Furthermore, to ensure that different mappings use different shadow pages, mappings would have to be aligned to KASAN_SHADOW_SCALE_SIZE * PAGE_SIZE. Instead, share backing space across multiple mappings. Allocate a backing page the first time a mapping in vmalloc space uses a particular page of the shadow region. Keep this page around regardless of whether the mapping is later freed - in the mean time the page could have become shared by another vmalloc mapping. This can in theory lead to unbounded memory growth, but the vmalloc allocator is pretty good at reusing addresses, so the practical memory usage grows at first but then stays fairly stable. I guess people having gigabytes of memory don't mind, but I'm concerned about tiny targets with very little amount of memory. I have boards with as little as 32Mbytes of RAM. The shadow region for the linear space already takes one eighth of the RAM. I'd rather avoid keeping unused shadow pages busy. Each page of shadow memory represent 8 pages of real memory. Could we use page_ref to count how many pieces of a shadow page are used so that we can free it when the ref count decreases to 0. This requires architecture support to actually use: arches must stop mapping the read-only zero page over portion of the shadow region that covers the vmalloc space and instead leave it unmapped. Why 'must' ? Couldn't we switch back and forth from the zero page to real page on demand ? If the zero page is not mapped for unused vmalloc space, bad memory accesses will Oops on the shadow memory access instead of Oopsing on the real bad access, making it more difficult to locate and identify the issue. This allows KASAN with VMAP_STACK, and will be needed for architectures that do not have a separate module space (e.g. powerpc64, which I am currently working on). It also allows relaxing the module alignment back to PAGE_SIZE. Why 'needed' ? powerpc32 doesn't have a separate module space and doesn't need that. Link: https://bugzilla.kernel.org/show_bug.cgi?id=202009 Acked-by: Vasily Gorbik Signed-off-by: Daniel Axtens [Mark: rework shadow allocation] Signed-off-by: Mark Rutland -- v2: let kasan_unpoison_shadow deal with ranges that do not use a full shadow byte. v3: relax module alignment rename to kasan_populate_vmalloc which is a much better name deal with concurrency correctly v4: Integrate Mark's rework Poision pages on vfree Handle allocation failures. I've tested this by inserting artificial failures and using test_vmalloc to stress it. I haven't handled the per-cpu case: it looked like it would require a messy hacking-up of the function to deal with an OOM failure case in a debug feature. --- Documentation/dev-tools/kasan.rst | 60 +++ include/linux/kasan.h | 24 +++ include/linux/moduleloader.h | 2 +- include/linux/vmalloc.h | 12 ++ lib/Kconfig.kasan | 16 lib/test_kasan.c | 26 mm/kasan/common.c | 67 +++ mm/kasan/generic_report.c | 3 ++ mm/kasan/kasan.h | 1 + mm/vmalloc.c | 28 - 10 files changed, 237 insertions(+), 2 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index b72d07d70239..35fda484a672 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -215,3 +215,63 @@ brk handler is used to print bug reports. A potential expansion of this mode is a hardware tag-based mode, which would use hardware memory tagging support instead of compiler instrumentation and manual shadow memory manipulation. + +What memory accesses are sanitised by KASAN? + + +The kernel maps memory in a number of different parts of the address +space. This poses something of a problem for KASAN, which requires +that all addresses accessed by instrumented code have a valid shadow +region. + +The range of kernel virtual addresses is large: there is not enough +real memory to support a real shadow region for every address that +could be accessed by the kernel. + +By default +~~ + +By default, architectures only map real memory over the shadow region +for the linear mapping (and potentially other small areas). For all +other areas - such as vmalloc and vmemmap space - a single read-only +page is mapped over the shadow area. This read-only shadow page +declares all memory accesses as permitted. + +This presents a problem for modules: they do not
Re: [PATCH v2 2/3] arm64: allwinner: h6: add I2C nodes
On Fri, Aug 16, 2019 at 12:17:09PM +0530, Bhushan Shah wrote: > Add device-tree nodes for i2c0 to i2c2, and also add relevant pinctrl > nodes. > > Suggested-by: Icenowy Zheng > Signed-off-by: Bhushan Shah > --- > Changes in v2: > - Add the SoC specific compatible string instead of re-using a31 one. > > arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 56 +++- > 1 file changed, 55 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > index bcecca17d61d..a1a329926540 100644 > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > @@ -329,6 +329,21 @@ > function = "hdmi"; > }; > > + i2c0_pins: i2c0-pins { > + pins = "PD25", "PD26"; > + function = "i2c0"; > + }; > + > + i2c1_pins: i2c1-pins { > + pins = "PH5", "PH6"; > + function = "i2c1"; > + }; > + > + i2c2_pins: i2c2-pins { > + pins = "PD23", "PD24"; > + function = "i2c2"; > + }; > + > mmc0_pins: mmc0-pins { > pins = "PF0", "PF1", "PF2", "PF3", > "PF4", "PF5"; > @@ -464,6 +479,45 @@ > status = "disabled"; > }; > > + i2c0: i2c@5002000 { > + compatible = "allwinner,sun50i-h6-i2c"; This isn't going to work if you don't patch the driver to add the compatible. And this isn't what you described in the binding patch. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com signature.asc Description: PGP signature
Re: [PATCH v2 3/3] arm64: allwinner: h6: add i2c0 node in PineH64
65;5603;1c On Fri, Aug 16, 2019 at 12:17:10PM +0530, Bhushan Shah wrote: > i2c0 bus is exposed by PI-2 BUS in the PineH64, model B. > > Signed-off-by: Bhushan Shah > --- > Changes in v2: > - Don't enable the i2c0 node in PineH64 by default > > arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts > b/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts > index 684d1daa3081..97d9b7c63fb3 100644 > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts > @@ -160,6 +160,15 @@ > vcc-pg-supply = <®_aldo1>; > }; > > +/* This i2c interface is exposed on PI-2 BUS, Pin 3 (I2C_SDA) and 5 > (I2C_SCL) */ > +&i2c0 { > + status = "disabled"; > +}; This property is set to disabled in the DTSI already > +&i2c0_pins { > + bias-pull-up; > +}; > + And this should be in the same overlay than the one that sets status to okay. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com signature.asc Description: PGP signature
[PATCH] powerpc/32: Add warning on misaligned copy_page() or clear_page()
copy_page() and clear_page() expect page aligned destination, and use dcbz instruction to clear entire cache lines based on the assumption that the destination is cache aligned. As shown during analysis of a bug in BTRFS filesystem, a misaligned copy_page() can create bugs that are difficult to locate (see Link). Add an explicit WARNING when copy_page() or clear_page() are called with misaligned destination. Signed-off-by: Christophe Leroy Cc: Erhard F. Link: https://bugzilla.kernel.org/show_bug.cgi?id=204371 --- arch/powerpc/include/asm/page_32.h | 4 arch/powerpc/kernel/misc_32.S | 5 + 2 files changed, 9 insertions(+) diff --git a/arch/powerpc/include/asm/page_32.h b/arch/powerpc/include/asm/page_32.h index 683dfbc67ca8..d64dfe3ac712 100644 --- a/arch/powerpc/include/asm/page_32.h +++ b/arch/powerpc/include/asm/page_32.h @@ -40,6 +40,8 @@ typedef unsigned long long pte_basic_t; typedef unsigned long pte_basic_t; #endif +#include + /* * Clear page using the dcbz instruction, which doesn't cause any * memory traffic (except to write out any cache lines which get @@ -49,6 +51,8 @@ static inline void clear_page(void *addr) { unsigned int i; + WARN_ON((unsigned long)addr & (L1_CACHE_BYTES - 1)); + for (i = 0; i < PAGE_SIZE / L1_CACHE_BYTES; i++, addr += L1_CACHE_BYTES) dcbz(addr); } diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S index fe4bd321730e..02d90e1ebf65 100644 --- a/arch/powerpc/kernel/misc_32.S +++ b/arch/powerpc/kernel/misc_32.S @@ -452,7 +452,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) stwur9,16(r3) _GLOBAL(copy_page) + rlwinm r5, r3, 0, L1_CACHE_BYTES - 1 addir3,r3,-4 + +0: twnei r5, 0 /* WARN if r3 is not cache aligned */ + EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING + addir4,r4,-4 li r5,4 -- 2.13.3
RE: [PATCH] rtw88: pci: Move a mass of jobs in hw IRQ to soft IRQ
> From: Jian-Hong Pan [mailto:jian-h...@endlessm.com] > > There is a mass of jobs between spin lock and unlock in the hardware > IRQ which will occupy much time originally. To make system work more > efficiently, this patch moves the jobs to the soft IRQ (bottom half) to > reduce the time in hardware IRQ. > > Signed-off-by: Jian-Hong Pan > --- > drivers/net/wireless/realtek/rtw88/pci.c | 36 +++- > 1 file changed, 29 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtw88/pci.c > b/drivers/net/wireless/realtek/rtw88/pci.c > index 00ef229552d5..355606b167c6 100644 > --- a/drivers/net/wireless/realtek/rtw88/pci.c > +++ b/drivers/net/wireless/realtek/rtw88/pci.c > @@ -866,12 +866,29 @@ static irqreturn_t rtw_pci_interrupt_handler(int irq, > void *dev) > { > struct rtw_dev *rtwdev = dev; > struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; > - u32 irq_status[4]; > + unsigned long flags; > > - spin_lock(&rtwpci->irq_lock); > + spin_lock_irqsave(&rtwpci->irq_lock, flags); > if (!rtwpci->irq_enabled) > goto out; > > + /* disable RTW PCI interrupt to avoid more interrupts before the end of > + * thread function > + */ > + rtw_pci_disable_interrupt(rtwdev, rtwpci); > +out: > + spin_unlock_irqrestore(&rtwpci->irq_lock, flags); > + > + return IRQ_WAKE_THREAD; > +} > + > +static irqreturn_t rtw_pci_interrupt_threadfn(int irq, void *dev) > +{ > + struct rtw_dev *rtwdev = dev; > + struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; > + unsigned long flags; > + u32 irq_status[4]; > + > rtw_pci_irq_recognized(rtwdev, rtwpci, irq_status); > > if (irq_status[0] & IMR_MGNTDOK) > @@ -891,8 +908,11 @@ static irqreturn_t rtw_pci_interrupt_handler(int irq, > void *dev) > if (irq_status[0] & IMR_ROK) > rtw_pci_rx_isr(rtwdev, rtwpci, RTW_RX_QUEUE_MPDU); > > -out: > - spin_unlock(&rtwpci->irq_lock); > + /* all of the jobs for this interrupt have been done */ > + spin_lock_irqsave(&rtwpci->irq_lock, flags); Shouldn't we protect the ISRs above? This patch could actually reduce the time of IRQ. But I think I need to further test it with PCI MSI interrupt. https://patchwork.kernel.org/patch/11081539/ Maybe we could drop the "rtw_pci_[enable/disable]_interrupt" when MSI Is enabled with this patch. > + if (rtw_flag_check(rtwdev, RTW_FLAG_RUNNING)) > + rtw_pci_enable_interrupt(rtwdev, rtwpci); > + spin_unlock_irqrestore(&rtwpci->irq_lock, flags); > > return IRQ_HANDLED; > } > @@ -1152,8 +1172,10 @@ static int rtw_pci_probe(struct pci_dev *pdev, > goto err_destroy_pci; > } > > - ret = request_irq(pdev->irq, &rtw_pci_interrupt_handler, > - IRQF_SHARED, KBUILD_MODNAME, rtwdev); > + ret = devm_request_threaded_irq(rtwdev->dev, pdev->irq, > + rtw_pci_interrupt_handler, > + rtw_pci_interrupt_threadfn, > + IRQF_SHARED, KBUILD_MODNAME, rtwdev); > if (ret) { > ieee80211_unregister_hw(hw); > goto err_destroy_pci; > @@ -1192,7 +1214,7 @@ static void rtw_pci_remove(struct pci_dev *pdev) > rtw_pci_disable_interrupt(rtwdev, rtwpci); > rtw_pci_destroy(rtwdev, pdev); > rtw_pci_declaim(rtwdev, pdev); > - free_irq(rtwpci->pdev->irq, rtwdev); > + devm_free_irq(rtwdev->dev, rtwpci->pdev->irq, rtwdev); > rtw_core_deinit(rtwdev); > ieee80211_free_hw(hw); > } > -- > 2.20.1 Yan-Hsuan
答复: [PATCH] ubifs: ubifs_tnc_start_commit: Fix OOB in layout_in_gaps
> ubifs_assert(c, p < c->gap_lebs + c->lst.idx_lebs); I've done 50 problem reproduces on different flash devices and made sure that the assertion was not triggered. See record.txt for details. -邮件原件- 发件人: chengzhihao 发送时间: 2019年8月14日 9:20 收件人: 'Richard Weinberger' 抄送: Richard Weinberger ; Sascha Hauer ; Artem Bityutskiy ; zhangyi (F) ; linux-...@lists.infradead.org; LKML 主题: 答复: [PATCH] ubifs: ubifs_tnc_start_commit: Fix OOB in layout_in_gaps Sure, I'll do more tests on different machines to check the assertion. I'm trying to understand when this assertion will be triggered. Although I haven't found this assertion be triggered so far in several tests on x86_64(qemu). -邮件原件- 发件人: Richard Weinberger [mailto:richard.weinber...@gmail.com] 发送时间: 2019年8月14日 5:44 收件人: chengzhihao 抄送: Richard Weinberger ; Sascha Hauer ; Artem Bityutskiy ; zhangyi (F) ; linux-...@lists.infradead.org; LKML 主题: Re: [PATCH] ubifs: ubifs_tnc_start_commit: Fix OOB in layout_in_gaps On Tue, Jul 30, 2019 at 3:21 AM chengzhihao wrote: > > OK, that's fine, and I will continue to understand more implementation code > related to this part. I think we can go with the realloc() approach for now. Can you please check whether the assert() triggers? -- Thanks, //richard No Log Config 1 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 2 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 9 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 3 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 9 nandsim: 16MiB, PEB size 16KiB, page size 512KiB, VID offset 0, fastmap enabled, volume size 11MiB 4 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 5 c->lst.idx_lebs[origin] = 5, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 6 c->lst.idx_lebs[origin] = 5, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 8 nandsim: 16MiB, PEB size 16KiB, page size 512KiB, VID offset 0, fastmap enabled, volume size 11MiB 7 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 8 c->lst.idx_lebs[origin] = 5, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 8 nandsim: 16MiB, PEB size 16KiB, page size 512KiB, VID offset 0, fastmap enabled, volume size 11MiB 9 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 10 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 11 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 12 c->lst.idx_lebs[origin] = 3, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 10 nandsim: 16MiB, PEB size 16KiB, page size 512KiB, VID offset 0, fastmap enabled, volume size 11MiB 13 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 14 c->lst.idx_lebs[origin] = 5, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 15 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 16 c->lst.idx_lebs[origin] = 5, c->lst.idx_lebs[curr] = 12, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 17 c->lst.idx_lebs[origin] = 4, c->lst.idx_lebs[curr] = 11, p - c->gap_lebs = 8 mtdram: 16MiB, PEB size 16KiB, fastmap enabled, volume size 11MiB 18 c->lst.idx_lebs[origin] = 6, c->lst.idx_lebs[curr] = 13, p - c->gap_lebs = 8 nandsim: 16MiB, PEB size 16KiB, page size 512KiB, VID offset 0, fastmap enabled, volume size 11MiB 19 c->lst.idx_lebs[origin] = 5, c-
Re: [PATCH v4 3/3] x86/kasan: support KASAN_VMALLOC
Le 15/08/2019 à 02:16, Daniel Axtens a écrit : In the case where KASAN directly allocates memory to back vmalloc space, don't map the early shadow page over it. If early shadow page is not mapped, any bad memory access will Oops on the shadow access instead of Oopsing on the real bad access. You should still map early shadow page, and replace it with real page when needed. Christophe We prepopulate pgds/p4ds for the range that would otherwise be empty. This is required to get it synced to hardware on boot, allowing the lower levels of the page tables to be filled dynamically. Acked-by: Dmitry Vyukov Signed-off-by: Daniel Axtens --- v2: move from faulting in shadow pgds to prepopulating --- arch/x86/Kconfig| 1 + arch/x86/mm/kasan_init_64.c | 61 + 2 files changed, 62 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 222855cc0158..40562cc3771f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -134,6 +134,7 @@ config X86 select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_JUMP_LABEL_RELATIVE select HAVE_ARCH_KASAN if X86_64 + select HAVE_ARCH_KASAN_VMALLOC if X86_64 select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS if MMU select HAVE_ARCH_MMAP_RND_COMPAT_BITS if MMU && COMPAT diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 296da58f3013..2f57c4ddff61 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c @@ -245,6 +245,52 @@ static void __init kasan_map_early_shadow(pgd_t *pgd) } while (pgd++, addr = next, addr != end); } +static void __init kasan_shallow_populate_p4ds(pgd_t *pgd, + unsigned long addr, + unsigned long end, + int nid) +{ + p4d_t *p4d; + unsigned long next; + void *p; + + p4d = p4d_offset(pgd, addr); + do { + next = p4d_addr_end(addr, end); + + if (p4d_none(*p4d)) { + p = early_alloc(PAGE_SIZE, nid, true); + p4d_populate(&init_mm, p4d, p); + } + } while (p4d++, addr = next, addr != end); +} + +static void __init kasan_shallow_populate_pgds(void *start, void *end) +{ + unsigned long addr, next; + pgd_t *pgd; + void *p; + int nid = early_pfn_to_nid((unsigned long)start); + + addr = (unsigned long)start; + pgd = pgd_offset_k(addr); + do { + next = pgd_addr_end(addr, (unsigned long)end); + + if (pgd_none(*pgd)) { + p = early_alloc(PAGE_SIZE, nid, true); + pgd_populate(&init_mm, pgd, p); + } + + /* +* we need to populate p4ds to be synced when running in +* four level mode - see sync_global_pgds_l4() +*/ + kasan_shallow_populate_p4ds(pgd, addr, next, nid); + } while (pgd++, addr = next, addr != (unsigned long)end); +} + + #ifdef CONFIG_KASAN_INLINE static int kasan_die_handler(struct notifier_block *self, unsigned long val, @@ -352,9 +398,24 @@ void __init kasan_init(void) shadow_cpu_entry_end = (void *)round_up( (unsigned long)shadow_cpu_entry_end, PAGE_SIZE); + /* +* If we're in full vmalloc mode, don't back vmalloc space with early +* shadow pages. Instead, prepopulate pgds/p4ds so they are synced to +* the global table and we can populate the lower levels on demand. +*/ +#ifdef CONFIG_KASAN_VMALLOC + kasan_shallow_populate_pgds( + kasan_mem_to_shadow((void *)PAGE_OFFSET + MAXMEM), + kasan_mem_to_shadow((void *)VMALLOC_END)); + + kasan_populate_early_shadow( + kasan_mem_to_shadow((void *)VMALLOC_END + 1), + shadow_cpu_entry_begin); +#else kasan_populate_early_shadow( kasan_mem_to_shadow((void *)PAGE_OFFSET + MAXMEM), shadow_cpu_entry_begin); +#endif kasan_populate_shadow((unsigned long)shadow_cpu_entry_begin, (unsigned long)shadow_cpu_entry_end, 0);
Re: [v2] rtc: pcf85363/pcf85263: fix error that failed to run hwclock -w
On 16/08/2019 10:46:36+0800, Biwen Li wrote: > Issue: > - # hwclock -w > hwclock: RTC_SET_TIME: Invalid argument > > Why: > - Relative patch: https://lkml.org/lkml/2019/4/3/55 , this patch > will always check for unwritable registers, it will compare reg > with max_register in regmap_writeable. > > - In drivers/rtc/rtc-pcf85363.c, CTRL_STOP_EN is 0x2e, but DT_100THS > is 0, max_regiter is 0x2f, then reg will be equal to 0x30, > '0x30 < 0x2f' is false,so regmap_writeable will return false. > > - Root cause: the buf[] was written to a wrong place in the file > drivers/rtc/rtc-pcf85363.c > This is not true, the RTC wraps the register accesses properly and this is probably something that should be handled by regmap_writable. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v3 01/14] PCI/P2PDMA: Introduce private pagemap structure
Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 02/14] PCI/P2PDMA: Add provider's pci_dev to pci_p2pdma_pagemap struct
On Mon, Aug 12, 2019 at 11:30:36AM -0600, Logan Gunthorpe wrote: > The provider will be needed to figure out how to map a device. > > Link: https://lore.kernel.org/r/20190730163545.4915-3-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas Looks good, Reviewed-by: Christoph Hellwig
RE: [PATCH] rtw88: pci: Move a mass of jobs in hw IRQ to soft IRQ
Hi, A few more questions below > > From: Jian-Hong Pan [mailto:jian-h...@endlessm.com] > > > > There is a mass of jobs between spin lock and unlock in the hardware > > IRQ which will occupy much time originally. To make system work more > > efficiently, this patch moves the jobs to the soft IRQ (bottom half) to > > reduce the time in hardware IRQ. > > > > Signed-off-by: Jian-Hong Pan > > --- > > drivers/net/wireless/realtek/rtw88/pci.c | 36 +++- > > 1 file changed, 29 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/net/wireless/realtek/rtw88/pci.c > > b/drivers/net/wireless/realtek/rtw88/pci.c > > index 00ef229552d5..355606b167c6 100644 > > --- a/drivers/net/wireless/realtek/rtw88/pci.c > > +++ b/drivers/net/wireless/realtek/rtw88/pci.c > > @@ -866,12 +866,29 @@ static irqreturn_t rtw_pci_interrupt_handler(int > irq, > > void *dev) > > { > > struct rtw_dev *rtwdev = dev; > > struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; > > - u32 irq_status[4]; > > + unsigned long flags; > > > > - spin_lock(&rtwpci->irq_lock); > > + spin_lock_irqsave(&rtwpci->irq_lock, flags); I think you can use 'spin_lock()' here as it's in IRQ context? > > if (!rtwpci->irq_enabled) > > goto out; > > > > + /* disable RTW PCI interrupt to avoid more interrupts before the end of > > +* thread function > > +*/ > > + rtw_pci_disable_interrupt(rtwdev, rtwpci); Why do we need rtw_pci_disable_interrupt() here. Have you done any experiment and decided to add this. If you have can you share your results to me? > > +out: > > + spin_unlock_irqrestore(&rtwpci->irq_lock, flags); spin_unlock() > > + > > + return IRQ_WAKE_THREAD; > > +} > > + > > +static irqreturn_t rtw_pci_interrupt_threadfn(int irq, void *dev) > > +{ > > + struct rtw_dev *rtwdev = dev; > > + struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; > > + unsigned long flags; > > + u32 irq_status[4]; > > + > > rtw_pci_irq_recognized(rtwdev, rtwpci, irq_status); > > > > if (irq_status[0] & IMR_MGNTDOK) > > @@ -891,8 +908,11 @@ static irqreturn_t rtw_pci_interrupt_handler(int > irq, > > void *dev) > > if (irq_status[0] & IMR_ROK) > > rtw_pci_rx_isr(rtwdev, rtwpci, RTW_RX_QUEUE_MPDU); > > > > -out: > > - spin_unlock(&rtwpci->irq_lock); > > + /* all of the jobs for this interrupt have been done */ > > + spin_lock_irqsave(&rtwpci->irq_lock, flags); > > Shouldn't we protect the ISRs above? > > This patch could actually reduce the time of IRQ. > But I think I need to further test it with PCI MSI interrupt. > https://patchwork.kernel.org/patch/11081539/ > > Maybe we could drop the "rtw_pci_[enable/disable]_interrupt" when MSI > Is enabled with this patch. > > > + if (rtw_flag_check(rtwdev, RTW_FLAG_RUNNING)) > > + rtw_pci_enable_interrupt(rtwdev, rtwpci); > > + spin_unlock_irqrestore(&rtwpci->irq_lock, flags); > > > > return IRQ_HANDLED; > > } > > @@ -1152,8 +1172,10 @@ static int rtw_pci_probe(struct pci_dev *pdev, > > goto err_destroy_pci; > > } > > > > - ret = request_irq(pdev->irq, &rtw_pci_interrupt_handler, > > - IRQF_SHARED, KBUILD_MODNAME, rtwdev); > > + ret = devm_request_threaded_irq(rtwdev->dev, pdev->irq, > > + rtw_pci_interrupt_handler, > > + rtw_pci_interrupt_threadfn, > > + IRQF_SHARED, KBUILD_MODNAME, rtwdev); > > if (ret) { > > ieee80211_unregister_hw(hw); > > goto err_destroy_pci; > > @@ -1192,7 +1214,7 @@ static void rtw_pci_remove(struct pci_dev > *pdev) > > rtw_pci_disable_interrupt(rtwdev, rtwpci); > > rtw_pci_destroy(rtwdev, pdev); > > rtw_pci_declaim(rtwdev, pdev); > > - free_irq(rtwpci->pdev->irq, rtwdev); > > + devm_free_irq(rtwdev->dev, rtwpci->pdev->irq, rtwdev); > > rtw_core_deinit(rtwdev); > > ieee80211_free_hw(hw); > > } > > -- > > 2.20.1 > > Yan-Hsuan > Thanks Yan-Hsuan
Re: [PATCH v3 03/14] PCI/P2PDMA: Add constants for map type results to upstream_bridge_distance()
On Mon, Aug 12, 2019 at 11:30:37AM -0600, Logan Gunthorpe wrote: > Add constant flags to indicate how two devices will be mapped or if they > are unsupported. upstream_bridge_distance() will now return the > mapping type and the distance in a passed-by-reference argument. > > This helps annotate the code better, but the main reason is so we can use > the information to store the required mapping method in an xarray. > > Link: https://lore.kernel.org/r/20190730163545.4915-4-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas > Reviewed-by: Christian König Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 04/14] PCI/P2PDMA: Factor out __upstream_bridge_distance()
On Mon, Aug 12, 2019 at 11:30:38AM -0600, Logan Gunthorpe wrote: > This is a prep patch to create a second level helper. There are no > functional changes. > > The root complex whitelist code will be moved into this function in a > subsequent patch. > > Link: https://lore.kernel.org/r/20190730163545.4915-5-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas > Reviewed-by: Christian König Reviewed-by: Christoph Hellwig
[ANN] kdevops - Linux kernel development devops framework
I'd like to announce my first release of kdevops [0] which I am happy to share with the community. The goal behind this project is to provide a modern devops framework for Linux kernel development. It is not a tests suite, it is designed to *use* *any* test suites, and more importantly, it allows us to let us *easily* set up test environments in a jiffie. It supports different virtualization enviornments, and different cloud environments, and supports different Operating Systems. This is all built on top of ansible, vagrant and terraform. There's a few demo projects which shows you how this can be used, one for fstests, and another for selftests. I've provided a bit more of details on my kernel blog [1]. Give it a spin, and send rants / patches my way. [0] https://github.com/mcgrof/kdevops/ [1] https://people.kernel.org/mcgrof/kdevops-a-devops-framework-for-linux-kernel-development Luis signature.asc Description: PGP signature
Re: [PATCH v3 05/14] PCI/P2PDMA: Apply host bridge whitelist for ACS
On Mon, Aug 12, 2019 at 11:30:39AM -0600, Logan Gunthorpe wrote: > When a P2PDMA transfer is rejected due to ACS being set, we can also check > the whitelist and allow the transactions. > > Do this by pushing the whitelist check into the upstream_bridge_distance() > function. > > Link: https://lore.kernel.org/r/20190730163545.4915-6-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas > Reviewed-by: Christian König Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 06/14] PCI/P2PDMA: Factor out host_bridge_whitelist()
On Mon, Aug 12, 2019 at 11:30:40AM -0600, Logan Gunthorpe wrote: > Push both PCI devices into the whitelist checking function seeing some > hardware will require us ensuring they are on the same host bridge. > > At the same time we rename root_complex_whitelist() to > host_bridge_whitelist() to match the terminology used in the code. > > Link: https://lore.kernel.org/r/20190730163545.4915-7-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas Looks good, Reviewed-by: Christoph Hellwig
Re: Bisected: Kernel 4.14 + has 3 times higher write IO latency than Kernel 4.4 with raid1
On Wed, Aug 7, 2019 at 2:35 PM Jinpu Wang wrote: > > On Wed, Aug 7, 2019 at 8:36 AM Jinpu Wang wrote: > > > > On Wed, Aug 7, 2019 at 1:40 AM NeilBrown wrote: > > > > > > On Tue, Aug 06 2019, Jinpu Wang wrote: > > > > > > > On Tue, Aug 6, 2019 at 9:54 AM Jinpu Wang > > > > wrote: > > > >> > > > >> On Tue, Aug 6, 2019 at 1:46 AM NeilBrown wrote: > > > >> > > > > >> > On Mon, Aug 05 2019, Jinpu Wang wrote: > > > >> > > > > >> > > Hi Neil, > > > >> > > > > > >> > > For the md higher write IO latency problem, I bisected it to these > > > >> > > commits: > > > >> > > > > > >> > > 4ad23a97 MD: use per-cpu counter for writes_pending > > > >> > > 210f7cd percpu-refcount: support synchronous switch to atomic mode. > > > >> > > > > > >> > > Do you maybe have an idea? How can we fix it? > > > >> > > > > >> > Hmmm not sure. > > > >> Hi Neil, > > > >> > > > >> Thanks for reply, detailed result in line. > > > > > > Thanks for the extra testing. > > > ... > > > > [ 105.133299] md md0 in_sync is 0, sb_flags 2, recovery 3, external > > > > 0, safemode 0, recovery_cp 524288 > > > ... > > > > > > ahh - the resync was still happening. That explains why set_in_sync() > > > is being called so often. If you wait for sync to complete (or create > > > the array with --assume-clean) you should see more normal behaviour. > > I've updated my tests accordingly, thanks for the hint. > > > > > > This patch should fix it. I think we can do better but it would be more > > > complex so no suitable for backports to -stable. > > > > > > Once you confirm it works, I'll send it upstream with a > > > Reported-and-Tested-by from you. > > > > > > Thanks, > > > NeilBrown > > > > Thanks a lot, Neil, my quick test show, yes, it fixed the problem for me. > > > > I will run more tests to be sure, will report back the test result. > Hi Neil, > > I've run our regression tests with your patch, everything works fine > as expected. > > So Reported-and-Tested-by: Jack Wang > > Thank you for your quick fix. > > The patch should go to stable 4.12+ Hi Neil, I hope you're doing well, just a soft ping? do you need further testing from my side? Please let me know how can we move the fix forward. Thanks, Jack Wang
RE: [PATCH v2 3/9] drm: Rename drm_bridge_timings to drm_timings
Hi Greg, hi Laurent, > From: Greg Kroah-Hartman > Sent: 15 August 2019 20:05 > Subject: Re: [PATCH v2 3/9] drm: Rename drm_bridge_timings to drm_timings > > On Thu, Aug 15, 2019 at 09:06:41PM +0300, Laurent Pinchart wrote: > > Hi Greg, > > > > On Thu, Aug 15, 2019 at 04:53:00PM +0200, Greg Kroah-Hartman wrote: > > > On Thu, Aug 15, 2019 at 02:31:26PM +, Fabrizio Castro wrote: > > > > On 15 August 2019 15:15, Laurent Pinchart wrote: > > > > > On Thu, Aug 15, 2019 at 04:04:00PM +0200, Greg Kroah-Hartman wrote: > > > > > > On Thu, Aug 15, 2019 at 04:18:38PM +0300, Laurent Pinchart wrote: > > > > > > > Hi Fabrizio, > > > > > > > > > > > > > > (CC'ing Greg as the architect of the SPDX move) > > > > > > > > > > > > _one of_, not the one that did the most of he work, that would be > > > > > > Thomas :) > > > > > > > > > > > > > On Thu, Aug 15, 2019 at 12:04:27PM +0100, Fabrizio Castro wrote: > > > > > > > > The information represented by drm_bridge_timings is also > > > > > > > > needed by panels, therefore rename drm_bridge_timings to > > > > > > > > drm_timings. > > > > > > > > > > > > > > > > Signed-off-by: Fabrizio Castro > > > > > > > > Link: > > > > > > > > https://www.spinics.net/lists/linux-renesas-soc/msg43271.html > > > > > > > > > > > > > > > > --- > > > > > > > > v1->v2: > > > > > > > > * new patch > > > > > > > > > > > > > > > > I have copied the license from include/drm/drm_bridge.h as > > > > > > > > that's > > > > > > > > where the struct originally came from. What's the right SPDX > > > > > > > > license > > > > > > > > to use in this case? > > > > > > > > > > > > > > https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files > > > > > > > > > > > > > > Greg, any idea on how we should handle this ? > > > > > > > > > > > > Ugh, what lunacy. But drm_bridge.h is NOT under any "public domain" > > > > > > license, so why is that an issue here? This looks like a "normal" > > > > > > bsd 3 > > > > > > clause license to me, right? > > > > > > > > > > You're right, I overread part of the text in drm_bridge.h, it seems to > > > > > indeed be covered by a BSD 3 clause license. Sorry for the noise. > > > > > > > > Mmm... This is the template for the BSD-3-Clause: > > > > > > > > Copyright (c) , > > > > All rights reserved. > > > > > > > > Redistribution and use in source and binary forms, with or without > > > > modification, are permitted provided that the following > conditions are met: > > > > > > > > Redistributions of source code must retain the above copyright notice, > > > > this list of conditions and the following disclaimer. > > > > Redistributions in binary form must reproduce the above copyright > > > > notice, this list of conditions and the following disclaimer in > the documentation and/or other materials provided with the distribution. > > > > Neither the name of the nor the names of its > > > > contributors may be used to endorse or promote products > derived from this software without specific prior written permission. > > > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS > > > > IS" AND ANY EXPRESS OR IMPLIED > WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF > MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR > CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > LIMITED TO, PROCUREMENT OF > SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > INTERRUPTION) HOWEVER CAUSED AND ON ANY > THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY > WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > SUCH DAMAGE. > > > > > > > > And this is the license coming from include/drm/drm_bridge.h: > > > > > > > > /* > > > > * Copyright (c) 2016 Intel Corporation > > > > * > > > > * Permission to use, copy, modify, distribute, and sell this software > > > > and its > > > > * documentation for any purpose is hereby granted without fee, > > > > provided that > > > > * the above copyright notice appear in all copies and that both that > > > > copyright > > > > * notice and this permission notice appear in supporting > > > > documentation, and > > > > * that the name of the copyright holders not be used in advertising or > > > > * publicity pertaining to distribution of the software without > > > > specific, > > > > * written prior permission. The copyright holders make no > > > > representations > > > > * about the suitability of this software for any purpose. It is > > > > provided "as > > > > * is" without express or implied warranty. > > > > * > > > > * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS > > > > SOFTWARE, > > > > * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN > > > > NO > >
RE: [PATCH net-next] r8152: divide the tx and rx bottom functions
Eric Dumazet [mailto:eric.duma...@gmail.com] > Sent: Friday, August 16, 2019 2:40 PM [...] > tasklet and NAPI are scheduled on the same core (the current > cpu calling napi_schedule() or tasklet_schedule()) > > I would rather not add this dubious tasklet, and instead try to understand > what is wrong in this driver ;) > > The various napi_schedule() calls are suspect IMO. The original method as following. static int r8152_poll(struct napi_struct *napi, int budget) { struct r8152 *tp = container_of(napi, struct r8152, napi); int work_done; work_done = rx_bottom(tp, budget); <-- RX bottom_half(tp); <-- Tx (tx_bottom) [...] The rx_bottom and tx_bottom would only be called in r8152_poll. That is, tx_bottom wouldn't be run unless rx_bottom is finished. And, rx_bottom would be called if tx_bottom is running. If the traffic is busy. rx_bottom or tx_bottom may take a lot of time to deal with the packets. And the one would increase the latency time for the other one. Therefore, when I separate the tx_bottom and rx_bottom to different tasklet and napi, the callback functions of tx and rx may schedule the tasklet and napi to different cpu. Then, the rx_bottom and tx_bottom may be run at the same time. Take our arm platform for example. There are five cpus to handle the interrupt of USB host controller. When the rx is completed, cpu #1 may handle the interrupt and napi would be scheduled. When the tx is finished, cpu #2 may handle the interrupt and the tasklet is scheduled. Then, napi is run on cpu #1, and tasklet is run on cpu #2. > Also rtl8152_start_xmit() uses skb_queue_tail(&tp->tx_queue, skb); > > But I see nothing really kicking the transmit if tx_free is empty ? Tx callback function "write_bulk_callback" would deal with it. The callback function would check if there are packets waiting to be sent. Best Regards, Hayes
Re: [PATCH v3 07/14] PCI/P2PDMA: Whitelist some Intel host bridges
Looks good, Reviewed-by: Christoph Hellwig
[PATCH net-next 1/6] net: hns3: add or modify comments
From: Guojia Liao To explain some code, this patch adds some comments, and modifies or merges some comments to make them more neat. Signed-off-by: Guojia Liao Signed-off-by: Zhongzhu Liu Signed-off-by: Weihang Li Signed-off-by: Guangbin Huang Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hnae3.h| 12 ++-- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 8 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h| 8 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 8 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 9 - 8 files changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 6c9fd58..3e21533 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -85,10 +85,10 @@ struct hnae3_queue { void __iomem *io_base; struct hnae3_ae_algo *ae_algo; struct hnae3_handle *handle; - int tqp_index; /* index in a handle */ - u32 buf_size; /* size for hnae_desc->addr, preset by AE */ - u16 tx_desc_num;/* total number of tx desc */ - u16 rx_desc_num;/* total number of rx desc */ + int tqp_index; /* index in a handle */ + u32 buf_size; /* size for hnae_desc->addr, preset by AE */ + u16 tx_desc_num;/* total number of tx desc */ + u16 rx_desc_num;/* total number of rx desc */ }; struct hns3_mac_stats { @@ -96,7 +96,7 @@ struct hns3_mac_stats { u64 rx_pause_cnt; }; -/*hnae3 loop mode*/ +/* hnae3 loop mode */ enum hnae3_loop { HNAE3_LOOP_APP, HNAE3_LOOP_SERIAL_SERDES, @@ -621,7 +621,7 @@ struct hnae3_handle { struct pci_dev *pdev; void *priv; struct hnae3_ae_algo *ae_algo; /* the class who provides this handle */ - u64 flags; /* Indicate the capabilities for this handle*/ + u64 flags; /* Indicate the capabilities for this handle */ union { struct net_device *netdev; /* first member */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 1750f80..a11d514 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -229,9 +229,9 @@ static void hns3_vector_gl_rl_init(struct hns3_enet_tqp_vector *tqp_vector, /* initialize the configuration for interrupt coalescing. * 1. GL (Interrupt Gap Limiter) * 2. RL (Interrupt Rate Limiter) +* +* Default: enable interrupt coalescing self-adaptive and GL */ - - /* Default: enable interrupt coalescing self-adaptive and GL */ tqp_vector->tx_group.coal.gl_adapt_enable = 1; tqp_vector->rx_group.coal.gl_adapt_enable = 1; @@ -4207,8 +4207,8 @@ int hns3_nic_reset_all_ring(struct hnae3_handle *h) static void hns3_store_coal(struct hns3_nic_priv *priv) { /* ethtool only support setting and querying one coal -* configuation for now, so save the vector 0' coal -* configuation here in order to restore it. +* configuration for now, so save the vector 0' coal +* configuration here in order to restore it. */ memcpy(&priv->tx_coal, &priv->tqp_vector[0].tx_group.coal, sizeof(struct hns3_enet_coalesce)); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 5b0ee1f..e37e64e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -302,7 +302,7 @@ struct hns3_desc_cb { dma_addr_t dma; /* dma address of this desc */ void *buf; /* cpu addr for a desc */ - /* priv data for the desc, e.g. skb when use with ip stack*/ + /* priv data for the desc, e.g. skb when use with ip stack */ void *priv; u32 page_offset; u32 length; /* length of the buffer */ @@ -325,11 +325,11 @@ enum hns3_pkt_l3type { HNS3_L3_TYPE_MAC_PAUSE, HNS3_L3_TYPE_PFC_PAUSE,/* 0x9*/ - /* reserved for 0xA~0xB*/ + /* reserved for 0xA~0xB */ HNS3_L3_TYPE_CNM = 0xc, - /* reserved for 0xD~0xE*/ + /* reserved for 0xD~0xE */ HNS3_L3_TYPE_PARSE_FAIL = 0xf /* must be last */ }; @@ -354,7 +354,7 @@ enum hns3_pkt_ol3type { HNS3_OL3_TYPE_IPV4_OPT = 4, HNS3_OL3_TYPE_IPV6_EXT, - /* reserved for 0x6~0xE*/ + /* reserved for 0x6~0xE */ HNS3_OL3_TYPE_PARSE_FAIL = 0xf /* must be last */ }; diff --git a/drivers/net/ethernet/hisilic
[PATCH net-next 4/6] net: hns3: change print level of RAS error log from warning to error
From: Xiaofei Tan This patch changes print level of RAS error log from warning to error. Because RAS error and its recovery process could cause application failure. Also uses %u instead of %d when the parameter is unsigned. Signed-off-by: Xiaofei Tan Signed-off-by: Weihang Li Signed-off-by: Huazhong Tan --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 88 +++--- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index 5ce9a8a..2425b3f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -637,8 +637,8 @@ static void hclge_log_error(struct device *dev, char *reg, { while (err->msg) { if (err->int_msk & err_sts) { - dev_warn(dev, "%s %s found [error status=0x%x]\n", -reg, err->msg, err_sts); + dev_err(dev, "%s %s found [error status=0x%x]\n", + reg, err->msg, err_sts); if (err->reset_level && err->reset_level != HNAE3_NONE_RESET) set_bit(err->reset_level, reset_requests); @@ -1163,8 +1163,8 @@ static int hclge_handle_mpf_ras_error(struct hclge_dev *hdev, status = le32_to_cpu(*(desc_data + 3)) & BIT(0); if (status) { - dev_warn(dev, "SSU_ECC_MULTI_BIT_INT_1 ssu_mem32_ecc_mbit_err found [error status=0x%x]\n", -status); + dev_err(dev, "SSU_ECC_MULTI_BIT_INT_1 ssu_mem32_ecc_mbit_err found [error status=0x%x]\n", + status); set_bit(HNAE3_GLOBAL_RESET, &ae_dev->hw_err_reset_req); } @@ -1200,8 +1200,8 @@ static int hclge_handle_mpf_ras_error(struct hclge_dev *hdev, desc_data = (__le32 *)&desc[5]; status = le32_to_cpu(*(desc_data + 1)); if (status) { - dev_warn(dev, "PPU_MPF_ABNORMAL_INT_ST1 %s found\n", -"rpu_rx_pkt_ecc_mbit_err"); + dev_err(dev, + "PPU_MPF_ABNORMAL_INT_ST1 rpu_rx_pkt_ecc_mbit_err found\n"); set_bit(HNAE3_GLOBAL_RESET, &ae_dev->hw_err_reset_req); } @@ -1379,17 +1379,17 @@ static int hclge_log_rocee_axi_error(struct hclge_dev *hdev) return ret; } - dev_info(dev, "AXI1: %08X %08X %08X %08X %08X %08X\n", -le32_to_cpu(desc[0].data[0]), le32_to_cpu(desc[0].data[1]), -le32_to_cpu(desc[0].data[2]), le32_to_cpu(desc[0].data[3]), -le32_to_cpu(desc[0].data[4]), le32_to_cpu(desc[0].data[5])); - dev_info(dev, "AXI2: %08X %08X %08X %08X %08X %08X\n", -le32_to_cpu(desc[1].data[0]), le32_to_cpu(desc[1].data[1]), -le32_to_cpu(desc[1].data[2]), le32_to_cpu(desc[1].data[3]), -le32_to_cpu(desc[1].data[4]), le32_to_cpu(desc[1].data[5])); - dev_info(dev, "AXI3: %08X %08X %08X %08X\n", -le32_to_cpu(desc[2].data[0]), le32_to_cpu(desc[2].data[1]), -le32_to_cpu(desc[2].data[2]), le32_to_cpu(desc[2].data[3])); + dev_err(dev, "AXI1: %08X %08X %08X %08X %08X %08X\n", + le32_to_cpu(desc[0].data[0]), le32_to_cpu(desc[0].data[1]), + le32_to_cpu(desc[0].data[2]), le32_to_cpu(desc[0].data[3]), + le32_to_cpu(desc[0].data[4]), le32_to_cpu(desc[0].data[5])); + dev_err(dev, "AXI2: %08X %08X %08X %08X %08X %08X\n", + le32_to_cpu(desc[1].data[0]), le32_to_cpu(desc[1].data[1]), + le32_to_cpu(desc[1].data[2]), le32_to_cpu(desc[1].data[3]), + le32_to_cpu(desc[1].data[4]), le32_to_cpu(desc[1].data[5])); + dev_err(dev, "AXI3: %08X %08X %08X %08X\n", + le32_to_cpu(desc[2].data[0]), le32_to_cpu(desc[2].data[1]), + le32_to_cpu(desc[2].data[2]), le32_to_cpu(desc[2].data[3])); return 0; } @@ -1408,12 +1408,12 @@ static int hclge_log_rocee_ecc_error(struct hclge_dev *hdev) return ret; } - dev_info(dev, "ECC1: %08X %08X %08X %08X %08X %08X\n", -le32_to_cpu(desc[0].data[0]), le32_to_cpu(desc[0].data[1]), -le32_to_cpu(desc[0].data[2]), le32_to_cpu(desc[0].data[3]), -le32_to_cpu(desc[0].data[4]), le32_to_cpu(desc[0].data[5])); - dev_info(dev, "ECC2: %08X %08X %08X\n", le32_to_cpu(desc[1].data[0]), -le32_to_cpu(desc[1].data[1]), le32_to_cpu(desc[1].data[2])); + dev_err(dev, "ECC1: %08X %08X %08X %08X %08X %08X\n", + le32_to_cpu(desc[0].data[0]), le32_to_cpu(desc[0].data[1]), + le32_to_cpu(desc[0].data[2]), le32_to_cpu(desc[0].data[3]), + le32_to_cpu(desc[0].data[4]), le32_to_cpu(desc[0].data[5])); + dev_er
[PATCH net-next 6/6] net: hns3: add phy_attached_info() to the hns3 driver
From: Yonglong Liu This patch adds the call to phy_attached_info() to the hns3 driver to identify which exact PHY drivers and models is in use. Signed-off-by: Yonglong Liu Reviewed-by: Yunsheng Lin Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c index abb1b43..dc4dfd4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c @@ -231,6 +231,8 @@ int hclge_mac_connect_phy(struct hnae3_handle *handle) linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->advertising); + phy_attached_info(phydev); + return 0; } -- 2.7.4
[PATCH net-next 5/6] net: hns3: prevent unnecessary MAC TNL interrupt
MAC TNL interrupt is used to collect statistic info about link status changing suddenly when netdev is running. But when stopping netdev, the enabled MAC TNL interrupt is unnecessary, and may add some noises to the statistic info. So this patch disables it before stopping MAC. Fixes: a63457878b12 ("net: hns3: Add handling of MAC tunnel interruption") Signed-off-by: Huazhong Tan Reviewed-by: Yunsheng Lin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 24b59f0..9d64c43 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6380,6 +6380,8 @@ static void hclge_ae_stop(struct hnae3_handle *handle) for (i = 0; i < handle->kinfo.num_tqps; i++) hclge_reset_tqp(handle, i); + hclge_config_mac_tnl_int(hdev, false); + /* Mac disable */ hclge_cfg_mac_mode(hdev, false); -- 2.7.4
[PATCH net-next 3/6] net: hns3: fix error and incorrect format
From: Guojia Liao The pointer type parameter should be declare as const for preventing from its pointed value being unexpected modified. The uninitialized variable can not be return directly. The default return value is 0 if no abnormal result. This patch fixes the preceding two errors, deletes redundant declaration of a function and align one parameter. Signed-off-by: Guojia Liao Signed-off-by: Weihang Li Signed-off-by: Jian Shen Signed-off-by: Guangbin Huang Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 6bbba15..528f624 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -46,7 +46,7 @@ void hnae3_set_client_init_flag(struct hnae3_client *client, EXPORT_SYMBOL(hnae3_set_client_init_flag); static int hnae3_get_client_init_flag(struct hnae3_client *client, - struct hnae3_ae_dev *ae_dev) + struct hnae3_ae_dev *ae_dev) { int inited = 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 4260653..0332d6f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -704,7 +704,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev, return 0; } -static int hns3_check_ksettings_param(struct net_device *netdev, +static int hns3_check_ksettings_param(const struct net_device *netdev, const struct ethtool_link_ksettings *cmd) { struct hnae3_handle *handle = hns3_get_handle(netdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 1d8dee1..24b59f0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1128,6 +1128,7 @@ static void hclge_parse_link_mode(struct hclge_dev *hdev, u8 speed_ability) else if (media_type == HNAE3_MEDIA_TYPE_BACKPLANE) hclge_parse_backplane_link_mode(hdev, speed_ability); } + static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc) { struct hclge_cfg_param_cmd *req; @@ -4364,8 +4365,8 @@ int hclge_bind_ring_with_vector(struct hclge_vport *vport, struct hclge_dev *hdev = vport->back; struct hnae3_ring_chain_node *node; struct hclge_desc desc; - struct hclge_ctrl_vector_chain_cmd *req - = (struct hclge_ctrl_vector_chain_cmd *)desc.data; + struct hclge_ctrl_vector_chain_cmd *req = + (struct hclge_ctrl_vector_chain_cmd *)desc.data; enum hclge_cmd_status status; enum hclge_opcode_type op; u16 tqp_type_and_id; @@ -8656,7 +8657,7 @@ static int hclge_init_client_instance(struct hnae3_client *client, } } - return ret; + return 0; clear_nic: hdev->nic_client = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index f6d9b57..7c28933 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -1000,7 +1000,6 @@ int hclge_buffer_alloc(struct hclge_dev *hdev); int hclge_rss_init_hw(struct hclge_dev *hdev); void hclge_rss_indir_init_cfg(struct hclge_dev *hdev); -int hclge_inform_reset_assert_to_vf(struct hclge_vport *vport); void hclge_mbx_handler(struct hclge_dev *hdev); int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id); void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id); -- 2.7.4
[PATCH net-next 2/6] net: hns3: modify redundant initialization of variable
From: Guojia Liao Some temporary variables do not need to be initialized that they will be set before used, so this patch deletes the initialization value of these temporary variables. Signed-off-by: Guojia Liao Signed-off-by: Guangbin Huang Signed-off-by: Huzhong Tan --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 7 +++ drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c| 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c| 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 908d4f4..6bbba15 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -104,7 +104,6 @@ int hnae3_register_client(struct hnae3_client *client) { struct hnae3_client *client_tmp; struct hnae3_ae_dev *ae_dev; - int ret = 0; if (!client) return -ENODEV; @@ -123,7 +122,7 @@ int hnae3_register_client(struct hnae3_client *client) /* if the client could not be initialized on current port, for * any error reasons, move on to next available port */ - ret = hnae3_init_client_instance(client, ae_dev); + int ret = hnae3_init_client_instance(client, ae_dev); if (ret) dev_err(&ae_dev->pdev->dev, "match and instantiation failed for port, ret = %d\n", @@ -164,7 +163,7 @@ void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) const struct pci_device_id *id; struct hnae3_ae_dev *ae_dev; struct hnae3_client *client; - int ret = 0; + int ret; if (!ae_algo) return; @@ -258,7 +257,7 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) const struct pci_device_id *id; struct hnae3_ae_algo *ae_algo; struct hnae3_client *client; - int ret = 0; + int ret; if (!ae_dev) return -ENODEV; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 677bfe06..4260653 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -749,7 +749,7 @@ static int hns3_set_link_ksettings(struct net_device *netdev, { struct hnae3_handle *handle = hns3_get_handle(netdev); const struct hnae3_ae_ops *ops = handle->ae_algo->ops; - int ret = 0; + int ret; /* Chip don't support this mode. */ if (cmd->base.speed == SPEED_1000 && cmd->base.duplex == DUPLEX_HALF) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index 05a4cdb..5ce9a8a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -1557,8 +1557,8 @@ int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en) static void hclge_handle_rocee_ras_error(struct hnae3_ae_dev *ae_dev) { - enum hnae3_reset_type reset_type = HNAE3_NONE_RESET; struct hclge_dev *hdev = ae_dev->priv; + enum hnae3_reset_type reset_type; if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) || hdev->pdev->revision < 0x21) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index f30d112..e829101 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -404,8 +404,8 @@ static int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev) { struct hclge_port_shapping_cmd *shap_cfg_cmd; struct hclge_desc desc; - u32 shapping_para = 0; u8 ir_u, ir_b, ir_s; + u32 shapping_para; int ret; ret = hclge_shaper_para_calc(hdev->hw.mac.speed, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c index 55d3c78..4c2c945 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c @@ -43,7 +43,7 @@ static int hclgevf_cmd_csq_clean(struct hclgevf_hw *hw) { struct hclgevf_dev *hdev = container_of(hw, struct hclgevf_dev, hw); struct hclgevf_cmq_ring *csq = &hw->cmq.csq; - int clean = 0; + int clean; u32 head; head = hclgevf_read_dev(hw, HCLGEVF_NIC_CSQ_HEAD_REG); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.
[PATCH net-next 0/6] net: hns3: add some cleanups & bugfix
This patch-set includes cleanups and bugfix for the HNS3 ethernet controller driver. [patch 01/06 - 03/06] adds some cleanups. [patch 04/06] changes the print level of RAS. [patch 05/06] fixes a bug related to MAC TNL. [patch 06/06] adds phy_attached_info(). Guojia Liao (3): net: hns3: add or modify comments net: hns3: modify redundant initialization of variable net: hns3: fix error and incorrect format Huazhong Tan (1): net: hns3: prevent unnecessary MAC TNL interrupt Xiaofei Tan (1): net: hns3: change print level of RAS error log from warning to error Yonglong Liu (1): net: hns3: add phy_attached_info() to the hns3 driver drivers/net/ethernet/hisilicon/hns3/hnae3.c| 9 +-- drivers/net/ethernet/hisilicon/hns3/hnae3.h| 12 +-- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 8 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h| 8 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 3 + .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 90 +++--- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 17 ++-- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h| 1 - .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c| 2 + .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 11 ++- 14 files changed, 89 insertions(+), 84 deletions(-) -- 2.7.4
Re: [PATCH v3 08/14] PCI/P2PDMA: Add attrs argument to pci_p2pdma_map_sg()
On Mon, Aug 12, 2019 at 11:30:42AM -0600, Logan Gunthorpe wrote: > This is to match the dma_map_sg() API which this function will have to call > in an future patch. > > Add a pci_p2pdma_map_sg_attrs() function and helper to call it with no > attributes just like the dma_map_sg() function. > > Link: https://lore.kernel.org/r/20190730163545.4915-9-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 09/14] PCI/P2PDMA: Introduce pci_p2pdma_unmap_sg()
On Mon, Aug 12, 2019 at 11:30:43AM -0600, Logan Gunthorpe wrote: > Add pci_p2pdma_unmap_sg() to the two places that call pci_p2pdma_map_sg(). > > This is a prep patch to introduce correct mappings for p2pdma transactions > that go through the root complex. I personally wouldn't split it from actually adding useful functionality, but that aside this looks ok: Reviewed-by: Christoph Hellwig
Re: [PATCH v3 10/14] PCI/P2PDMA: Factor out __pci_p2pdma_map_sg()
On Mon, Aug 12, 2019 at 11:30:44AM -0600, Logan Gunthorpe wrote: > Factor out the bus-only mapping into its own static function. No > functional changes. The original pci_p2pdma_map_sg_attrs() will be used to > decide whether this is an appropriate way to map. > > Link: https://lore.kernel.org/r/20190730163545.4915-11-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 11/14] PCI/P2PDMA: Store mapping method in an xarray
On Mon, Aug 12, 2019 at 11:30:45AM -0600, Logan Gunthorpe wrote: > When upstream_bridge_distance() is called, store the method required to map > the DMA transfers in an xarray so it can be looked up efficiently on the > hot path in pci_p2pdma_map_sg(). > > Link: https://lore.kernel.org/r/20190730163545.4915-12-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 12/14] PCI/P2PDMA: dma_map() requests that traverse the host bridge
On Mon, Aug 12, 2019 at 11:30:46AM -0600, Logan Gunthorpe wrote: > Any requests that traverse the host bridge will need to be mapped into the > IOMMU, so call dma_map_sg() inside pci_p2pdma_map_sg() when appropriate. > > Similarly, call dma_unmap_sg() inside pci_p2pdma_unmap_sg(). > > Link: https://lore.kernel.org/r/20190730163545.4915-13-log...@deltatee.com > Signed-off-by: Logan Gunthorpe > Signed-off-by: Bjorn Helgaas Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v3 13/14] PCI/P2PDMA: Allow IOMMU for host bridge whitelist
On Mon, Aug 12, 2019 at 11:30:47AM -0600, Logan Gunthorpe wrote: > Now that we map the requests correctly we can remove the iommu_present() > restriction. Looks good, Reviewed-by: Christoph Hellwig
Re: [PATCH v6 2/4] media: stm32-dcmi: trace the supported fourcc/mbus_code
Hi Hugues, On Wed, Aug 14, 2019 at 03:48:51PM +0200, Hugues Fruchet wrote: > Add a trace of the set of supported fourcc/mbus_code which > intersect between DCMI and source sub-device. > > Signed-off-by: Hugues Fruchet > --- > drivers/media/platform/stm32/stm32-dcmi.c | 12 ++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/stm32/stm32-dcmi.c > b/drivers/media/platform/stm32/stm32-dcmi.c > index b462f71..18acecf 100644 > --- a/drivers/media/platform/stm32/stm32-dcmi.c > +++ b/drivers/media/platform/stm32/stm32-dcmi.c > @@ -1447,12 +1447,20 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi) > /* Code supported, have we got this fourcc yet? */ > for (j = 0; j < num_fmts; j++) > if (sd_fmts[j]->fourcc == > - dcmi_formats[i].fourcc) > + dcmi_formats[i].fourcc) { > /* Already available */ > + dev_dbg(dcmi->dev, "Skipping > fourcc/code: %4.4s/0x%x\n", > + (char *)&sd_fmts[j]->fourcc, > + mbus_code.code); > break; > - if (j == num_fmts) > + } > + if (j == num_fmts) { > /* New */ > sd_fmts[num_fmts++] = dcmi_formats + i; > + dev_dbg(dcmi->dev, "Supported fourcc/code: > %4.4s/0x%x\n", Over 80 characters per line. > + (char *)&sd_fmts[num_fmts - 1]->fourcc, > + sd_fmts[num_fmts - 1]->mbus_code); > + } > } > mbus_code.index++; > } -- Regards, Sakari Ailus sakari.ai...@linux.intel.com
Re: [PATCH v3 14/14] PCI/P2PDMA: Update pci_p2pdma_distance_many() documentation
On Mon, Aug 12, 2019 at 11:30:48AM -0600, Logan Gunthorpe wrote: > The comment describing pci_p2pdma_distance_many() still referred to > the devices being behind the same root port. This no longer applies > so reword the documentation. Looks good, Reviewed-by: Christoph Hellwig
[PATCH v2 0/3] x86/cpu: Add new Airmont CPU model
A forthcoming product uses a new variant of Atom Airmont CPU model. This series adds support for this new CPU model. Patches are baselined upon Linux 5.3-rc4 at below Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core v2: * Address review concerns about incorrect patch prefixes & redundant comments. * Improve summary in cover letter and commit messages. Rahul Tanwar (3): x86/cpu: Use constant definitions for CPU type x86/cpu: Add new Intel Atom CPU model name x86/cpu: Update init data for new Atom CPU model arch/x86/include/asm/intel-family.h | 1 + arch/x86/kernel/cpu/common.c| 1 + arch/x86/kernel/cpu/intel.c | 7 --- arch/x86/kernel/tsc_msr.c | 5 + 4 files changed, 11 insertions(+), 3 deletions(-) -- 2.11.0
[PATCH v2 1/3] x86/cpu: Use constant definitions for CPU type
Replace direct values usage with constant definitions when access CPU models. Signed-off-by: Rahul Tanwar Suggested-by: Andy Shevchenko --- arch/x86/kernel/cpu/intel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 8d6d92ebeb54..66de4b84c369 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -265,9 +265,9 @@ static void early_init_intel(struct cpuinfo_x86 *c) /* Penwell and Cloverview have the TSC which doesn't sleep on S3 */ if (c->x86 == 6) { switch (c->x86_model) { - case 0x27: /* Penwell */ - case 0x35: /* Cloverview */ - case 0x4a: /* Merrifield */ + case INTEL_FAM6_ATOM_SALTWELL_MID: + case INTEL_FAM6_ATOM_SALTWELL_TABLET: + case INTEL_FAM6_ATOM_SILVERMONT_MID: set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC_S3); break; default: -- 2.11.0
Re: [PATCH 1/2] vsprintf: Prevent crash when dereferencing invalid pointers for %pD
On Fri 2019-08-09 10:56:04, Justin He (Arm Technology China) wrote: > > > > -Original Message- > > From: Andy Shevchenko > > Sent: 2019年8月9日 18:52 > > To: Justin He (Arm Technology China) > > Cc: Petr Mladek ; Andy Shevchenko > > ; Sergey Senozhatsky > > ; Geert Uytterhoeven > > ; Linux Kernel Mailing List > ker...@vger.kernel.org>; Thomas Gleixner ; Steven > > Rostedt (VMware) ; Kees Cook > > ; Shuah Khan ; Tobin C. > > Harding > > Subject: Re: [PATCH 1/2] vsprintf: Prevent crash when dereferencing invalid > > pointers for %pD > > > > On Fri, Aug 9, 2019 at 4:28 AM Jia He wrote: > > > > > > Commit 3e5903eb9cff ("vsprintf: Prevent crash when dereferencing > > invalid > > > pointers") prevents most crash except for %pD. > > > There is an additional pointer dereferencing before dentry_name. > > > > > > At least, vma->file can be NULL and be passed to printk %pD in > > > print_bad_pte, which can cause crash. > > > > > > This patch fixes it with introducing a new file_dentry_name. > > > > > > > Reviewed-by: Andy Shevchenko > > > > Perhaps you need to add a Fixes tag > Thanks, Andy > Fixes: 3e5903eb9cff ("vsprintf: Prevent crash when dereferencing invalid > pointers") I have added the Fixes tag and pushed the patch into printk.git, branch for-5.4. Thanks for the fix. Best Regards, Petr
[PATCH v2 3/3] x86/cpu: Update init data for new Atom CPU model
Update vulnerability init data for the newly added CPU model. Enable setting CPU feature applicable for newly added CPU model. Add TSC MSR freq_desc entry for newly added CPU model. Signed-off-by: Rahul Tanwar --- arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/cpu/intel.c | 1 + arch/x86/kernel/tsc_msr.c| 5 + 3 files changed, 7 insertions(+) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 5cc2d51cc25e..c6b4a578b280 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1059,6 +1059,7 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = { VULNWL_INTEL(CORE_YONAH,NO_SSB), VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF | MSBDS_ONLY | NO_SWAPGS), + VULNWL_INTEL(ATOM_AIRMONT_NP, NO_L1TF | NO_SWAPGS), VULNWL_INTEL(ATOM_GOLDMONT, NO_MDS | NO_L1TF | NO_SWAPGS), VULNWL_INTEL(ATOM_GOLDMONT_X, NO_MDS | NO_L1TF | NO_SWAPGS), diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 66de4b84c369..d618be5ed0e2 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -268,6 +268,7 @@ static void early_init_intel(struct cpuinfo_x86 *c) case INTEL_FAM6_ATOM_SALTWELL_MID: case INTEL_FAM6_ATOM_SALTWELL_TABLET: case INTEL_FAM6_ATOM_SILVERMONT_MID: + case INTEL_FAM6_ATOM_AIRMONT_NP: set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC_S3); break; default: diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c index 067858fe4db8..e0cbe4f2af49 100644 --- a/arch/x86/kernel/tsc_msr.c +++ b/arch/x86/kernel/tsc_msr.c @@ -58,6 +58,10 @@ static const struct freq_desc freq_desc_ann = { 1, { 83300, 10, 133300, 10, 0, 0, 0, 0 } }; +static const struct freq_desc freq_desc_lgm = { + 1, { 78000, 78000, 78000, 78000, 78000, 78000, 78000, 78000 } +}; + static const struct x86_cpu_id tsc_msr_cpu_ids[] = { INTEL_CPU_FAM6(ATOM_SALTWELL_MID, freq_desc_pnw), INTEL_CPU_FAM6(ATOM_SALTWELL_TABLET,freq_desc_clv), @@ -65,6 +69,7 @@ static const struct x86_cpu_id tsc_msr_cpu_ids[] = { INTEL_CPU_FAM6(ATOM_SILVERMONT_MID, freq_desc_tng), INTEL_CPU_FAM6(ATOM_AIRMONT,freq_desc_cht), INTEL_CPU_FAM6(ATOM_AIRMONT_MID,freq_desc_ann), + INTEL_CPU_FAM6(ATOM_AIRMONT_NP, freq_desc_lgm), {} }; -- 2.11.0
Re: [PATCH net-next] r8152: divide the tx and rx bottom functions
On 8/16/19 10:10 AM, Hayes Wang wrote: > Eric Dumazet [mailto:eric.duma...@gmail.com] >> Sent: Friday, August 16, 2019 2:40 PM > [...] >> tasklet and NAPI are scheduled on the same core (the current >> cpu calling napi_schedule() or tasklet_schedule()) >> >> I would rather not add this dubious tasklet, and instead try to understand >> what is wrong in this driver ;) >> >> The various napi_schedule() calls are suspect IMO. > > The original method as following. > > static int r8152_poll(struct napi_struct *napi, int budget) > { > struct r8152 *tp = container_of(napi, struct r8152, napi); > int work_done; > > work_done = rx_bottom(tp, budget); <-- RX > bottom_half(tp); <-- Tx (tx_bottom) > [...] > > The rx_bottom and tx_bottom would only be called in r8152_poll. > That is, tx_bottom wouldn't be run unless rx_bottom is finished. > And, rx_bottom would be called if tx_bottom is running. > > If the traffic is busy. rx_bottom or tx_bottom may take a lot > of time to deal with the packets. And the one would increase > the latency time for the other one. > > Therefore, when I separate the tx_bottom and rx_bottom to > different tasklet and napi, the callback functions of tx and > rx may schedule the tasklet and napi to different cpu. Then, > the rx_bottom and tx_bottom may be run at the same time. Your patch makes absolutely no guarantee of doing what you want, I am afraid. > > Take our arm platform for example. There are five cpus to > handle the interrupt of USB host controller. When the rx is > completed, cpu #1 may handle the interrupt and napi would > be scheduled. When the tx is finished, cpu #2 may handle > the interrupt and the tasklet is scheduled. Then, napi is > run on cpu #1, and tasklet is run on cpu #2. > >> Also rtl8152_start_xmit() uses skb_queue_tail(&tp->tx_queue, skb); >> >> But I see nothing really kicking the transmit if tx_free is empty ? > > Tx callback function "write_bulk_callback" would deal with it. > The callback function would check if there are packets waiting > to be sent. Which callback ? After an idle period (no activity, no prior packets being tx-completed ...), a packet is sent by the upper stack, enters the ndo_start_xmit() of a network driver. This driver ndo_start_xmit() simply adds an skb to a local list, and returns. Where/how is scheduled this callback ? Some kind of timer ? An (unrelated) incoming packet ? > > > Best Regards, > Hayes > >
Re: [PATCH v4 06/10] modpost: Add modinfo flag to livepatch modules
Hi, > I cleaned up the build system, and pushed it based on my > kbuild tree. > > Please see: > > git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git > klp-cleanup This indeed looks much simpler and cleaner (as far as I can judge with my limited kbuild knowledge). We just need to remove MODULE_INFO(livepatch, "Y") from lib/livepatch/test_klp_convert_mod_a.c to make it compile and work (test_klp_convert_mod_a is not a livepatch module, it is just a dummy module which is then livepatched by lib/livepatch/test_klp_convert1.c). Thanks a lot! Miroslav
Re: [PATCH v2 3/3] arm64: allwinner: h6: add i2c0 node in PineH64
On Fri, Aug 16, 2019 at 09:52:11AM +0200, Maxime Ripard wrote: > > +/* This i2c interface is exposed on PI-2 BUS, Pin 3 (I2C_SDA) and 5 > > (I2C_SCL) */ > > +&i2c0 { > > + status = "disabled"; > > +}; > > This property is set to disabled in the DTSI already I added this node here with disabled status due to comment from wens in previous revision, main reason being that serves as reference/pointer to people looking at how to enable i2c0. I can remove it if you prefer. -- Bhushan Shah http://blog.bshah.in IRC Nick : bshah on Freenode GPG key fingerprint : 0AAC 775B B643 7A8D 9AF7 A3AC FE07 8411 7FBC E11D signature.asc Description: PGP signature
Re: WARNING in is_bpf_text_address
On Thu, Aug 15, 2019 at 06:39:56PM -0700, Bart Van Assche wrote: > On 8/15/19 12:51 AM, Will Deacon wrote: > > On Sat, Aug 10, 2019 at 05:24:06PM -0700, syzbot wrote: > > > The bug was bisected to: > > > > > > commit a0b0fd53e1e67639b303b15939b9c653dbe7a8c4 > > > Author: Bart Van Assche > > > Date: Thu Feb 14 23:00:46 2019 + > > > > > > locking/lockdep: Free lock classes that are no longer in use > > > > > > bisection log: > > > https://syzkaller.appspot.com/x/bisect.txt?x=152f6a9da0 > > > final crash: > > > https://syzkaller.appspot.com/x/report.txt?x=172f6a9da0 > > > console output: https://syzkaller.appspot.com/x/log.txt?x=132f6a9da0 > > > > I know you don't think much to these reports, but please could you have a > > look (even if it's just to declare it a false positive)? > > Had you already noticed the following message? > > https://lore.kernel.org/bpf/d76d7a63-7854-e92d-30cb-52546d333...@iogearbox.net/ > > From that message: "Hey Bart, don't think it's related in any way to your > commit. I'll allocate some time on working on this issue today, thanks!" Apologies, but I hadn't received that when I sent my initial email. Anyway, just wanted to make sure somebody was looking into it! Will
Re: [PATCH v2 2/3] arm64: allwinner: h6: add I2C nodes
On Fri, Aug 16, 2019 at 09:50:31AM +0200, Maxime Ripard wrote: > On Fri, Aug 16, 2019 at 12:17:09PM +0530, Bhushan Shah wrote: > > Add device-tree nodes for i2c0 to i2c2, and also add relevant pinctrl > > nodes. > > > > Suggested-by: Icenowy Zheng > > Signed-off-by: Bhushan Shah > > --- > > Changes in v2: > > - Add the SoC specific compatible string instead of re-using a31 one. > > > > arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 56 +++- > > 1 file changed, 55 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > > b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > > index bcecca17d61d..a1a329926540 100644 > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi > > @@ -329,6 +329,21 @@ > > function = "hdmi"; > > }; > > > > + i2c0_pins: i2c0-pins { > > + pins = "PD25", "PD26"; > > + function = "i2c0"; > > + }; > > + > > + i2c1_pins: i2c1-pins { > > + pins = "PH5", "PH6"; > > + function = "i2c1"; > > + }; > > + > > + i2c2_pins: i2c2-pins { > > + pins = "PD23", "PD24"; > > + function = "i2c2"; > > + }; > > + > > mmc0_pins: mmc0-pins { > > pins = "PF0", "PF1", "PF2", "PF3", > >"PF4", "PF5"; > > @@ -464,6 +479,45 @@ > > status = "disabled"; > > }; > > > > + i2c0: i2c@5002000 { > > + compatible = "allwinner,sun50i-h6-i2c"; > > This isn't going to work if you don't patch the driver to add the > compatible. And this isn't what you described in the binding patch. oops, I will correct this in next patch series. Sorry. > > Maxime > > -- > Maxime Ripard, Bootlin > Embedded Linux and Kernel engineering > https://bootlin.com -- Bhushan Shah http://blog.bshah.in IRC Nick : bshah on Freenode GPG key fingerprint : 0AAC 775B B643 7A8D 9AF7 A3AC FE07 8411 7FBC E11D signature.asc Description: PGP signature
[PATCH v2 2/3] x86/cpu: Add new Intel Atom CPU model name
Add a new variant of Intel Atom Airmont CPU model. Signed-off-by: Rahul Tanwar --- arch/x86/include/asm/intel-family.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/intel-family.h b/arch/x86/include/asm/intel-family.h index 0278aa66ef62..cbbb8250370f 100644 --- a/arch/x86/include/asm/intel-family.h +++ b/arch/x86/include/asm/intel-family.h @@ -73,6 +73,7 @@ #define INTEL_FAM6_ATOM_AIRMONT0x4C /* Cherry Trail, Braswell */ #define INTEL_FAM6_ATOM_AIRMONT_MID0x5A /* Moorefield */ +#define INTEL_FAM6_ATOM_AIRMONT_NP 0x75 /* Lightning Mountain */ #define INTEL_FAM6_ATOM_GOLDMONT 0x5C /* Apollo Lake */ #define INTEL_FAM6_ATOM_GOLDMONT_X 0x5F /* Denverton */ -- 2.11.0
Re: [PATCH 2/2] lib/test_printf: add test of null/invalid pointer dereference for dentry
On Fri 2019-08-09 09:24:57, Jia He wrote: > This add some additional test cases of null/invalid pointer dereference > for dentry and file (%pd and %pD) > > Signed-off-by: Jia He > --- > lib/test_printf.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/lib/test_printf.c b/lib/test_printf.c > index 944eb50f3862..befedffeb476 100644 > --- a/lib/test_printf.c > +++ b/lib/test_printf.c > @@ -455,6 +455,13 @@ dentry(void) > test("foo", "%pd", &test_dentry[0]); > test("foo", "%pd2", &test_dentry[0]); > > + /* test the null/invalid pointer case for dentry */ > + test("(null)", "%pd", NULL); > + test("(efault)", "%pd", PTR_INVALID); > + /* test the null/invalid pointer case for file */ The two comments mention something that is obvious from the code. I have pushed the patch as is and removed the comments in a follow up patch [1]. Both are in printk.git, branch for-5.4. > + test("(null)", "%pD", NULL); > + test("(efault)", "%pD", PTR_INVALID); Reference: [1] https://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git/commit/?h=for-5.4&id=8ebea6ea1a7ed5d67ecbb2a493c716a2a89c0be2 Best Regards, Petr
Re: [PATCH v4 4/8] printk: Replace strncmp with str_has_prefix
On Thu 2019-08-15 23:33:01, Chuhong Yuan wrote: > On Thu, Aug 15, 2019 at 9:52 PM Petr Mladek wrote: > > > > On Thu 2019-08-15 16:50:33, Sergey Senozhatsky wrote: > > > On (08/14/19 12:49), Petr Mladek wrote: > > > > On Fri 2019-08-09 15:10:34, Chuhong Yuan wrote: > > > > > strncmp(str, const, len) is error-prone because len > > > > > is easy to have typo. > > > > > The example is the hard-coded len has counting error > > > > > or sizeof(const) forgets - 1. > > > > > So we prefer using newly introduced str_has_prefix() > > > > > to substitute such strncmp to make code better. > > > > > > > > > > Signed-off-by: Chuhong Yuan > > > > > > > > Reviewed-by: Petr Mladek > > > > > > Reviewed-by: Sergey Senozhatsky > > > > Chuong Yuan, should I take this patch via printk.git? Or will > > the entire series go via some other tree, please? > > > > I think that it goes via printk.git is okay, thanks! The patch is commited into printk.git, branch for-5.4. Best Regards, Petr
[PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks
From: Nick Dyer On some firmware variants, the size of the info block exceeds what can be read in a single transfer. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 74c4f5277cfa403d43fafc404119dc57a08677db) [gdavis: Forward port and fix conflicts due to v4.14.51 commit 960fe000b1d3 ("Input: atmel_mxt_ts - fix the firmware update").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 27 +--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 9b165d23e092..2d70ddf71cd9 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -40,7 +40,7 @@ #define MXT_OBJECT_START 0x07 #define MXT_OBJECT_SIZE6 #define MXT_INFO_CHECKSUM_SIZE 3 -#define MXT_MAX_BLOCK_WRITE256 +#define MXT_MAX_BLOCK_WRITE255 /* Object types */ #define MXT_DEBUG_DIAGNOSTIC_T37 37 @@ -659,6 +659,27 @@ static int __mxt_read_reg(struct i2c_client *client, return ret; } +static int mxt_read_blks(struct mxt_data *data, u16 start, u16 count, u8 *buf) +{ + u16 offset = 0; + int error; + u16 size; + + while (offset < count) { + size = min(MXT_MAX_BLOCK_WRITE, count - offset); + + error = __mxt_read_reg(data->client, + start + offset, + size, buf + offset); + if (error) + return error; + + offset += size; + } + + return 0; +} + static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, const void *val) { @@ -1793,7 +1814,7 @@ static int mxt_read_info_block(struct mxt_data *data) id_buf = buf; /* Read rest of info block */ - error = __mxt_read_reg(client, MXT_OBJECT_START, + error = mxt_read_blks(data, MXT_OBJECT_START, size - MXT_OBJECT_START, id_buf + MXT_OBJECT_START); if (error) @@ -2783,7 +2804,7 @@ static ssize_t mxt_object_show(struct device *dev, u16 size = mxt_obj_size(object); u16 addr = object->start_address + j * size; - error = __mxt_read_reg(data->client, addr, size, obuf); + error = mxt_read_blks(data, addr, size, obuf); if (error) goto done; -- 2.19.2
[PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive
input_mt_report_slot_state() ignores the tool when the slot is closed. which has caused a bit of confusion. This patch introduces input_mt_report_slot_inactive() to report slot inactive state. replaces all input_mt_report_slot_state() with input_mt_report_slot_inactive() in case of close of slot, also some other related changes. Signed-off-by: Jiada Wang --- drivers/hid/hid-alps.c | 3 +-- drivers/hid/hid-asus.c | 3 +-- drivers/hid/hid-elan.c | 3 +-- drivers/hid/hid-logitech-hidpp.c| 5 ++--- drivers/hid/hid-magicmouse.c| 3 +-- drivers/hid/hid-multitouch.c| 9 +++-- drivers/hid/hid-sony.c | 8 drivers/hid/wacom_wac.c | 15 +-- drivers/input/input-mt.c| 15 ++- drivers/input/misc/xen-kbdfront.c | 2 +- drivers/input/mouse/elan_i2c_core.c | 2 +- drivers/input/mouse/elantech.c | 5 ++--- drivers/input/mouse/focaltech.c | 3 +-- drivers/input/mouse/sentelic.c | 3 +-- drivers/input/mouse/synaptics.c | 3 +-- drivers/input/rmi4/rmi_2d_sensor.c | 6 ++ drivers/input/touchscreen/atmel_mxt_ts.c| 7 +++ drivers/input/touchscreen/chipone_icn8505.c | 4 ++-- drivers/input/touchscreen/cyttsp4_core.c| 5 ++--- drivers/input/touchscreen/cyttsp_core.c | 2 +- drivers/input/touchscreen/egalax_ts.c | 3 +-- drivers/input/touchscreen/hideep.c | 7 +++ drivers/input/touchscreen/ili210x.c | 3 +-- drivers/input/touchscreen/melfas_mip4.c | 4 ++-- drivers/input/touchscreen/mms114.c | 6 +++--- drivers/input/touchscreen/penmount.c| 5 ++--- drivers/input/touchscreen/raspberrypi-ts.c | 2 +- drivers/input/touchscreen/raydium_i2c_ts.c | 4 ++-- drivers/input/touchscreen/sis_i2c.c | 5 ++--- drivers/input/touchscreen/stmfts.c | 2 +- drivers/input/touchscreen/surface3_spi.c| 4 ++-- drivers/input/touchscreen/wacom_w8001.c | 3 +-- drivers/input/touchscreen/zforce_ts.c | 6 ++ include/linux/input/mt.h| 1 + 34 files changed, 73 insertions(+), 88 deletions(-) diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c index ae79a7c66737..36ca1d815d53 100644 --- a/drivers/hid/hid-alps.c +++ b/drivers/hid/hid-alps.c @@ -387,8 +387,7 @@ static int u1_raw_event(struct alps_dev *hdata, u8 *data, int size) input_report_abs(hdata->input, ABS_MT_PRESSURE, z); } else { - input_mt_report_slot_state(hdata->input, - MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(hdata->input); } } diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 8063b1d567b1..55f1004f0e58 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -240,9 +240,8 @@ static int asus_report_input(struct asus_drvdata *drvdat, u8 *data, int size) MT_TOOL_PALM : MT_TOOL_FINGER; input_mt_slot(drvdat->input, i); - input_mt_report_slot_state(drvdat->input, toolType, down); - if (down) { + if (input_mt_report_slot_state(drvdat->input, toolType, down)) { asus_report_contact_down(drvdat, toolType, contactData); contactData += drvdat->tp->contact_size; } diff --git a/drivers/hid/hid-elan.c b/drivers/hid/hid-elan.c index 45c4f888b7c4..84a317c6feb6 100644 --- a/drivers/hid/hid-elan.c +++ b/drivers/hid/hid-elan.c @@ -216,8 +216,7 @@ static void elan_report_mt_slot(struct elan_drvdata *drvdata, u8 *data, bool active = !!data; input_mt_slot(input, slot_num); - input_mt_report_slot_state(input, MT_TOOL_FINGER, active); - if (active) { + if (input_mt_report_slot_state(input, MT_TOOL_FINGER, active)) { x = ((data[0] & 0xF0) << 4) | data[1]; y = drvdata->max_y - (((data[0] & 0x07) << 8) | data[2]); diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 21268c9fa71a..a7b552a797f1 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2295,9 +2295,8 @@ static void wtp_touch_event(struct hidpp_device *hidpp, slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); input_mt_slot(hidpp->input, slot); - input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, - touch_report->contact_status); - if (touch_report->contact_status) { + if (input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, +
[PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
From: Nick Dyer The workaround of reading all messages until an invalid is received is a way of forcing the CHG line high, which means that when using edge-triggered interrupts the interrupt can be acquired. With level-triggered interrupts the workaround is unnecessary. Also, most recent maXTouch chips have a feature called RETRIGEN which, when enabled, reasserts the interrupt line every cycle if there are messages waiting. This also makes the workaround unnecessary. Note: the RETRIGEN feature is only in some firmware versions/chips, it's not valid simply to enable the bit. Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 1ae4e8281e491b22442cd5acdfca1862555f8ecb) [gdavis: Fix conflicts due to v4.6-rc7 commit eb43335c4095 ("Input: atmel_mxt_ts - use mxt_acquire_irq in mxt_soft_reset").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 49 ++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 79e35c929857..9b165d23e092 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ struct t9_range { /* MXT_SPT_COMMSCONFIG_T18 */ #define MXT_COMMS_CTRL 0 #define MXT_COMMS_CMD 1 +#define MXT_COMMS_RETRIGEN BIT(6) /* MXT_DEBUG_DIAGNOSTIC_T37 */ #define MXT_DIAGNOSTIC_PAGEUP 0x01 @@ -308,6 +310,7 @@ struct mxt_data { struct t7_config t7_cfg; struct mxt_dbg dbg; struct gpio_desc *reset_gpio; + bool use_retrigen_workaround; /* Cached parameters from object table */ u16 T5_address; @@ -318,6 +321,7 @@ struct mxt_data { u16 T71_address; u8 T9_reportid_min; u8 T9_reportid_max; + u16 T18_address; u8 T19_reportid; u16 T44_address; u8 T100_reportid_min; @@ -1190,9 +1194,11 @@ static int mxt_acquire_irq(struct mxt_data *data) enable_irq(data->irq); - error = mxt_process_messages_until_invalid(data); - if (error) - return error; + if (data->use_retrigen_workaround) { + error = mxt_process_messages_until_invalid(data); + if (error) + return error; + } return 0; } @@ -1282,6 +1288,31 @@ static u32 mxt_calculate_crc(u8 *base, off_t start_off, off_t end_off) return crc; } +static int mxt_check_retrigen(struct mxt_data *data) +{ + struct i2c_client *client = data->client; + int error; + int val; + + if (irq_get_trigger_type(data->irq) & IRQF_TRIGGER_LOW) + return 0; + + if (data->T18_address) { + error = __mxt_read_reg(client, + data->T18_address + MXT_COMMS_CTRL, + 1, &val); + if (error) + return error; + + if (val & MXT_COMMS_RETRIGEN) + return 0; + } + + dev_warn(&client->dev, "Enabling RETRIGEN workaround\n"); + data->use_retrigen_workaround = true; + return 0; +} + static int mxt_prepare_cfg_mem(struct mxt_data *data, struct mxt_cfg *cfg) { struct device *dev = &data->client->dev; @@ -1561,6 +1592,10 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) mxt_update_crc(data, MXT_COMMAND_BACKUPNV, MXT_BACKUP_VALUE); + ret = mxt_check_retrigen(data); + if (ret) + goto release_mem; + ret = mxt_soft_reset(data); if (ret) goto release_mem; @@ -1604,6 +1639,7 @@ static void mxt_free_object_table(struct mxt_data *data) data->T71_address = 0; data->T9_reportid_min = 0; data->T9_reportid_max = 0; + data->T18_address = 0; data->T19_reportid = 0; data->T44_address = 0; data->T100_reportid_min = 0; @@ -1678,6 +1714,9 @@ static int mxt_parse_object_table(struct mxt_data *data, object->num_report_ids - 1; data->num_touchids = object->num_report_ids; break; + case MXT_SPT_COMMSCONFIG_T18: + data->T18_address = object->start_address; + break; case MXT_SPT_MESSAGECOUNT_T44: data->T44_address = object->start_address; break; @@ -2140,6 +2179,10 @@ static int mxt_initialize(struct mxt_data *data) msleep(MXT_FW_RESET_TIME); } + error = mxt_check_retrigen(data); + if (error) + return error; + error = mxt_acquire_irq(data);
[PATCH v1 00/63] atmel_mxt_ts misc
This patch-set forward ports Nick Dyer's work in ndyer/linux github repository as long as some other features and fixes Balasubramani Vivekanandan (4): Input: atmel_mxt_ts: Limit the max bytes transferred in an i2c transaction Input: atmel_mxt_ts: update stale use_retrigen_workaround flag Input: atmel_mxt_ts: use gpiod_set_value_cansleep for reset pin input: atmel_mxt_ts: Add NULL check for sysfs attribute debug_msg_attr Bhuvanesh Surachari (3): Input: touchscreen: Atmel: Enable IRQ_DISABLE_UNLAZY flag for interrupt Input: atmel_mxt_ts: Avoid race condition in freeing of input device Input: atmel_mxt_ts: Prevent crash due to freeing of input device Daniel Gong (1): Input: touchscreen: Atmel: Add device tree support for T15 key array objects Dean Jenkins (3): Input: atmel_mxt_ts: return error from mxt_process_messages_until_invalid() Input: atmel_mxt_ts: Use msecs_to_jiffies() instead of HZ Input: atmel_mxt_ts: Use complete when in_bootloader true Deepak Das (8): Input: Atmel: improve error handling in mxt_start() Input: Atmel: improve error handling in mxt_initialize() Input: Atmel: improve error handling in mxt_update_cfg() input: atmel_mxt_ts: move bootloader probe from mxt_initialize() Input: Atmel: Improve error handling in mxt_initialize_input_device() Input: Atmel: handle ReportID "0x00" while processing T5 messages input: Atmel: limit the max bytes transferred while reading T5 messages Input: Atmel: use T44 object to process T5 messages George G. Davis (1): input: atmel_mxt_ts: export GPIO reset line via sysfs Janus Cheng (1): Input: atmel_mxt_ts - check data->input_dev is not null in mxt_input_sync() Jiada Wang (3): Input: introduce input_mt_report_slot_inactive Input: atmel_mxt_ts - eliminate data->raw_info_block Input: atmel_mxt_ts - Fix compilation warning Karl Tsou (1): Input: atmel_mxt_ts - add debug for T92 gesture and T93 touch seq msgs Kautuk Consul (3): Input: atmel_mxt_ts - Change call-points of mxt_free_* functions Input: atmel_mxt_ts - rely on calculated_crc rather than file config_crc Input: atmel_mxt_ts - configure and use gpios as real gpios Naveen Chakka (2): input: touchscreen: atmel_mxt_ts: Added sysfs entry for touchscreen status input: atmel_mxt_ts: added sysfs interface to update atmel T38 data Nick Dyer (28): Input: atmel_mxt_ts - rework sysfs init/remove Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary Input: atmel_mxt_ts - split large i2c transfers into blocks Input: atmel_mxt_ts - output status from T48 Noise Supression Input: atmel_mxt_ts - output status from T42 Touch Suppression Input: atmel_mxt_ts - implement T9 vector/orientation support Input: atmel_mxt_ts - implement T15 Key Array support Input: atmel_mxt_ts - handle reports from T47 Stylus object Input: atmel_mxt_ts - implement support for T107 active stylus Input: atmel_mxt_ts - release touch state during suspend Input: atmel_mxt_ts - add regulator control support Input: atmel_mxt_ts - report failures in suspend/resume Input: atmel_mxt_ts - allow specification of firmware file name Input: atmel_mxt_ts - handle cfg filename via pdata/sysfs Input: atmel_mxt_ts - allow input name to be specified in platform data Input: atmel_mxt_ts - refactor firmware flash to extract context into struct Input: atmel_mxt_ts - refactor code to enter bootloader into separate func Input: atmel_mxt_ts - combine bootloader version query with probe Input: atmel_mxt_ts - improve bootloader state machine handling Input: atmel_mxt_ts - check firmware format before entering bootloader Input: atmel_mxt_ts - rename bl_completion to chg_completion Input: atmel_mxt_ts - make bootloader interrupt driven Input: atmel_mxt_ts - delay enabling IRQ when not using regulators Input: atmel_mxt_ts - implement I2C retries Input: atmel_mxt_ts - orientation is not present in hover Input: atmel_mxt_ts - implement debug output for messages Input: atmel_mxt_ts - add memory access interface via sysfs Input: atmel_mxt_ts - implement improved debug message interface Nikhil Ravindran (1): Input: atmel_mxt_ts: Add support for run self-test routine. Sanjeev Chugh (2): Input: atmel_mxt_ts: Remove sysfs attributes during driver detach Input: atmel_mxt_ts: Implement synchronization during various operation karl tsou (1): Input: atmel_mxt_ts - add config checksum attribute to sysfs keerthikumarp (1): input: atmel_mxt_ts: Add Missing Delay for reset handling of Atmel touch panel controller in detachable displays. .../bindings/input/atmel,maxtouch.txt | 29 + MAINTAINERS |1 + drivers/hid/hid-alps.c|3 +- drivers/hid/hid-asus.c|3 +- drivers/hid/hid-elan.c|3 +- drivers/hid/hid-logitech-hidpp.c |5 +- driv
[PATCH v1 02/63] Input: atmel_mxt_ts - rework sysfs init/remove
From: Nick Dyer An error in the sysfs init may otherwise interfere with the async return from the firmware loader Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 3114584ae77c2b03b6dad87174f010d002e9c05d) [gdavis: Forward port and fixup conflicts. Also fixed sysfs leaks in both the mxt_initialize() and mxt_probe() error return cases.] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 71 +++- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 573b94a049b2..79e35c929857 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2090,6 +2090,9 @@ static int mxt_initialize_input_device(struct mxt_data *data) return error; } +static int mxt_sysfs_init(struct mxt_data *data); +static void mxt_sysfs_remove(struct mxt_data *data); + static int mxt_configure_objects(struct mxt_data *data, const struct firmware *cfg); @@ -2141,16 +2144,24 @@ static int mxt_initialize(struct mxt_data *data) if (error) return error; + error = mxt_sysfs_init(data); + if (error) + return error; + error = request_firmware_nowait(THIS_MODULE, true, MXT_CFG_NAME, &client->dev, GFP_KERNEL, data, mxt_config_cb); if (error) { dev_err(&client->dev, "Failed to invoke firmware loader: %d\n", error); - return error; + goto err_free_sysfs; } return 0; + +err_free_sysfs: + mxt_sysfs_remove(data); + return error; } static int mxt_set_t7_power_cfg(struct mxt_data *data, u8 sleep) @@ -2803,6 +2814,7 @@ static int mxt_load_fw(struct device *dev, const char *fn) if (ret) goto release_firmware; + mxt_sysfs_remove(data); mxt_free_input_device(data); mxt_free_object_table(data); } else { @@ -2909,16 +2921,25 @@ static ssize_t mxt_update_fw_store(struct device *dev, return count; } +static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); + +static struct attribute *mxt_fw_attrs[] = { + &dev_attr_update_fw.attr, + NULL +}; + +static const struct attribute_group mxt_fw_attr_group = { + .attrs = mxt_fw_attrs, +}; + static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL); static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL); static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); -static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store); static struct attribute *mxt_attrs[] = { &dev_attr_fw_version.attr, &dev_attr_hw_version.attr, &dev_attr_object.attr, - &dev_attr_update_fw.attr, NULL }; @@ -2926,6 +2947,28 @@ static const struct attribute_group mxt_attr_group = { .attrs = mxt_attrs, }; +static int mxt_sysfs_init(struct mxt_data *data) +{ + struct i2c_client *client = data->client; + int error; + + error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); + if (error) { + dev_err(&client->dev, "Failure %d creating sysfs group\n", + error); + return error; + } + + return 0; +} + +static void mxt_sysfs_remove(struct mxt_data *data) +{ + struct i2c_client *client = data->client; + + sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); +} + static void mxt_start(struct mxt_data *data) { switch (data->suspend_mode) { @@ -3109,22 +3152,21 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) msleep(MXT_RESET_INVALID_CHG); } - error = mxt_initialize(data); - if (error) - return error; - - error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); + error = sysfs_create_group(&client->dev.kobj, &mxt_fw_attr_group); if (error) { - dev_err(&client->dev, "Failure %d creating sysfs group\n", + dev_err(&client->dev, "Failure %d creating fw sysfs group\n", error); - goto err_free_object; + return error; } + error = mxt_initialize(data); + if (error) + goto err_sysfs_remove_group; + return 0; -err_free_object: - mxt_free_input_device(data); - mxt_free_object_table(data); +err_sysfs_remove_group: + sysfs_remove_group(&client->dev.kobj, &mxt_fw_attr_group); return error; } @@ -3133,7 +3175,8 @@ static int mxt_remove(struct i2c_client *client) struct mxt_data *data = i2c_get_clientdata(client); disable_i
RE: [PATCH 2/2] lib/test_printf: add test of null/invalid pointer dereference for dentry
Hi Petr > -Original Message- > From: Petr Mladek > Sent: 2019年8月16日 16:27 > To: Justin He (Arm Technology China) > Cc: Geert Uytterhoeven ; Sergey Senozhatsky > ; Thomas Gleixner ; > Andy Shevchenko ; linux- > ker...@vger.kernel.org; Kees Cook ; Steven > Rostedt (VMware) ; Shuah Khan > ; Tobin C. Harding > Subject: Re: [PATCH 2/2] lib/test_printf: add test of null/invalid pointer > dereference for dentry > > On Fri 2019-08-09 09:24:57, Jia He wrote: > > This add some additional test cases of null/invalid pointer dereference > > for dentry and file (%pd and %pD) > > > > Signed-off-by: Jia He > > --- > > lib/test_printf.c | 7 +++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/lib/test_printf.c b/lib/test_printf.c > > index 944eb50f3862..befedffeb476 100644 > > --- a/lib/test_printf.c > > +++ b/lib/test_printf.c > > @@ -455,6 +455,13 @@ dentry(void) > > test("foo", "%pd", &test_dentry[0]); > > test("foo", "%pd2", &test_dentry[0]); > > > > + /* test the null/invalid pointer case for dentry */ > > + test("(null)", "%pd", NULL); > > + test("(efault)", "%pd", PTR_INVALID); > > + /* test the null/invalid pointer case for file */ > > The two comments mention something that is obvious from the code. > No problem, ok with me 😊 -- Cheers, Justin (Jia He) > I have pushed the patch as is and removed the comments in > a follow up patch [1]. Both are in printk.git, branch for-5.4. > > > + test("(null)", "%pD", NULL); > > + test("(efault)", "%pD", PTR_INVALID); > > Reference: > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git/commi > t/?h=for-5.4&id=8ebea6ea1a7ed5d67ecbb2a493c716a2a89c0be2 > > Best Regards, > Petr IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
[PATCH v1 22/63] Input: atmel_mxt_ts - combine bootloader version query with probe
From: Nick Dyer This removes some complexity from the bootloader state machine, and means that we always output some debug about the version as soon as we start talking to the bootloader. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit a2d141f170c80fea6663af98aab0be32abc0ddb0) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 45 +++- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index e171a843751f..2a5f2157c322 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -558,47 +558,31 @@ static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address) { struct device *dev = &data->client->dev; int error; - u8 val; - bool crc_failure; + u8 buf[3]; + bool crc_failure, extended_id; error = mxt_lookup_bootloader_address(data, alt_address); if (error) return error; - error = mxt_bootloader_read(data, &val, 1); + /* Check bootloader status and version information */ + error = mxt_bootloader_read(data, buf, sizeof(buf)); if (error) return error; - /* Check app crc fail mode */ - crc_failure = (val & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL; + crc_failure = (buf[0] & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL; + extended_id = buf[0] & MXT_BOOT_EXTENDED_ID; - dev_err(dev, "Detected bootloader, status:%02X%s\n", - val, crc_failure ? ", APP_CRC_FAIL" : ""); + dev_info(dev, "Found bootloader addr:%02x ID:%u%s%u%s\n", +data->bootloader_addr, +extended_id ? (buf[1] & MXT_BOOT_ID_MASK) : buf[0], +extended_id ? " version:" : "", +extended_id ? buf[2] : 0, +crc_failure ? ", APP_CRC_FAIL" : ""); return 0; } -static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val) -{ - struct device *dev = &data->client->dev; - u8 buf[3]; - - if (val & MXT_BOOT_EXTENDED_ID) { - if (mxt_bootloader_read(data, &buf[0], 3) != 0) { - dev_err(dev, "%s: i2c failure\n", __func__); - return val; - } - - dev_dbg(dev, "Bootloader ID:%d Version:%d\n", buf[1], buf[2]); - - return buf[0]; - } else { - dev_dbg(dev, "Bootloader ID:%d\n", val & MXT_BOOT_ID_MASK); - - return val; - } -} - static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, bool wait) { @@ -632,9 +616,6 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, if (ret) return ret; - if (state == MXT_WAITING_BOOTLOAD_CMD) - val = mxt_get_bootloader_version(data, val); - switch (state) { case MXT_WAITING_BOOTLOAD_CMD: case MXT_WAITING_FRAME_DATA: @@ -3279,7 +3260,7 @@ static int mxt_enter_bootloader(struct mxt_data *data) msleep(MXT_RESET_TIME); /* Do not need to scan since we know family ID */ - ret = mxt_lookup_bootloader_address(data, 0); + ret = mxt_probe_bootloader(data, 0); if (ret) return ret; -- 2.19.2
[PATCH v1 21/63] Input: atmel_mxt_ts - refactor code to enter bootloader into separate func
From: Nick Dyer Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit bedd706a32522b946467e15f4f4f24de86a1b4d7) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 43 +++- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ad5b4a246f55..e171a843751f 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3253,23 +3253,10 @@ static int mxt_check_firmware_format(struct device *dev, return -EINVAL; } -static int mxt_load_fw(struct device *dev) +static int mxt_enter_bootloader(struct mxt_data *data) { - struct mxt_data *data = dev_get_drvdata(dev); - struct mxt_flash f = { 0, }; int ret; - ret = request_firmware(&f.fw, data->fw_name, dev); - if (ret) { - dev_err(dev, "Unable to open firmware %s\n", data->fw_name); - return ret; - } - - /* Check for incorrect enc file */ - ret = mxt_check_firmware_format(dev, f.fw); - if (ret) - goto release_firmware; - if (data->suspended) { if (data->suspend_mode == MXT_SUSPEND_REGULATOR) mxt_regulator_enable(data); @@ -3287,14 +3274,14 @@ static int mxt_load_fw(struct device *dev) ret = mxt_t6_command(data, MXT_COMMAND_RESET, MXT_BOOT_VALUE, false); if (ret) - goto release_firmware; + return ret; msleep(MXT_RESET_TIME); /* Do not need to scan since we know family ID */ ret = mxt_lookup_bootloader_address(data, 0); if (ret) - goto release_firmware; + return ret; mxt_sysfs_remove(data); mxt_free_input_device(data); @@ -3305,6 +3292,30 @@ static int mxt_load_fw(struct device *dev) reinit_completion(&data->bl_completion); + return 0; +} + +static int mxt_load_fw(struct device *dev) +{ + struct mxt_data *data = dev_get_drvdata(dev); + struct mxt_flash f = { 0, }; + int ret; + + ret = request_firmware(&f.fw, data->fw_name, dev); + if (ret) { + dev_err(dev, "Unable to open firmware %s\n", data->fw_name); + return ret; + } + + ret = mxt_enter_bootloader(data); + if (ret) + goto release_firmware; + + /* Check for incorrect enc file */ + ret = mxt_check_firmware_format(dev, f.fw); + if (ret) + goto release_firmware; + ret = mxt_check_bootloader(data, MXT_WAITING_BOOTLOAD_CMD, false); if (ret) { /* Bootloader may still be unlocked from previous attempt */ -- 2.19.2
[PATCH] FS: timerfd: Fix unexpected return value of timerfd_read function. 'hrtimer_forward_now()' returns zero due to bigger backward time drift. This causes timerfd_read to return 0. As per man pa
From: ARUL JENISTON MC --- fs/timerfd.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/timerfd.c b/fs/timerfd.c index 6a6fc8aa1de7..f5094e070e9a 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -284,8 +284,16 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, &ctx->t.alarm, ctx->tintv) - 1; alarm_restart(&ctx->t.alarm); } else { - ticks += hrtimer_forward_now(&ctx->t.tmr, -ctx->tintv) - 1; + u64 nooftimeo = hrtimer_forward_now(&ctx->t.tmr, +ctx->tintv); + /* +* ticks shouldn't become zero at this point. +* Ignore if hrtimer_forward_now returns 0 +* due to larger backward time drift. +*/ + if (likely(nooftimeo)) { + ticks += nooftimeo - 1; + } hrtimer_restart(&ctx->t.tmr); } } -- 2.11.0
[PATCH v1 28/63] Input: atmel_mxt_ts - implement I2C retries
From: Nick Dyer Some maXTouch chips (eg mXT1386) will not respond on the first I2C request when they are in a sleep state. It must be retried after a delay for the chip to wake up. Signed-off-by: Nick Dyer Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 63fd7a2cd03c3a572a5db39c52f4856819e1835d) [gdavis: Forward port and fix conflicts.] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 45 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index d3e1cd677aa7..86c016dbec0d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -216,6 +216,7 @@ enum t100_type { #define MXT_CRC_TIMEOUT1000/* msec */ #define MXT_FW_RESET_TIME 3000/* msec */ #define MXT_FW_CHG_TIMEOUT 300 /* msec */ +#define MXT_WAKEUP_TIME25 /* msec */ #define MXT_REGULATOR_DELAY150 /* msec */ #define MXT_CHG_DELAY 100 /* msec */ #define MXT_POWERON_DELAY 150 /* msec */ @@ -723,6 +724,7 @@ static int __mxt_read_reg(struct i2c_client *client, struct i2c_msg xfer[2]; u8 buf[2]; int ret; + bool retry = false; buf[0] = reg & 0xff; buf[1] = (reg >> 8) & 0xff; @@ -739,17 +741,22 @@ static int __mxt_read_reg(struct i2c_client *client, xfer[1].len = len; xfer[1].buf = val; - ret = i2c_transfer(client->adapter, xfer, 2); - if (ret == 2) { - ret = 0; - } else { - if (ret >= 0) - ret = -EIO; - dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", - __func__, ret); +retry_read: + ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer)); + if (ret != ARRAY_SIZE(xfer)) { + if (!retry) { + dev_dbg(&client->dev, "%s: i2c retry\n", __func__); + msleep(MXT_WAKEUP_TIME); + retry = true; + goto retry_read; + } else { + dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", + __func__, ret); + return -EIO; + } } - return ret; + return 0; } static int mxt_read_blks(struct mxt_data *data, u16 start, u16 count, u8 *buf) @@ -779,6 +786,7 @@ static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, u8 *buf; size_t count; int ret; + bool retry = false; count = len + 2; buf = kmalloc(count, GFP_KERNEL); @@ -789,14 +797,21 @@ static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len, buf[1] = (reg >> 8) & 0xff; memcpy(&buf[2], val, len); +retry_write: ret = i2c_master_send(client, buf, count); - if (ret == count) { - ret = 0; - } else { - if (ret >= 0) + if (ret != count) { + if (!retry) { + dev_dbg(&client->dev, "%s: i2c retry\n", __func__); + msleep(MXT_WAKEUP_TIME); + retry = true; + goto retry_write; + } else { + dev_err(&client->dev, "%s: i2c send failed (%d)\n", + __func__, ret); ret = -EIO; - dev_err(&client->dev, "%s: i2c send failed (%d)\n", - __func__, ret); + } + } else { + ret = 0; } kfree(buf); -- 2.19.2
[PATCH v1 23/63] Input: atmel_mxt_ts - improve bootloader state machine handling
From: Nick Dyer The code is much clearer if we switch on the actual state the bootloader is in, rather than the state we want it to be in, and allows the removal of a goto retry tangle. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 463e15ee95ee6e6274017ff645839dbe34d75c99) [gdavis: Squash fix from George G. Davis: - input: atmel_mxt_ts - Fix 'mxt_send_bootloader_cmd' was not declared warning] Signed-off-by: George G. Davis --- Notes: - Squash fix from George G. Davis: + input: atmel_mxt_ts - Fix 'mxt_send_bootloader_cmd' was not declared warning The following sparse warning was introduced by ndyer/linux/for-upstream commit 463e15ee95ee ("Input: atmel_mxt_ts - improve bootloader state machine handling"): drivers/input/touchscreen/atmel_mxt_ts.c:888:5: warning: symbol 'mxt_send_bootloader_cmd' was not declared. Should it be static? Fix the above sparse warning by restoring the 'mxt_send_bootloader_cmd' static declaration which was errantly removed by ndyer/linux/for-upstream commit 463e15ee95ee ("Input: atmel_mxt_ts - improve bootloader state machine handling"). Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 183 --- 1 file changed, 98 insertions(+), 85 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 2a5f2157c322..ca882231ab41 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -305,6 +305,8 @@ struct mxt_flash { size_t frame_size; unsigned int count; unsigned int retry; + u8 previous; + bool complete; }; /* Each client has this additional data */ @@ -583,64 +585,121 @@ static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address) return 0; } -static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, - bool wait) +static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock); + +static int mxt_write_firmware_frame(struct mxt_data *data, struct mxt_flash *f) +{ + f->frame = (struct mxt_fw_frame *)(f->fw->data + f->pos); + + /* Take account of CRC bytes */ + f->frame_size = __be16_to_cpu(f->frame->size) + 2U; + + /* Write one frame to device */ + return mxt_bootloader_write(data, f->fw->data + f->pos, + f->frame_size); +} + +static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) { struct device *dev = &data->client->dev; - u8 val; + u8 state; int ret; -recheck: - if (wait) { + /* +* In application update mode, the interrupt +* line signals state transitions. We must wait for the +* CHG assertion before reading the status byte. +* Once the status byte has been read, the line is deasserted. +*/ + ret = mxt_wait_for_completion(data, &data->bl_completion, + MXT_FW_CHG_TIMEOUT); + if (ret) { /* -* In application update mode, the interrupt -* line signals state transitions. We must wait for the -* CHG assertion before reading the status byte. -* Once the status byte has been read, the line is deasserted. +* TODO: handle -ERESTARTSYS better by terminating +* fw update process before returning to userspace +* by writing length 0x000 to device (iff we are in +* WAITING_FRAME_DATA state). */ - ret = mxt_wait_for_completion(data, &data->bl_completion, - MXT_FW_CHG_TIMEOUT); - if (ret) { - /* -* TODO: handle -ERESTARTSYS better by terminating -* fw update process before returning to userspace -* by writing length 0x000 to device (iff we are in -* WAITING_FRAME_DATA state). -*/ - dev_err(dev, "Update wait error %d\n", ret); - return ret; - } + dev_warn(dev, "Update wait error %d\n", ret); } - ret = mxt_bootloader_read(data, &val, 1); + ret = mxt_bootloader_read(data, &state, 1); if (ret) return ret; + /* Remove don't care bits */ + if (state & ~MXT_BOOT_STATUS_MASK) + state &= ~MXT_BOOT_STATUS_MASK; + switch (state) { case MXT_WAITING_BOOTLOAD_CMD: + dev_info(dev, "Unlocking bootloader\n"); + ret = mxt_send_bootloader_cmd(data, true); + if (ret) + return ret; + + break; + case MXT_WAITING_FRAME_DATA: - case MXT_APP_CR
[PATCH v1 20/63] Input: atmel_mxt_ts - refactor firmware flash to extract context into struct
From: Nick Dyer Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 1bbe20ff3dcd6612e7942c495929eae5c138ece2) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 59 +++- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 99e5c84d207a..ad5b4a246f55 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -291,6 +291,22 @@ struct mxt_cfg { struct mxt_info info; }; +/* Firmware frame structure */ +struct mxt_fw_frame { + __be16 size; + u8 data[]; +}; + +/* Firmware update context */ +struct mxt_flash { + const struct firmware *fw; + struct mxt_fw_frame *frame; + loff_t pos; + size_t frame_size; + unsigned int count; + unsigned int retry; +}; + /* Each client has this additional data */ struct mxt_data { struct i2c_client *client; @@ -3240,21 +3256,17 @@ static int mxt_check_firmware_format(struct device *dev, static int mxt_load_fw(struct device *dev) { struct mxt_data *data = dev_get_drvdata(dev); - const struct firmware *fw = NULL; - unsigned int frame_size; - unsigned int pos = 0; - unsigned int retry = 0; - unsigned int frame = 0; + struct mxt_flash f = { 0, }; int ret; - ret = request_firmware(&fw, data->fw_name, dev); + ret = request_firmware(&f.fw, data->fw_name, dev); if (ret) { dev_err(dev, "Unable to open firmware %s\n", data->fw_name); return ret; } /* Check for incorrect enc file */ - ret = mxt_check_firmware_format(dev, fw); + ret = mxt_check_firmware_format(dev, f.fw); if (ret) goto release_firmware; @@ -3308,41 +3320,42 @@ static int mxt_load_fw(struct device *dev) goto disable_irq; } - while (pos < fw->size) { + while (f.pos < f.fw->size) { + f.frame = (struct mxt_fw_frame *)(f.fw->data + f.pos); + ret = mxt_check_bootloader(data, MXT_WAITING_FRAME_DATA, true); if (ret) goto disable_irq; - frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); - /* Take account of CRC bytes */ - frame_size += 2; + f.frame_size = __be16_to_cpu(f.frame->size) + 2U; /* Write one frame to device */ - ret = mxt_bootloader_write(data, fw->data + pos, frame_size); + ret = mxt_bootloader_write(data, f.fw->data + f.pos, + f.frame_size); if (ret) goto disable_irq; ret = mxt_check_bootloader(data, MXT_FRAME_CRC_PASS, true); if (ret) { - retry++; + f.retry++; /* Back off by 20ms per retry */ - msleep(retry * 20); + msleep(f.retry * 20); - if (retry > 20) { + if (f.retry > 20) { dev_err(dev, "Retry count exceeded\n"); goto disable_irq; } } else { - retry = 0; - pos += frame_size; - frame++; + f.retry = 0; + f.pos += f.frame_size; + f.count++; } - if (frame % 50 == 0) - dev_dbg(dev, "Sent %d frames, %d/%zd bytes\n", - frame, pos, fw->size); + if (f.count % 50 == 0) + dev_dbg(dev, "Sent %u frames, %lld/%zu bytes\n", + f.count, f.pos, f.fw->size); } /* Wait for flash. */ @@ -3351,7 +3364,7 @@ static int mxt_load_fw(struct device *dev) if (ret) goto disable_irq; - dev_dbg(dev, "Sent %d frames, %d bytes\n", frame, pos); + dev_dbg(dev, "Sent %u frames, %lld bytes\n", f.count, f.pos); /* * Wait for device to reset. Some bootloader versions do not assert @@ -3365,7 +3378,7 @@ static int mxt_load_fw(struct device *dev) disable_irq: disable_irq(data->irq); release_firmware: - release_firmware(fw); + release_firmware(f.fw); return ret; } -- 2.19.2
[PATCH v1 24/63] Input: atmel_mxt_ts - check firmware format before entering bootloader
From: Nick Dyer Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit d691d3ee6c6de84b38464a423207b3e23cb9dc3a) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ca882231ab41..a7805df83af2 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3347,12 +3347,12 @@ static int mxt_load_fw(struct device *dev) return ret; } - ret = mxt_enter_bootloader(data); + /* Check for incorrect enc file */ + ret = mxt_check_firmware_format(dev, f.fw); if (ret) goto release_firmware; - /* Check for incorrect enc file */ - ret = mxt_check_firmware_format(dev, f.fw); + ret = mxt_enter_bootloader(data); if (ret) goto release_firmware; -- 2.19.2
[PATCH v1 26/63] Input: atmel_mxt_ts - make bootloader interrupt driven
From: Nick Dyer Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 67a3eea0cfc724c3c2a7410ac064f74227c7c6ef) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 120 --- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 6f185bc5128c..2bc80abcbd80 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -218,6 +219,7 @@ enum t100_type { #define MXT_REGULATOR_DELAY150 /* msec */ #define MXT_CHG_DELAY 100 /* msec */ #define MXT_POWERON_DELAY 150 /* msec */ +#define MXT_BOOTLOADER_WAIT36E5/* 1 minute */ /* Command to unlock bootloader */ #define MXT_UNLOCK_CMD_MSB 0xaa @@ -299,6 +301,7 @@ struct mxt_fw_frame { /* Firmware update context */ struct mxt_flash { + struct mxt_data *data; const struct firmware *fw; struct mxt_fw_frame *frame; loff_t pos; @@ -306,7 +309,8 @@ struct mxt_flash { unsigned int count; unsigned int retry; u8 previous; - bool complete; + struct completion flash_completion; + struct delayed_work work; }; /* Each client has this additional data */ @@ -355,6 +359,7 @@ struct mxt_data { char *cfg_name; const char *pcfg_name; const char *input_name; + struct mxt_flash *flash; /* Cached parameters from object table */ u16 T5_address; @@ -599,28 +604,17 @@ static int mxt_write_firmware_frame(struct mxt_data *data, struct mxt_flash *f) f->frame_size); } -static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) +static int mxt_check_bootloader(struct mxt_data *data) { struct device *dev = &data->client->dev; + struct mxt_flash *f = data->flash; u8 state; int ret; - /* -* In application update mode, the interrupt -* line signals state transitions. We must wait for the -* CHG assertion before reading the status byte. -* Once the status byte has been read, the line is deasserted. -*/ - ret = mxt_wait_for_completion(data, &data->chg_completion, - MXT_FW_CHG_TIMEOUT); - if (ret) { - /* -* TODO: handle -ERESTARTSYS better by terminating -* fw update process before returning to userspace -* by writing length 0x000 to device (iff we are in -* WAITING_FRAME_DATA state). -*/ - dev_warn(dev, "Update wait error %d\n", ret); + /* Handle interrupt after download/flash process */ + if (f->pos >= f->fw->size) { + complete(&f->flash_completion); + return 0; } ret = mxt_bootloader_read(data, &state, 1); @@ -666,14 +660,12 @@ static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) f->pos += f->frame_size; f->count++; - if (f->pos >= f->fw->size) { - f->complete = true; + if (f->pos >= f->fw->size) dev_info(dev, "Sent %u frames, %zu bytes\n", f->count, f->fw->size); - } else if (f->count % 50 == 0) { + else if (f->count % 50 == 0) dev_dbg(dev, "Sent %u frames, %lld/%zu bytes\n", f->count, f->pos, f->fw->size); - } break; @@ -695,6 +687,9 @@ static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) f->previous = state; + /* Poll after 0.1s if no interrupt received */ + schedule_delayed_work(&f->work, HZ / 10); + return 0; unexpected: @@ -1402,8 +1397,12 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) complete(&data->chg_completion); - if (data->in_bootloader) - return IRQ_HANDLED; + if (data->in_bootloader) { + if (data->flash && &data->flash->work) + cancel_delayed_work_sync(&data->flash->work); + + return IRQ_RETVAL(mxt_check_bootloader(data)); + } if (!data->object_table) return IRQ_HANDLED; @@ -3300,16 +3299,13 @@ static int mxt_enter_bootloader(struct mxt_data *data) if (data->suspend_mode == MXT_SUSPEND_REGULATOR) mxt_regulator_enable(data); - if (data->suspend_mode == MXT_SUSPEND_DEE
[PATCH v1 27/63] Input: atmel_mxt_ts - delay enabling IRQ when not using regulators
From: Nick Dyer The path of enabling the IRQ in the probe function is not safe in level triggered operation, if it was already powered up and there is a message waiting on the device (eg finger down) because the object table has not yet been read. This forces the ISR into a hard loop. Delay enabling the interrupt until it is first needed. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 64c9dadc4a3250a185baf06ab0f628be45d5d9a0) [gdavis: Resolve forward port conflicts due to v4.14-rc1 commit 8cc8446b9b62 ("Input: atmel_mxt_ts - use more managed resources") and applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 40 +++- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 2bc80abcbd80..d3e1cd677aa7 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1450,9 +1450,24 @@ static int mxt_acquire_irq(struct mxt_data *data) { int error; - enable_irq(data->irq); + if (!data->irq) { + error = devm_request_threaded_irq(&data->client->dev, + data->client->irq, + NULL, mxt_interrupt, + IRQF_ONESHOT, + data->client->name, data); + if (error) { + dev_err(&data->client->dev, "Error requesting irq\n"); + return error; + } + + /* Presence of data->irq means IRQ initialised */ + data->irq = data->client->irq; + } else { + enable_irq(data->irq); + } - if (data->use_retrigen_workaround) { + if (data->object_table && data->use_retrigen_workaround) { error = mxt_process_messages_until_invalid(data); if (error) return error; @@ -3369,7 +3384,9 @@ static int mxt_load_fw(struct device *dev) goto release_firmware; } - enable_irq(data->irq); + ret = mxt_acquire_irq(data); + if (ret) + goto release_firmware; /* Poll after 0.1s if no interrupt received */ schedule_delayed_work(&data->flash->work, HZ / 10); @@ -3769,7 +3786,6 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) client->adapter->nr, client->addr); data->client = client; - data->irq = client->irq; i2c_set_clientdata(client, data); init_completion(&data->chg_completion); @@ -3797,26 +3813,22 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } - error = devm_request_threaded_irq(&client->dev, client->irq, - NULL, mxt_interrupt, IRQF_ONESHOT, - client->name, data); - if (error) { - dev_err(&client->dev, "Failed to register interrupt\n"); - return error; - } - if (data->suspend_mode == MXT_SUSPEND_REGULATOR) { + error = mxt_acquire_irq(data); + if (error) + return error; + error = mxt_probe_regulators(data); if (error) return error; + + disable_irq(data->irq); } else if (data->reset_gpio) { msleep(MXT_RESET_GPIO_TIME); gpiod_set_value(data->reset_gpio, 1); msleep(MXT_RESET_INVALID_CHG); } - disable_irq(data->irq); - error = sysfs_create_group(&client->dev.kobj, &mxt_fw_attr_group); if (error) { dev_err(&client->dev, "Failure %d creating fw sysfs group\n", -- 2.19.2
[PATCH v1 25/63] Input: atmel_mxt_ts - rename bl_completion to chg_completion
From: Nick Dyer Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit dda8453bfb44216645ede798918a314d4fca2481) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 27 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index a7805df83af2..6f185bc5128c 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -381,9 +381,6 @@ struct mxt_data { u8 T100_reportid_max; u16 T107_address; - /* for fw update in bootloader */ - struct completion bl_completion; - /* for reset handling */ struct completion reset_completion; @@ -395,6 +392,9 @@ struct mxt_data { enum mxt_suspend_mode suspend_mode; + /* for power up handling */ + struct completion chg_completion; + /* Indicates whether device is in suspend */ bool suspended; @@ -611,7 +611,7 @@ static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) * CHG assertion before reading the status byte. * Once the status byte has been read, the line is deasserted. */ - ret = mxt_wait_for_completion(data, &data->bl_completion, + ret = mxt_wait_for_completion(data, &data->chg_completion, MXT_FW_CHG_TIMEOUT); if (ret) { /* @@ -1400,11 +1400,10 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) { struct mxt_data *data = dev_id; - if (data->in_bootloader) { - /* bootloader state transition completion */ - complete(&data->bl_completion); + complete(&data->chg_completion); + + if (data->in_bootloader) return IRQ_HANDLED; - } if (!data->object_table) return IRQ_HANDLED; @@ -2164,9 +2163,9 @@ static void mxt_regulator_enable(struct mxt_data *data) msleep(MXT_CHG_DELAY); retry_wait: - reinit_completion(&data->bl_completion); + reinit_completion(&data->chg_completion); data->in_bootloader = true; - error = mxt_wait_for_completion(data, &data->bl_completion, + error = mxt_wait_for_completion(data, &data->chg_completion, MXT_POWERON_DELAY); if (error == -EINTR) goto retry_wait; @@ -3330,7 +3329,7 @@ static int mxt_enter_bootloader(struct mxt_data *data) enable_irq(data->irq); } - reinit_completion(&data->bl_completion); + reinit_completion(&data->chg_completion); return 0; } @@ -3366,7 +3365,7 @@ static int mxt_load_fw(struct device *dev) } /* Wait for flash. */ - ret = mxt_wait_for_completion(data, &data->bl_completion, + ret = mxt_wait_for_completion(data, &data->chg_completion, MXT_FW_RESET_TIME); if (ret) goto disable_irq; @@ -3377,7 +3376,7 @@ static int mxt_load_fw(struct device *dev) * the CHG line after bootloading has finished, so ignore potential * errors. */ - mxt_wait_for_completion(data, &data->bl_completion, MXT_FW_RESET_TIME); + mxt_wait_for_completion(data, &data->chg_completion, MXT_FW_RESET_TIME); data->in_bootloader = false; disable_irq: @@ -3771,7 +3770,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) data->irq = client->irq; i2c_set_clientdata(client, data); - init_completion(&data->bl_completion); + init_completion(&data->chg_completion); init_completion(&data->reset_completion); init_completion(&data->crc_completion); -- 2.19.2
[PATCH v1 29/63] Input: atmel_mxt_ts - orientation is not present in hover
From: Nick Dyer When in hover, the orientation information is not sent Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 0c885d5bd276bd9240c43aa046fc407cbe2ae864) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 86c016dbec0d..ba608d04ee82 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1028,10 +1028,6 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message) distance = MXT_DISTANCE_HOVERING; hover = true; active = true; - - if (data->t100_aux_vect) - orientation = message[data->t100_aux_vect]; - break; case MXT_T100_TYPE_FINGER: -- 2.19.2
Re: [PATCH 14/22] ARM: omap1: use pci_ioremap_io() for omap_cf
Hi, On Wed, Aug 14, 2019 at 12:36:40PM +0200, Arnd Bergmann wrote: > On Wed, Aug 14, 2019 at 9:49 AM Tony Lindgren wrote: > > * Arnd Bergmann [190813 19:34]: > > > -#define OMAP1_IO_OFFSET0x0100 /* Virtual IO > > > = 0xfefb */ > > > +#define OMAP1_IO_OFFSET0x00fb /* Virtual IO > > > = 0xff00 */ > > > #define OMAP1_IO_ADDRESS(pa) IOMEM((pa) - OMAP1_IO_OFFSET) > > > > Oh OK yeah sounds like that's the issue. > > > > > There may be additional locations that hardcode the virtual address. > > > > Those should be in mach-omap1/io.c, and I recall innovator had some > > hardcoded fpga address that should also be checked. > > I see four boards with hardcoded I/O addresses, but they are all below > the PCI I/O virtual address range, and are not affected by that change. > > For the innovator FPGA access, this was ok, it uses the correct address > in the OMAP1_IO_OFFSET range. I tried testing this on OSK board. If I boot with earlyprintk disabled, it boots OK and everything works (also CF card) with your playground commit 5723b6686943. However with earlyprintk it seems to hang as soon as kernel tries to print something. So something goes wrong with early DEBUG_LL mapping code when CONFIG_DEBUG_UART_VIRT=0xff00 is used? A.
[PATCH v1 49/63] Input: Atmel: Improve error handling in mxt_initialize_input_device()
From: Deepak Das Currently Driver probe continues with a warning message when it fails to get the proper multitouch object configurations like TouchScreen resolution. But Driver probe should fail in case of above scneario because it will not behave as expected without the proper touchscreen configurations. This commit modifies mxt_initialize_input_device() to return error when it fails to get the proper touch screen configurations. Signed-off-by: Deepak Das Signed-off-by: Dean Jenkins Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 27b908a50b66..b17af89a4711 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2749,15 +2749,19 @@ static int mxt_initialize_input_device(struct mxt_data *data) case MXT_TOUCH_MULTI_T9: num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1; error = mxt_read_t9_resolution(data); - if (error) - dev_warn(dev, "Failed to initialize T9 resolution\n"); + if (error) { + dev_err(dev, "Failed to initialize T9 resolution\n"); + return error; + } break; case MXT_TOUCH_MULTITOUCHSCREEN_T100: num_mt_slots = data->num_touchids; error = mxt_read_t100_config(data); - if (error) - dev_warn(dev, "Failed to read T100 config\n"); + if (error) { + dev_err(dev, "Failed to read T100 config\n"); + return error; + } break; default: -- 2.19.2
[PATCH v1 46/63] Input: Atmel: improve error handling in mxt_initialize()
From: Deepak Das Currently mxt_initialize() tries to probe bootloader mode even if valid bootloader address is not specified. This commit modifies mxt_initialize() to return error if Device is not in appmode and bootloader address is not specified. This commit also returns error code from mxt_send_bootloader_cmd() in mxt_initialize(). Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 33 +--- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 232262736029..3999d3e31a6a 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -718,17 +718,13 @@ static int mxt_lookup_bootloader_address(struct mxt_data *data, bool retry) return 0; } -static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address) +static int mxt_probe_bootloader(struct mxt_data *data) { struct device *dev = &data->client->dev; int error; u8 buf[3]; bool crc_failure, extended_id; - error = mxt_lookup_bootloader_address(data, alt_address); - if (error) - return error; - /* Check bootloader status and version information */ error = mxt_bootloader_read(data, buf, sizeof(buf)); if (error) @@ -2930,13 +2926,25 @@ static int mxt_initialize(struct mxt_data *data) if (!error) break; + dev_info(&client->dev, +"info block read failed (%d), so try bootloader method\n", +error); + + error = mxt_lookup_bootloader_address(data, false); + if (error) { + dev_info(&client->dev, +"Bootloader address is not specified\n"); + return error; + } /* Check bootloader state */ - error = mxt_probe_bootloader(data, false); + error = mxt_probe_bootloader(data); if (error) { dev_info(&client->dev, "Trying alternate bootloader address\n"); - error = mxt_probe_bootloader(data, true); + mxt_lookup_bootloader_address(data, true); + error = mxt_probe_bootloader(data); if (error) { - /* Chip is not in appmode or bootloader mode */ + dev_err(&client->dev, + "Chip is not in appmode or bootloader mode\n"); return error; } } @@ -2953,7 +2961,9 @@ static int mxt_initialize(struct mxt_data *data) } /* Attempt to exit bootloader into app mode */ - mxt_send_bootloader_cmd(data, false); + error = mxt_send_bootloader_cmd(data, false); + if (error) + return error; msleep(MXT_FW_RESET_TIME); } @@ -3645,8 +3655,11 @@ static int mxt_enter_bootloader(struct mxt_data *data) msleep(MXT_RESET_TIME); + ret = mxt_lookup_bootloader_address(data, false); + if (ret) + return ret; /* Do not need to scan since we know family ID */ - ret = mxt_probe_bootloader(data, 0); + ret = mxt_probe_bootloader(data); if (ret) return ret; -- 2.19.2
[PATCH v1 45/63] Input: Atmel: improve error handling in mxt_start()
From: Deepak Das mxt_start() does not return error in any of the failure cases which will allow input_dev->open() to return success even in case of any failure. This commit modifies mxt_start() to return error in failure cases. Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 31 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ed5b98c067e8..232262736029 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -4043,12 +4043,13 @@ static int mxt_start(struct mxt_data *data) switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: - mxt_soft_reset(data); - + ret = mxt_soft_reset(data); + if (ret) + break; /* Touch enable */ /* 0x83 = SCANEN | RPTEN | ENABLE */ - mxt_write_object(data, - MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); + ret = mxt_write_object(data, + MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); break; case MXT_SUSPEND_REGULATOR: @@ -4062,27 +4063,26 @@ static int mxt_start(struct mxt_data *data) * Discard any touch messages still in message buffer * from before chip went to sleep */ - mxt_process_messages_until_invalid(data); + ret = mxt_process_messages_until_invalid(data); + if (ret) + break; ret = mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); if (ret) - return ret; + break; /* Recalibrate since chip has been in deep sleep */ ret = mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false); if (ret) - return ret; + break; ret = mxt_acquire_irq(data); - if (ret) - return ret; - - break; } - data->suspended = false; + if (!ret) + data->suspended = false; - return 0; + return ret; } static int mxt_stop(struct mxt_data *data) @@ -4511,6 +4511,7 @@ static int __maybe_unused mxt_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct mxt_data *data = i2c_get_clientdata(client); struct input_dev *input_dev = data->input_dev; + int ret = 0; if (!input_dev) return 0; @@ -4518,11 +4519,11 @@ static int __maybe_unused mxt_resume(struct device *dev) mutex_lock(&input_dev->mutex); if (input_dev->users) - mxt_start(data); + ret = mxt_start(data); mutex_unlock(&input_dev->mutex); - return 0; + return ret; } static SIMPLE_DEV_PM_OPS(mxt_pm_ops, mxt_suspend, mxt_resume); -- 2.19.2
[PATCH v1 47/63] Input: Atmel: improve error handling in mxt_update_cfg()
From: Deepak Das mxt_update_cfg() failed to propagate the error code from mxt_init_t7_power_cfg() so return the error code. Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 3999d3e31a6a..dec9f2b2c64d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2173,7 +2173,9 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) dev_info(dev, "Config successfully updated\n"); /* T7 config may have changed */ - mxt_init_t7_power_cfg(data); + ret = mxt_init_t7_power_cfg(data); + if (ret) + dev_warn(dev, "Power Config failed to update\n"); release_mem: kfree(cfg.mem); -- 2.19.2