[PATCH 4.9 00/39] 4.9.234-rc2 review

2020-08-24 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.234 release.
There are 39 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 Wed, 26 Aug 2020 16:47:07 +.
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.9.234-rc2.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.9.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.9.234-rc2

Will Deacon 
KVM: arm/arm64: Don't reschedule in unmap_stage2_range()

Juergen Gross 
xen: don't reschedule in preemption off sections

Peter Xu 
mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible

Al Viro 
do_epoll_ctl(): clean the failure exits up a bit

Marc Zyngier 
epoll: Keep a reference on files added to the check list

Michael Ellerman 
powerpc: Allow 4224 bytes of stack expansion for the signal frame

Vasant Hegde 
powerpc/pseries: Do not initiate shutdown when system is running on UPS

Tom Rix 
net: dsa: b53: check for timeout

Dinghao Liu 
ASoC: intel: Fix memleak in sst_media_open

Fugang Duan 
net: fec: correct the error path for regulator disable in probe

Przemyslaw Patynowski 
i40e: Set RX_ONLY mode for unicast promiscuous on VLAN

Eric Sandeen 
ext4: fix potential negative array index in do_split()

Luc Van Oostenryck 
alpha: fix annotation of io{read,write}{16,32}be()

Eiichi Tsukata 
xfs: Fix UBSAN null-ptr-deref in xfs_sysfs_init

Mao Wenan 
virtio_ring: Avoid loop when vq is broken in virtqueue_poll

Javed Hasan 
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases

Zhe Li 
jffs2: fix UAF problem

Darrick J. Wong 
xfs: fix inode quota reservation checks

Greg Ungerer 
m68knommu: fix overwriting of bits in ColdFire V3 cache control

Xiongfeng Wang 
Input: psmouse - add a newline when printing 'proto' by sysfs

Evgeny Novikov 
media: vpss: clean up resources in init

Chuhong Yuan 
media: budget-core: Improve exception handling in budget_register()

Stanley Chu 
scsi: ufs: Add DELAY_BEFORE_LPM quirk for Micron devices

Jan Kara 
ext4: fix checking of directory entry validity for inline directories

Eric Biggers 
ext4: clean up ext4_match() and callers

Charan Teja Reddy 
mm, page_alloc: fix core hung in free_pcppages_bulk()

Doug Berger 
mm: include CMA pages in lowmem_reserve at boot

Wei Yongjun 
kernel/relay.c: fix memleak on destroy relay channel

Jann Horn 
romfs: fix uninitialized memory leak in romfs_dev_read()

Josef Bacik 
btrfs: don't show full path of bind mounts in subvol=

Marcos Paulo de Souza 
btrfs: export helpers for subvolume name/id resolution

Hugh Dickins 
khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter()

Hugh Dickins 
khugepaged: khugepaged_test_exit() check mmget_still_valid()

Kevin Hao 
tracing/hwlat: Honor the tracing_cpumask

Steven Rostedt (VMware) 
tracing: Clean up the hwlat binding code

Masami Hiramatsu 
perf probe: Fix memory leakage when the probe point is not found

Liu Ying 
drm/imx: imx-ldb: Disable both channels for split mode in enc->disable()

Jan Beulich 
x86/asm: Add instruction suffixes to bitops

Uros Bizjak 
x86/asm: Remove unnecessary \n\t in front of CC_SET() from asm templates


-

Diffstat:

 Makefile  |  4 +-
 arch/alpha/include/asm/io.h   |  8 +-
 arch/arm/kvm/mmu.c|  6 --
 arch/m68k/include/asm/m53xxacr.h  |  6 +-
 arch/powerpc/mm/fault.c   |  7 +-
 arch/powerpc/platforms/pseries/ras.c  |  1 -
 arch/x86/include/asm/archrandom.h |  8 +-
 arch/x86/include/asm/bitops.h | 29 ---
 arch/x86/include/asm/percpu.h |  2 +-
 drivers/gpu/drm/imx/imx-ldb.c |  7 +-
 drivers/input/mouse/psmouse-base.c|  2 +-
 drivers/media/pci/ttpci/budget-core.c | 11 ++-
 drivers/media/platform/davinci/vpss.c | 20 -
 drivers/net/dsa/b53/b53_common.c  |  2 +
 drivers/net/ethernet/freescale/fec_main.c |  4 +-
 drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_common.c | 35 ++--
 drivers/scsi/libfc/fc_disc.c  | 12 ++-
 drivers/scsi/ufs/ufs_quirks.h |  1 +
 drivers/scsi/ufs/ufshcd.c |  2 +
 drivers/virtio/virtio_ring.c  |  3 +
 drivers/xen/preempt.c |  2 +-
 fs/btrfs/ctree.h

[PATCH 4.14 00/51] 4.14.195-rc2 review

2020-08-24 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.195 release.
There are 51 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 Wed, 26 Aug 2020 16:47:07 +.
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.195-rc2.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

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.14.195-rc2

Will Deacon 
KVM: arm/arm64: Don't reschedule in unmap_stage2_range()

Stephen Boyd 
clk: Evict unregistered clks from parent caches

Juergen Gross 
xen: don't reschedule in preemption off sections

Peter Xu 
mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible

Al Viro 
do_epoll_ctl(): clean the failure exits up a bit

Marc Zyngier 
epoll: Keep a reference on files added to the check list

Vasant Hegde 
powerpc/pseries: Do not initiate shutdown when system is running on UPS

Tom Rix 
net: dsa: b53: check for timeout

Haiyang Zhang 
hv_netvsc: Fix the queue_mapping in netvsc_vf_xmit()

Jiri Wiesner 
bonding: fix active-backup failover for current ARP slave

Alex Williamson 
vfio/type1: Add proper error unwind for vfio_iommu_replay()

Dinghao Liu 
ASoC: intel: Fix memleak in sst_media_open

Srinivas Kandagatla 
ASoC: msm8916-wcd-analog: fix register Interrupt offset

Cong Wang 
bonding: fix a potential double-unregister

Jarod Wilson 
bonding: show saner speed for broadcast mode

Fugang Duan 
net: fec: correct the error path for regulator disable in probe

Grzegorz Szczurek 
i40e: Fix crash during removing i40e driver

Przemyslaw Patynowski 
i40e: Set RX_ONLY mode for unicast promiscuous on VLAN

Eric Sandeen 
ext4: fix potential negative array index in do_split()

Luc Van Oostenryck 
alpha: fix annotation of io{read,write}{16,32}be()

Eiichi Tsukata 
xfs: Fix UBSAN null-ptr-deref in xfs_sysfs_init

Mao Wenan 
virtio_ring: Avoid loop when vq is broken in virtqueue_poll

Javed Hasan 
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases

Srinivas Pandruvada 
cpufreq: intel_pstate: Fix cpuinfo_max_freq when MSR_TURBO_RATIO_LIMIT is 0

Zhe Li 
jffs2: fix UAF problem

Darrick J. Wong 
xfs: fix inode quota reservation checks

Greg Ungerer 
m68knommu: fix overwriting of bits in ColdFire V3 cache control

Xiongfeng Wang 
Input: psmouse - add a newline when printing 'proto' by sysfs

Evgeny Novikov 
media: vpss: clean up resources in init

Huacai Chen 
rtc: goldfish: Enable interrupt in set_alarm() when necessary

Chuhong Yuan 
media: budget-core: Improve exception handling in budget_register()

Stanley Chu 
scsi: ufs: Add DELAY_BEFORE_LPM quirk for Micron devices

Lukas Wunner 
spi: Prevent adding devices below an unregistering controller

Yang Shi 
mm/memory.c: skip spurious TLB flush for retried page fault

zhangyi (F) 
jbd2: add the missing unlock_buffer() in the error path of 
jbd2_write_superblock()

Jan Kara 
ext4: fix checking of directory entry validity for inline directories

Charan Teja Reddy 
mm, page_alloc: fix core hung in free_pcppages_bulk()

Doug Berger 
mm: include CMA pages in lowmem_reserve at boot

Wei Yongjun 
kernel/relay.c: fix memleak on destroy relay channel

Jann Horn 
romfs: fix uninitialized memory leak in romfs_dev_read()

Josef Bacik 
btrfs: sysfs: use NOFS for device creation

Qu Wenruo 
btrfs: inode: fix NULL pointer dereference if inode doesn't need compression

Nikolay Borisov 
btrfs: Move free_pages_out label in inline extent handling branch in 
compress_file_range

Josef Bacik 
btrfs: don't show full path of bind mounts in subvol=

Marcos Paulo de Souza 
btrfs: export helpers for subvolume name/id resolution

Michael Ellerman 
powerpc: Allow 4224 bytes of stack expansion for the signal frame

Christophe Leroy 
powerpc/mm: Only read faulting instruction when necessary in do_page_fault()

Hugh Dickins 
khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter()

Hugh Dickins 
khugepaged: khugepaged_test_exit() check mmget_still_valid()

Masami Hiramatsu 
perf probe: Fix memory leakage when the probe point is not found

Chris Wilson 
drm/vgem: Replace opencoded version of drm_gem_dumb_map_offset()


-

Diffstat:

 Makefile  |  4 +-
 arch/alpha/include/asm/io.h   |  8 +--
 arch/m68k/include/asm/m53xxacr.h  |  6 +-
 arch/powerpc/mm/fault.c   | 55 --
 arch/powerpc/platforms/pseries/ras.c  

[PATCH v7 08/10] Drivers: hv: vmbus: Add hooks for per-CPU IRQ

2020-08-24 Thread Michael Kelley
Add hooks to enable/disable a per-CPU IRQ for VMbus. These hooks
are in the architecture independent setup and shutdown paths for
Hyper-V, and are needed by Linux guests on Hyper-V on ARM64.  The
x86/x64 implementation is null because VMbus interrupts on x86/x64
don't use an IRQ.

Signed-off-by: Michael Kelley 
---
 arch/x86/include/asm/mshyperv.h | 4 
 drivers/hv/hv.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index ffc2899..dd1365c 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -56,6 +56,10 @@ typedef int (*hyperv_fill_flush_list_func)(
 #define hv_get_raw_timer() rdtsc_ordered()
 #define hv_get_vector() HYPERVISOR_CALLBACK_VECTOR
 
+/* On x86/x64, there isn't a real IRQ to be enabled/disable */
+static inline void hv_enable_vmbus_irq(void) {}
+static inline void hv_disable_vmbus_irq(void) {}
+
 /*
  * Reference to pv_ops must be inline so objtool
  * detection of noinstr violations can work correctly.
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 2bd44fd..7499079 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -178,6 +178,7 @@ void hv_synic_enable_regs(unsigned int cpu)
hv_set_siefp(siefp.as_uint64);
 
/* Setup the shared SINT. */
+   hv_enable_vmbus_irq();
hv_get_synint_state(VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
shared_sint.vector = hv_get_vector();
@@ -235,6 +236,8 @@ void hv_synic_disable_regs(unsigned int cpu)
hv_get_synic_state(sctrl.as_uint64);
sctrl.enable = 0;
hv_set_synic_state(sctrl.as_uint64);
+
+   hv_disable_vmbus_irq();
 }
 
 int hv_synic_cleanup(unsigned int cpu)
-- 
1.8.3.1



[PATCH v7 07/10] arm64: hyperv: Initialize hypervisor on boot

2020-08-24 Thread Michael Kelley
Add ARM64-specific code to initialize the Hyper-V
hypervisor when booting as a guest VM. Provide functions
and data structures indicating hypervisor status that
are needed by VMbus driver.

This code is built only when CONFIG_HYPERV is enabled.

Signed-off-by: Michael Kelley 
---
 arch/arm64/hyperv/hv_core.c | 144 
 1 file changed, 144 insertions(+)

diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c
index 966d815..831a69c 100644
--- a/arch/arm64/hyperv/hv_core.c
+++ b/arch/arm64/hyperv/hv_core.c
@@ -18,10 +18,41 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
+static boolhyperv_initialized;
+
+struct ms_hyperv_info ms_hyperv __ro_after_init;
+EXPORT_SYMBOL_GPL(ms_hyperv);
+
+u32*hv_vp_index;
+EXPORT_SYMBOL_GPL(hv_vp_index);
+
+u32hv_max_vp_index;
+EXPORT_SYMBOL_GPL(hv_max_vp_index);
+
+static int hv_cpu_init(unsigned int cpu)
+{
+   u64 msr_vp_index;
+
+   msr_vp_index = hv_get_vpreg(HV_REGISTER_VPINDEX);
+
+   hv_vp_index[smp_processor_id()] = msr_vp_index;
+
+   if (msr_vp_index > hv_max_vp_index)
+   hv_max_vp_index = msr_vp_index;
+
+   return 0;
+}
 
 /*
  * Functions for allocating and freeing memory with size and
@@ -67,6 +98,107 @@ void hv_free_hyperv_page(unsigned long addr)
 
 
 /*
+ * This function is invoked via the ACPI clocksource probe mechanism. We
+ * don't actually use any values from the ACPI GTDT table, but we set up
+ * the Hyper-V synthetic clocksource and do other initialization for
+ * interacting with Hyper-V the first time.  Using early_initcall to invoke
+ * this function is too late because interrupts are already enabled at that
+ * point, and hv_init_clocksource() must run before interrupts are enabled.
+ *
+ * 1. Setup the guest ID.
+ * 2. Get features and hints info from Hyper-V
+ * 3. Setup per-cpu VP indices.
+ * 4. Initialize the Hyper-V clocksource.
+ */
+
+static int __init hyperv_init(struct acpi_table_header *table)
+{
+   struct hv_get_vp_registers_output result;
+   u32 a, b, c, d;
+   u64 guest_id;
+   int i, cpuhp;
+
+   /*
+* If we're in a VM on Hyper-V, the ACPI hypervisor_id field will
+* have the string "MsHyperV".
+*/
+   if (strncmp((char *)_gbl_FADT.hypervisor_id, "MsHyperV", 8))
+   return -EINVAL;
+
+   /* Setup the guest ID */
+   guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
+   hv_set_vpreg(HV_REGISTER_GUEST_OSID, guest_id);
+
+   /* Get the features and hints from Hyper-V */
+   hv_get_vpreg_128(HV_REGISTER_FEATURES, );
+   ms_hyperv.features = result.as32.a;
+   ms_hyperv.misc_features = result.as32.c;
+
+   hv_get_vpreg_128(HV_REGISTER_ENLIGHTENMENTS, );
+   ms_hyperv.hints = result.as32.a;
+
+   pr_info("Hyper-V: Features 0x%x, hints 0x%x, misc 0x%x\n",
+   ms_hyperv.features, ms_hyperv.hints, ms_hyperv.misc_features);
+
+   /*
+* If Hyper-V has crash notifications, set crash_kexec_post_notifiers
+* so that we will report the panic to Hyper-V before running kdump.
+*/
+   if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
+   crash_kexec_post_notifiers = true;
+
+   /* Get information about the Hyper-V host version */
+   hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION, );
+   a = result.as32.a;
+   b = result.as32.b;
+   c = result.as32.c;
+   d = result.as32.d;
+   pr_info("Hyper-V: Host Build %d.%d.%d.%d-%d-%d\n",
+   b >> 16, b & 0x, a, d & 0xFF, c, d >> 24);
+
+   /* Allocate and initialize percpu VP index array */
+   hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index),
+   GFP_KERNEL);
+   if (!hv_vp_index)
+   return -ENOMEM;
+
+   for (i = 0; i < num_possible_cpus(); i++)
+   hv_vp_index[i] = VP_INVAL;
+
+   cpuhp = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
+   "arm64/hyperv_init:online", hv_cpu_init, NULL);
+   if (cpuhp < 0)
+   goto free_vp_index;
+
+   hv_init_clocksource();
+   if (hv_stimer_alloc())
+   goto remove_cpuhp_state;
+
+   hyperv_initialized = true;
+   return 0;
+
+remove_cpuhp_state:
+   cpuhp_remove_state(cpuhp);
+free_vp_index:
+   kfree(hv_vp_index);
+   hv_vp_index = NULL;
+   return -EINVAL;
+}
+TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_init);
+
+/*
+ * This routine is called before kexec/kdump, it does the required cleanup.
+ */
+void hyperv_cleanup(void)
+{
+   /* Reset our OS id */
+   hv_set_vpreg(HV_REGISTER_GUEST_OSID, 0);
+
+}
+EXPORT_SYMBOL_GPL(hyperv_cleanup);
+
+
+/*
  * hv_do_hypercall- Invoke the specified hypercall
  */
 u64 hv_do_hypercall(u64 control, 

[PATCH 4.19 00/73] 4.19.142-rc2 review

2020-08-24 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.142 release.
There are 73 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 Wed, 26 Aug 2020 16:47:07 +.
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.19.142-rc2.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.19.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.19.142-rc2

Will Deacon 
KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set

Will Deacon 
KVM: Pass MMU notifier range flags to kvm_unmap_hva_range()

Stephen Boyd 
clk: Evict unregistered clks from parent caches

Juergen Gross 
xen: don't reschedule in preemption off sections

Peter Xu 
mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible

Al Viro 
do_epoll_ctl(): clean the failure exits up a bit

Marc Zyngier 
epoll: Keep a reference on files added to the check list

Li Heng 
efi: add missed destroy_workqueue when efisubsys_init fails

Vasant Hegde 
powerpc/pseries: Do not initiate shutdown when system is running on UPS

Tom Rix 
net: dsa: b53: check for timeout

Haiyang Zhang 
hv_netvsc: Fix the queue_mapping in netvsc_vf_xmit()

Wang Hai 
net: gemini: Fix missing free_netdev() in error path of 
gemini_ethernet_port_probe()

Shay Agroskin 
net: ena: Prevent reset after device destruction

Jiri Wiesner 
bonding: fix active-backup failover for current ARP slave

David Howells 
afs: Fix NULL deref in afs_dynroot_depopulate()

Selvin Xavier 
RDMA/bnxt_re: Do not add user qps to flushlist

Randy Dunlap 
Fix build error when CONFIG_ACPI is not set/enabled:

Juergen Gross 
efi: avoid error message when booting under Xen

Masahiro Yamada 
kconfig: qconf: fix signal connection to invalid slots

Masahiro Yamada 
kconfig: qconf: do not limit the pop-up menu to the first row

Jim Mattson 
kvm: x86: Toggling CR4.PKE does not load PDPTEs in PAE mode

Jim Mattson 
kvm: x86: Toggling CR4.SMAP does not load PDPTEs in PAE mode

Alex Williamson 
vfio/type1: Add proper error unwind for vfio_iommu_replay()

Dinghao Liu 
ASoC: intel: Fix memleak in sst_media_open

Srinivas Kandagatla 
ASoC: msm8916-wcd-analog: fix register Interrupt offset

Heiko Carstens 
s390/ptrace: fix storage key handling

Heiko Carstens 
s390/runtime_instrumentation: fix storage key handling

Cong Wang 
bonding: fix a potential double-unregister

Jarod Wilson 
bonding: show saner speed for broadcast mode

Fugang Duan 
net: fec: correct the error path for regulator disable in probe

Grzegorz Szczurek 
i40e: Fix crash during removing i40e driver

Przemyslaw Patynowski 
i40e: Set RX_ONLY mode for unicast promiscuous on VLAN

Srinivas Kandagatla 
ASoC: q6routing: add dummy register read/write function

Jan Kara 
ext4: don't allow overlapping system zones

Eric Sandeen 
ext4: fix potential negative array index in do_split()

Helge Deller 
fs/signalfd.c: fix inconsistent return codes for signalfd4

Luc Van Oostenryck 
alpha: fix annotation of io{read,write}{16,32}be()

Eiichi Tsukata 
xfs: Fix UBSAN null-ptr-deref in xfs_sysfs_init

Gaurav Singh 
tools/testing/selftests/cgroup/cgroup_util.c: cg_read_strcmp: fix null 
pointer dereference

Mao Wenan 
virtio_ring: Avoid loop when vq is broken in virtqueue_poll

Javed Hasan 
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases

Srinivas Pandruvada 
cpufreq: intel_pstate: Fix cpuinfo_max_freq when MSR_TURBO_RATIO_LIMIT is 0

Xiubo Li 
ceph: fix use-after-free for fsc->mdsc

Zhe Li 
jffs2: fix UAF problem

Darrick J. Wong 
xfs: fix inode quota reservation checks

Chuck Lever 
svcrdma: Fix another Receive buffer leak

Greg Ungerer 
m68knommu: fix overwriting of bits in ColdFire V3 cache control

Xiongfeng Wang 
Input: psmouse - add a newline when printing 'proto' by sysfs

Evgeny Novikov 
media: vpss: clean up resources in init

Huacai Chen 
rtc: goldfish: Enable interrupt in set_alarm() when necessary

Chuhong Yuan 
media: budget-core: Improve exception handling in budget_register()

Bodo Stroesser 
scsi: target: tcmu: Fix crash in tcmu_flush_dcache_range on ARM

Stanley Chu 
scsi: ufs: Add DELAY_BEFORE_LPM quirk for Micron devices

Lukas Wunner 
spi: Prevent adding devices below an unregistering controller

Liang Chen 
kthread: Do not preempt current task if it is going to call schedule()

Krunoslav Kovac 
drm/amd/display: fix pow() crashing when given base 0

Yang Shi 
mm/memory.c: skip spurious TLB flush for 

[PATCH v7 09/10] arm64: efi: Export screen_info

2020-08-24 Thread Michael Kelley
The Hyper-V frame buffer driver may be built as a module, and
it needs access to screen_info. So export screen_info.

Signed-off-by: Michael Kelley 
---
 arch/arm64/kernel/efi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index d0cf596..8ff557a 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -55,6 +55,7 @@ static __init pteval_t 
create_mapping_protection(efi_memory_desc_t *md)
 
 /* we will fill this structure from the stub, so don't put it in .bss */
 struct screen_info screen_info __section(.data);
+EXPORT_SYMBOL(screen_info);
 
 int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
 {
-- 
1.8.3.1



[PATCH v7 06/10] arm64: hyperv: Add kexec and panic handlers

2020-08-24 Thread Michael Kelley
Add functions to set up and remove kexec and panic
handlers, and to inform Hyper-V about a guest panic.
These functions are called from architecture independent
code in the VMbus driver.

This code is built only when CONFIG_HYPERV is enabled.

Signed-off-by: Michael Kelley 
---
 arch/arm64/hyperv/hv_core.c   | 80 +++
 arch/arm64/hyperv/mshyperv.c  | 26 +
 arch/arm64/include/asm/mshyperv.h |  2 +
 3 files changed, 108 insertions(+)

diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c
index 14e41b7..966d815 100644
--- a/arch/arm64/hyperv/hv_core.c
+++ b/arch/arm64/hyperv/hv_core.c
@@ -211,3 +211,83 @@ void hv_get_vpreg_128(u32 msr, struct 
hv_get_vp_registers_output *res)
kfree(output);
 }
 EXPORT_SYMBOL_GPL(hv_get_vpreg_128);
+
+
+/*
+ * hyperv_report_panic - report a panic to Hyper-V.  This function uses
+ * the older version of the Hyper-V interface that admittedly doesn't
+ * pass enough information to be useful beyond just recording the
+ * occurrence of a panic. The parallel hyperv_report_panic_msg() uses the
+ * new interface that allows reporting 4 Kbytes of data, which is much
+ * more useful. Hyper-V on ARM64 always supports the newer interface, but
+ * we retain support for the older version because the sysadmin is allowed
+ * to disable the newer version via sysctl in case of information security
+ * concerns about the more verbose version.
+ */
+void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die)
+{
+   static bool panic_reported;
+   u64 guest_id;
+
+   /* Don't report a panic to Hyper-V if we're not going to panic */
+   if (in_die && !panic_on_oops)
+   return;
+
+   /*
+* We prefer to report panic on 'die' chain as we have proper
+* registers to report, but if we miss it (e.g. on BUG()) we need
+* to report it on 'panic'.
+*
+* Calling code in the 'die' and 'panic' paths ensures that only
+* one CPU is running this code, so no atomicity is needed.
+*/
+   if (panic_reported)
+   return;
+   panic_reported = true;
+
+   guest_id = hv_get_vpreg(HV_REGISTER_GUEST_OSID);
+
+   /*
+* Hyper-V provides the ability to store only 5 values.
+* Pick the passed in error value, the guest_id, and the PC.
+* The first two general registers are added arbitrarily.
+*/
+   hv_set_vpreg(HV_REGISTER_CRASH_P0, err);
+   hv_set_vpreg(HV_REGISTER_CRASH_P1, guest_id);
+   hv_set_vpreg(HV_REGISTER_CRASH_P2, regs->pc);
+   hv_set_vpreg(HV_REGISTER_CRASH_P3, regs->regs[0]);
+   hv_set_vpreg(HV_REGISTER_CRASH_P4, regs->regs[1]);
+
+   /*
+* Let Hyper-V know there is crash data available
+*/
+   hv_set_vpreg(HV_REGISTER_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
+}
+EXPORT_SYMBOL_GPL(hyperv_report_panic);
+
+/*
+ * hyperv_report_panic_msg - report panic message to Hyper-V
+ * @pa: physical address of the panic page containing the message
+ * @size: size of the message in the page
+ */
+void hyperv_report_panic_msg(phys_addr_t pa, size_t size)
+{
+   /*
+* P3 to contain the physical address of the panic page & P4 to
+* contain the size of the panic data in that page. Rest of the
+* registers are no-op when the NOTIFY_MSG flag is set.
+*/
+   hv_set_vpreg(HV_REGISTER_CRASH_P0, 0);
+   hv_set_vpreg(HV_REGISTER_CRASH_P1, 0);
+   hv_set_vpreg(HV_REGISTER_CRASH_P2, 0);
+   hv_set_vpreg(HV_REGISTER_CRASH_P3, pa);
+   hv_set_vpreg(HV_REGISTER_CRASH_P4, size);
+
+   /*
+* Let Hyper-V know there is crash data available along with
+* the panic message.
+*/
+   hv_set_vpreg(HV_REGISTER_CRASH_CTL,
+  (HV_CRASH_CTL_CRASH_NOTIFY | HV_CRASH_CTL_CRASH_NOTIFY_MSG));
+}
+EXPORT_SYMBOL_GPL(hyperv_report_panic_msg);
diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c
index be2cd2f..5bd39cb 100644
--- a/arch/arm64/hyperv/mshyperv.c
+++ b/arch/arm64/hyperv/mshyperv.c
@@ -23,6 +23,8 @@
 
 static void (*vmbus_handler)(void);
 static void (*hv_stimer0_handler)(void);
+static void (*hv_kexec_handler)(void);
+static void (*hv_crash_handler)(struct pt_regs *regs);
 
 static int vmbus_irq;
 static long __percpu *vmbus_evt;
@@ -131,3 +133,27 @@ void hv_remove_stimer0_irq(int irq)
}
 }
 EXPORT_SYMBOL_GPL(hv_remove_stimer0_irq);
+
+void hv_setup_kexec_handler(void (*handler)(void))
+{
+   hv_kexec_handler = handler;
+}
+EXPORT_SYMBOL_GPL(hv_setup_kexec_handler);
+
+void hv_remove_kexec_handler(void)
+{
+   hv_kexec_handler = NULL;
+}
+EXPORT_SYMBOL_GPL(hv_remove_kexec_handler);
+
+void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs))
+{
+   hv_crash_handler = handler;
+}
+EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
+
+void hv_remove_crash_handler(void)
+{
+   hv_crash_handler = NULL;
+}

[PATCH 4.4 00/34] 4.4.234-rc2 review

2020-08-24 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.234 release.
There are 34 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 Wed, 26 Aug 2020 16:47:07 +.
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.4.234-rc2.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.4.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.4.234-rc2

Will Deacon 
KVM: arm/arm64: Don't reschedule in unmap_stage2_range()

Adam Ford 
omapfb: dss: Fix max fclk divider for omap36xx

Juergen Gross 
xen: don't reschedule in preemption off sections

Peter Xu 
mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible

Al Viro 
do_epoll_ctl(): clean the failure exits up a bit

Marc Zyngier 
epoll: Keep a reference on files added to the check list

Michael Ellerman 
powerpc: Allow 4224 bytes of stack expansion for the signal frame

Dinghao Liu 
ASoC: intel: Fix memleak in sst_media_open

Eric Sandeen 
ext4: fix potential negative array index in do_split()

Luc Van Oostenryck 
alpha: fix annotation of io{read,write}{16,32}be()

Eiichi Tsukata 
xfs: Fix UBSAN null-ptr-deref in xfs_sysfs_init

Mao Wenan 
virtio_ring: Avoid loop when vq is broken in virtqueue_poll

Javed Hasan 
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases

Zhe Li 
jffs2: fix UAF problem

Darrick J. Wong 
xfs: fix inode quota reservation checks

Greg Ungerer 
m68knommu: fix overwriting of bits in ColdFire V3 cache control

Xiongfeng Wang 
Input: psmouse - add a newline when printing 'proto' by sysfs

Evgeny Novikov 
media: vpss: clean up resources in init

Chuhong Yuan 
media: budget-core: Improve exception handling in budget_register()

Jan Kara 
ext4: fix checking of directory entry validity for inline directories

Eric Biggers 
ext4: clean up ext4_match() and callers

Charan Teja Reddy 
mm, page_alloc: fix core hung in free_pcppages_bulk()

Doug Berger 
mm: include CMA pages in lowmem_reserve at boot

Jann Horn 
romfs: fix uninitialized memory leak in romfs_dev_read()

Josef Bacik 
btrfs: don't show full path of bind mounts in subvol=

Marcos Paulo de Souza 
btrfs: export helpers for subvolume name/id resolution

Hugh Dickins 
khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter()

Hugh Dickins 
khugepaged: khugepaged_test_exit() check mmget_still_valid()

Andrea Arcangeli 
coredump: fix race condition between collapse_huge_page() and core dumping

Ahmad Fatoum 
watchdog: f71808e_wdt: remove use of wrong watchdog_info option

Ahmad Fatoum 
watchdog: f71808e_wdt: indicate WDIOF_CARDRESET support in 
watchdog_info.options

Kees Cook 
net/compat: Add missing sock updates for SCM_RIGHTS

Masami Hiramatsu 
perf probe: Fix memory leakage when the probe point is not found

Liu Ying 
drm/imx: imx-ldb: Disable both channels for split mode in enc->disable()


-

Diffstat:

 Makefile |  4 +-
 arch/alpha/include/asm/io.h  |  8 +--
 arch/arm/kvm/mmu.c   |  8 ---
 arch/m68k/include/asm/m53xxacr.h |  6 +-
 arch/powerpc/mm/fault.c  |  7 +-
 drivers/gpu/drm/imx/imx-ldb.c|  7 +-
 drivers/input/mouse/psmouse-base.c   |  2 +-
 drivers/media/pci/ttpci/budget-core.c| 11 +++-
 drivers/media/platform/davinci/vpss.c| 20 --
 drivers/scsi/libfc/fc_disc.c | 12 +++-
 drivers/video/fbdev/omap2/dss/dss.c  |  2 +-
 drivers/virtio/virtio_ring.c |  3 +
 drivers/watchdog/f71808e_wdt.c   |  6 +-
 drivers/xen/preempt.c|  2 +-
 fs/btrfs/ctree.h |  2 +
 fs/btrfs/export.c|  8 +--
 fs/btrfs/export.h|  5 ++
 fs/btrfs/super.c | 18 +++--
 fs/eventpoll.c   | 19 +++---
 fs/ext4/namei.c  | 99 +++-
 fs/jffs2/dir.c   |  6 +-
 fs/romfs/storage.c   |  4 +-
 fs/xfs/xfs_sysfs.h   |  6 +-
 fs/xfs/xfs_trans_dquot.c |  2 +-
 include/linux/mm.h   |  4 ++
 include/net/sock.h   |  4 ++
 mm/huge_memory.c |  4 +-
 mm/hugetlb.c | 25 ---
 mm/page_alloc.c  |  7 +-
 net/compat.c 

[PATCH v7 10/10] Drivers: hv: Enable Hyper-V code to be built on ARM64

2020-08-24 Thread Michael Kelley
Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on
ARM64, causing the Hyper-V specific code to be built.

Signed-off-by: Michael Kelley 
---
 drivers/hv/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 79e5356..1113e49 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
tristate "Microsoft Hyper-V client drivers"
-   depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
+   depends on ACPI && \
+   ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) || ARM64)
select PARAVIRT
select X86_HV_CALLBACK_VECTOR
help
-- 
1.8.3.1



[PATCH 5.4 000/109] 5.4.61-rc2 review

2020-08-24 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.61 release.
There are 109 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 Wed, 26 Aug 2020 16:47:07 +.
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.4.61-rc2.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.4.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 5.4.61-rc2

Will Deacon 
KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set

Will Deacon 
KVM: Pass MMU notifier range flags to kvm_unmap_hva_range()

Juergen Gross 
xen: don't reschedule in preemption off sections

Peter Xu 
mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible

Al Viro 
do_epoll_ctl(): clean the failure exits up a bit

Marc Zyngier 
epoll: Keep a reference on files added to the check list

Li Heng 
efi: add missed destroy_workqueue when efisubsys_init fails

Vasant Hegde 
powerpc/pseries: Do not initiate shutdown when system is running on UPS

Tom Rix 
net: dsa: b53: check for timeout

Haiyang Zhang 
hv_netvsc: Fix the queue_mapping in netvsc_vf_xmit()

Wang Hai 
net: gemini: Fix missing free_netdev() in error path of 
gemini_ethernet_port_probe()

Shay Agroskin 
net: ena: Prevent reset after device destruction

Jiri Wiesner 
bonding: fix active-backup failover for current ARP slave

Stephen Boyd 
ARM64: vdso32: Install vdso32 from vdso_install

David Howells 
afs: Fix NULL deref in afs_dynroot_depopulate()

Selvin Xavier 
RDMA/bnxt_re: Do not add user qps to flushlist

Randy Dunlap 
Fix build error when CONFIG_ACPI is not set/enabled:

Juergen Gross 
efi: avoid error message when booting under Xen

Masahiro Yamada 
kconfig: qconf: fix signal connection to invalid slots

Masahiro Yamada 
kconfig: qconf: do not limit the pop-up menu to the first row

Quinn Tran 
Revert "scsi: qla2xxx: Disable T10-DIF feature with FC-NVMe during probe"

Jim Mattson 
kvm: x86: Toggling CR4.PKE does not load PDPTEs in PAE mode

Jim Mattson 
kvm: x86: Toggling CR4.SMAP does not load PDPTEs in PAE mode

Alex Williamson 
vfio/type1: Add proper error unwind for vfio_iommu_replay()

Dinghao Liu 
ASoC: intel: Fix memleak in sst_media_open

Srinivas Kandagatla 
ASoC: msm8916-wcd-analog: fix register Interrupt offset

Heiko Carstens 
s390/ptrace: fix storage key handling

Heiko Carstens 
s390/runtime_instrumentation: fix storage key handling

Cong Wang 
bonding: fix a potential double-unregister

Zhang Changzhong 
can: j1939: add rxtimer for multipacket broadcast session

Zhang Changzhong 
can: j1939: abort multipacket broadcast session when timeout occurs

Zhang Changzhong 
can: j1939: cancel rxtimer on multipacket broadcast session complete

Zhang Changzhong 
can: j1939: fix support for multipacket broadcast message

Jarod Wilson 
bonding: show saner speed for broadcast mode

Fugang Duan 
net: fec: correct the error path for regulator disable in probe

Grzegorz Szczurek 
i40e: Fix crash during removing i40e driver

Przemyslaw Patynowski 
i40e: Set RX_ONLY mode for unicast promiscuous on VLAN

Oleksij Rempel 
can: j1939: transport: add j1939_session_skb_find_by_offset() function

Oleksij Rempel 
can: j1939: transport: j1939_simple_recv(): ignore local J1939 messages 
send not by J1939 stack

Eric Dumazet 
can: j1939: fix kernel-infoleak in j1939_sk_sock2sockaddr_can()

John Fastabend 
bpf: sock_ops sk access may stomp registers when dst_reg = src_reg

Srinivas Kandagatla 
ASoC: q6routing: add dummy register read/write function

Srinivas Kandagatla 
ASoC: q6afe-dai: mark all widgets registers as SND_SOC_NOPM

Amelie Delaunay 
spi: stm32: fixes suspend/resume management

Stephen Suryaputra 
netfilter: nf_tables: nft_exthdr: the presence return value should be 
little-endian

Jan Kara 
ext4: don't allow overlapping system zones

Eric Sandeen 
ext4: fix potential negative array index in do_split()

Helge Deller 
fs/signalfd.c: fix inconsistent return codes for signalfd4

Luc Van Oostenryck 
alpha: fix annotation of io{read,write}{16,32}be()

Eiichi Tsukata 
xfs: Fix UBSAN null-ptr-deref in xfs_sysfs_init

Gaurav Singh 
tools/testing/selftests/cgroup/cgroup_util.c: cg_read_strcmp: fix null 
pointer dereference

Evgeny Novikov 
media: camss: fix memory leaks on error handling paths in probe

Mao Wenan 
virtio_ring: Avoid loop when vq is broken in virtqueue_poll

Javed Hasan 
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases

Srinivas 

[PATCH AUTOSEL 4.19 17/21] scsi: qla2xxx: Fix null pointer access during disconnect from subsystem

2020-08-24 Thread Sasha Levin
From: Quinn Tran 

[ Upstream commit 83949613fac61e8e37eadf8275bf072342302f4e ]

NVMEAsync command is being submitted to QLA while the same NVMe controller
is in the middle of reset. The reset path has deleted the association and
freed aen_op->fcp_req.private. Add a check for this private pointer before
issuing the command.

...
 6 [b656ca11fce0] page_fault at 8c00114e
[exception RIP: qla_nvme_post_cmd+394]
RIP: c0d012ba  RSP: b656ca11fd98  RFLAGS: 00010206
RAX: 8fb039eda228  RBX: 8fb039eda200  RCX: 000da161
RDX: c0d4d0f0  RSI: c0d26c9b  RDI: 8fb039eda220
RBP: 0013   R8: 8fb47ff6aa80   R9: 0002
R10:   R11: b656ca11fdc8  R12: 8fb27d04a3b0
R13: 8fc46dd98a58  R14:   R15: 8fc4540f
ORIG_RAX:   CS: 0010  SS: 0018
 7 [b656ca11fe08] nvme_fc_start_fcp_op at c0241568 [nvme_fc]
 8 [b656ca11fe50] nvme_fc_submit_async_event at c0241901 [nvme_fc]
 9 [b656ca11fe68] nvme_async_event_work at c014543d [nvme_core]
10 [b656ca11fe98] process_one_work at 8b6cd437
11 [b656ca11fed8] worker_thread at 8b6cdcef
12 [b656ca11ff10] kthread at 8b6d3402
13 [b656ca11ff50] ret_from_fork at 8c000255

--
PID: 37824  TASK: 8fb033063d80  CPU: 20  COMMAND: "kworker/u97:451"
 0 [b656ce1abc28] __schedule at 8be629e3
 1 [b656ce1abcc8] schedule at 8be62fe8
 2 [b656ce1abcd0] schedule_timeout at 8be671ed
 3 [b656ce1abd70] wait_for_completion at 8be639cf
 4 [b656ce1abdd0] flush_work at 8b6ce2d5
 5 [b656ce1abe70] nvme_stop_ctrl at c0144900 [nvme_core]
 6 [b656ce1abe80] nvme_fc_reset_ctrl_work at c0243445 [nvme_fc]
 7 [b656ce1abe98] process_one_work at 8b6cd437
 8 [b656ce1abed8] worker_thread at 8b6cdb50
 9 [b656ce1abf10] kthread at 8b6d3402
10 [b656ce1abf50] ret_from_fork at 8c000255

Link: https://lore.kernel.org/r/20200806111014.28434-10-njav...@marvell.com
Reviewed-by: Himanshu Madhani 
Signed-off-by: Quinn Tran 
Signed-off-by: Nilesh Javali 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 5590d6e8b5762..3e2f8ce1d9a97 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -477,6 +477,11 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
struct nvme_private *priv = fd->private;
struct qla_nvme_rport *qla_rport = rport->private;
 
+   if (!priv) {
+   /* nvme association has been torn down */
+   return rval;
+   }
+
fcport = qla_rport->fcport;
 
vha = fcport->vha;
-- 
2.25.1



[PATCH AUTOSEL 4.19 18/21] Revert "scsi: qla2xxx: Fix crash on qla2x00_mailbox_command"

2020-08-24 Thread Sasha Levin
From: Saurav Kashyap 

[ Upstream commit de7e6194301ad31c4ce95395eb678e51a1b907e5 ]

FCoE adapter initialization failed for ISP8021 with the following patch
applied. In addition, reproduction of the issue the patch originally tried
to address has been unsuccessful.

This reverts commit 3cb182b3fa8b7a61f05c671525494697cba39c6a.

Link: https://lore.kernel.org/r/20200806111014.28434-11-njav...@marvell.com
Reviewed-by: Himanshu Madhani 
Signed-off-by: Saurav Kashyap 
Signed-off-by: Nilesh Javali 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/qla2xxx/qla_mbx.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index ac5d2d34aeeae..07c5d7397d425 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -329,14 +329,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
*mcp)
if (time_after(jiffies, wait_time))
break;
 
-   /*
-* Check if it's UNLOADING, cause we cannot poll in
-* this case, or else a NULL pointer dereference
-* is triggered.
-*/
-   if (unlikely(test_bit(UNLOADING, _vha->dpc_flags)))
-   return QLA_FUNCTION_TIMEOUT;
-
/* Check for pending interrupts. */
qla2x00_poll(ha->rsp_q_map[0]);
 
-- 
2.25.1



[PATCH AUTOSEL 4.19 20/21] net: gianfar: Add of_node_put() before goto statement

2020-08-24 Thread Sasha Levin
From: Sumera Priyadarsini 

[ Upstream commit 989e4da042ca4a56bbaca9223d1a93639ad11e17 ]

Every iteration of for_each_available_child_of_node() decrements
reference count of the previous node, however when control
is transferred from the middle of the loop, as in the case of
a return or break or goto, there is no decrement thus ultimately
resulting in a memory leak.

Fix a potential memory leak in gianfar.c by inserting of_node_put()
before the goto statement.

Issue found with Coccinelle.

Signed-off-by: Sumera Priyadarsini 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/gianfar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index cf2d1e846a692..8243501c37574 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -844,8 +844,10 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
continue;
 
err = gfar_parse_group(child, priv, model);
-   if (err)
+   if (err) {
+   of_node_put(child);
goto err_grp_init;
+   }
}
} else { /* SQ_SG_MODE */
err = gfar_parse_group(np, priv, model);
-- 
2.25.1



[PATCH AUTOSEL 4.19 19/21] macvlan: validate setting of multiple remote source MAC addresses

2020-08-24 Thread Sasha Levin
From: Alvin Šipraga 

[ Upstream commit 8b61fba503904acae24aeb2bd5569b4d6544d48f ]

Remote source MAC addresses can be set on a 'source mode' macvlan
interface via the IFLA_MACVLAN_MACADDR_DATA attribute. This commit
tightens the validation of these MAC addresses to match the validation
already performed when setting or adding a single MAC address via the
IFLA_MACVLAN_MACADDR attribute.

iproute2 uses IFLA_MACVLAN_MACADDR_DATA for its 'macvlan macaddr set'
command, and IFLA_MACVLAN_MACADDR for its 'macvlan macaddr add' command,
which demonstrates the inconsistent behaviour that this commit
addresses:

 # ip link add link eth0 name macvlan0 type macvlan mode source
 # ip link set link dev macvlan0 type macvlan macaddr add 01:00:00:00:00:00
 RTNETLINK answers: Cannot assign requested address
 # ip link set link dev macvlan0 type macvlan macaddr set 01:00:00:00:00:00
 # ip -d link show macvlan0
 5: macvlan0@eth0:  mtu 1500 ...
 link/ether 2e:ac:fd:2d:69:f8 brd ff:ff:ff:ff:ff:ff promiscuity 0
 macvlan mode source remotes (1) 01:00:00:00:00:00 numtxqueues 1 ...

With this change, the 'set' command will (rightly) fail in the same way
as the 'add' command.

Signed-off-by: Alvin Šipraga 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/macvlan.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 349123592af0f..e226a96da3a39 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1230,6 +1230,9 @@ static void macvlan_port_destroy(struct net_device *dev)
 static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
 {
+   struct nlattr *nla, *head;
+   int rem, len;
+
if (tb[IFLA_ADDRESS]) {
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
return -EINVAL;
@@ -1277,6 +1280,20 @@ static int macvlan_validate(struct nlattr *tb[], struct 
nlattr *data[],
return -EADDRNOTAVAIL;
}
 
+   if (data[IFLA_MACVLAN_MACADDR_DATA]) {
+   head = nla_data(data[IFLA_MACVLAN_MACADDR_DATA]);
+   len = nla_len(data[IFLA_MACVLAN_MACADDR_DATA]);
+
+   nla_for_each_attr(nla, head, len, rem) {
+   if (nla_type(nla) != IFLA_MACVLAN_MACADDR ||
+   nla_len(nla) != ETH_ALEN)
+   return -EINVAL;
+
+   if (!is_valid_ether_addr(nla_data(nla)))
+   return -EADDRNOTAVAIL;
+   }
+   }
+
if (data[IFLA_MACVLAN_MACADDR_COUNT])
return -EINVAL;
 
@@ -1333,10 +1350,6 @@ static int macvlan_changelink_sources(struct macvlan_dev 
*vlan, u32 mode,
len = nla_len(data[IFLA_MACVLAN_MACADDR_DATA]);
 
nla_for_each_attr(nla, head, len, rem) {
-   if (nla_type(nla) != IFLA_MACVLAN_MACADDR ||
-   nla_len(nla) != ETH_ALEN)
-   continue;
-
addr = nla_data(nla);
ret = macvlan_hash_add_source(vlan, addr);
if (ret)
-- 
2.25.1



[PATCH AUTOSEL 4.19 21/21] powerpc/perf: Fix soft lockups due to missed interrupt accounting

2020-08-24 Thread Sasha Levin
From: Athira Rajeev 

[ Upstream commit 17899eaf88d689529b866371344c8f269ba79b5f ]

Performance monitor interrupt handler checks if any counter has
overflown and calls record_and_restart() in core-book3s which invokes
perf_event_overflow() to record the sample information. Apart from
creating sample, perf_event_overflow() also does the interrupt and
period checks via perf_event_account_interrupt().

Currently we record information only if the SIAR (Sampled Instruction
Address Register) valid bit is set (using siar_valid() check) and
hence the interrupt check.

But it is possible that we do sampling for some events that are not
generating valid SIAR, and hence there is no chance to disable the
event if interrupts are more than max_samples_per_tick. This leads to
soft lockup.

Fix this by adding perf_event_account_interrupt() in the invalid SIAR
code path for a sampling event. ie if SIAR is invalid, just do
interrupt check and don't record the sample information.

Reported-by: Alexey Kardashevskiy 
Signed-off-by: Athira Rajeev 
Tested-by: Alexey Kardashevskiy 
Signed-off-by: Michael Ellerman 
Link: 
https://lore.kernel.org/r/1596717992-7321-1-git-send-email-atraj...@linux.vnet.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/perf/core-book3s.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 4004dbdab9c7b..d407b73298171 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2087,6 +2087,10 @@ static void record_and_restart(struct perf_event *event, 
unsigned long val,
 
if (perf_event_overflow(event, , regs))
power_pmu_stop(event, 0);
+   } else if (period) {
+   /* Account for interrupt in case of invalid SIAR */
+   if (perf_event_account_interrupt(event))
+   power_pmu_stop(event, 0);
}
 }
 
-- 
2.25.1



[PATCH AUTOSEL 4.14 02/11] ext4: don't BUG on inconsistent journal feature

2020-08-24 Thread Sasha Levin
From: Jan Kara 

[ Upstream commit 11215630aada28307ba555a43138db6ac54fa825 ]

A customer has reported a BUG_ON in ext4_clear_journal_err() hitting
during an LTP testing. Either this has been caused by a test setup
issue where the filesystem was being overwritten while LTP was mounting
it or the journal replay has overwritten the superblock with invalid
data. In either case it is preferable we don't take the machine down
with a BUG_ON. So handle the situation of unexpectedly missing
has_journal feature more gracefully. We issue warning and fail the mount
in the cases where the race window is narrow and the failed check is
most likely a programming error. In cases where fs corruption is more
likely, we do full ext4_error() handling before failing mount / remount.

Reviewed-by: Lukas Czerner 
Signed-off-by: Jan Kara 
Link: https://lore.kernel.org/r/20200710140759.18031-1-j...@suse.cz
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/ext4/super.c | 68 ++---
 1 file changed, 47 insertions(+), 21 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ffc985d781373..da0cb9a7d6fdc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -63,10 +63,10 @@ static int ext4_load_journal(struct super_block *, struct 
ext4_super_block *,
 unsigned long journal_devnum);
 static int ext4_show_options(struct seq_file *seq, struct dentry *root);
 static int ext4_commit_super(struct super_block *sb, int sync);
-static void ext4_mark_recovery_complete(struct super_block *sb,
+static int ext4_mark_recovery_complete(struct super_block *sb,
struct ext4_super_block *es);
-static void ext4_clear_journal_err(struct super_block *sb,
-  struct ext4_super_block *es);
+static int ext4_clear_journal_err(struct super_block *sb,
+ struct ext4_super_block *es);
 static int ext4_sync_fs(struct super_block *sb, int wait);
 static int ext4_remount(struct super_block *sb, int *flags, char *data);
 static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
@@ -4458,7 +4458,9 @@ static int ext4_fill_super(struct super_block *sb, void 
*data, int silent)
EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
if (needs_recovery) {
ext4_msg(sb, KERN_INFO, "recovery complete");
-   ext4_mark_recovery_complete(sb, es);
+   err = ext4_mark_recovery_complete(sb, es);
+   if (err)
+   goto failed_mount8;
}
if (EXT4_SB(sb)->s_journal) {
if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
@@ -4501,10 +4503,8 @@ static int ext4_fill_super(struct super_block *sb, void 
*data, int silent)
ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
goto failed_mount;
 
-#ifdef CONFIG_QUOTA
 failed_mount8:
ext4_unregister_sysfs(sb);
-#endif
 failed_mount7:
ext4_unregister_li_request(sb);
 failed_mount6:
@@ -4640,7 +4640,8 @@ static journal_t *ext4_get_journal(struct super_block *sb,
struct inode *journal_inode;
journal_t *journal;
 
-   BUG_ON(!ext4_has_feature_journal(sb));
+   if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
+   return NULL;
 
journal_inode = ext4_get_journal_inode(sb, journal_inum);
if (!journal_inode)
@@ -4670,7 +4671,8 @@ static journal_t *ext4_get_dev_journal(struct super_block 
*sb,
struct ext4_super_block *es;
struct block_device *bdev;
 
-   BUG_ON(!ext4_has_feature_journal(sb));
+   if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
+   return NULL;
 
bdev = ext4_blkdev_get(j_dev, sb);
if (bdev == NULL)
@@ -4762,7 +4764,8 @@ static int ext4_load_journal(struct super_block *sb,
int err = 0;
int really_read_only;
 
-   BUG_ON(!ext4_has_feature_journal(sb));
+   if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
+   return -EFSCORRUPTED;
 
if (journal_devnum &&
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
@@ -4831,7 +4834,12 @@ static int ext4_load_journal(struct super_block *sb,
}
 
EXT4_SB(sb)->s_journal = journal;
-   ext4_clear_journal_err(sb, es);
+   err = ext4_clear_journal_err(sb, es);
+   if (err) {
+   EXT4_SB(sb)->s_journal = NULL;
+   jbd2_journal_destroy(journal);
+   return err;
+   }
 
if (!really_read_only && journal_devnum &&
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
@@ -4930,26 +4938,32 @@ static int ext4_commit_super(struct super_block *sb, 
int sync)
  * remounting) the filesystem readonly, then we will end up with a
  * consistent fs on disk.  Record that fact.
  */
-static void ext4_mark_recovery_complete(struct super_block *sb,
-   struct ext4_super_block *es)

[PATCH AUTOSEL 4.14 01/11] jbd2: make sure jh have b_transaction set in refile/unfile_buffer

2020-08-24 Thread Sasha Levin
From: Lukas Czerner 

[ Upstream commit 24dc9864914eb5813173cfa53313fcd02e4aea7d ]

Callers of __jbd2_journal_unfile_buffer() and
__jbd2_journal_refile_buffer() assume that the b_transaction is set. In
fact if it's not, we can end up with journal_head refcounting errors
leading to crash much later that might be very hard to track down. Add
asserts to make sure that is the case.

We also make sure that b_next_transaction is NULL in
__jbd2_journal_unfile_buffer() since the callers expect that as well and
we should not get into that stage in this state anyway, leading to
problems later on if we do.

Tested with fstests.

Signed-off-by: Lukas Czerner 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/20200617092549.6712-1-lczer...@redhat.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/jbd2/transaction.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index a355ca418e788..b4bde0ae10948 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1914,6 +1914,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct 
journal_head *jh)
  */
 static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
 {
+   J_ASSERT_JH(jh, jh->b_transaction != NULL);
+   J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
+
__jbd2_journal_temp_unlink_buffer(jh);
jh->b_transaction = NULL;
jbd2_journal_put_journal_head(jh);
@@ -2461,6 +2464,13 @@ void __jbd2_journal_refile_buffer(struct journal_head 
*jh)
 
was_dirty = test_clear_buffer_jbddirty(bh);
__jbd2_journal_temp_unlink_buffer(jh);
+
+   /*
+* b_transaction must be set, otherwise the new b_transaction won't
+* be holding jh reference
+*/
+   J_ASSERT_JH(jh, jh->b_transaction != NULL);
+
/*
 * We set b_transaction here because b_next_transaction will inherit
 * our jh reference and thus __jbd2_journal_file_buffer() must not
-- 
2.25.1



[PATCH AUTOSEL 4.14 03/11] jbd2: abort journal if free a async write error metadata buffer

2020-08-24 Thread Sasha Levin
From: "zhangyi (F)" 

[ Upstream commit c044f3d8360d2ecf831ba2cc9f08cf9fb2c699fb ]

If we free a metadata buffer which has been failed to async write out
in the background, the jbd2 checkpoint procedure will not detect this
failure in jbd2_log_do_checkpoint(), so it may lead to filesystem
inconsistency after cleanup journal tail. This patch abort the journal
if free a buffer has write_io_error flag to prevent potential further
inconsistency.

Signed-off-by: zhangyi (F) 
Link: https://lore.kernel.org/r/20200620025427.1756360-5-yi.zh...@huawei.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/jbd2/transaction.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index b4bde0ae10948..3311b1e684def 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -2008,6 +2008,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
 {
struct buffer_head *head;
struct buffer_head *bh;
+   bool has_write_io_error = false;
int ret = 0;
 
J_ASSERT(PageLocked(page));
@@ -2032,11 +2033,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
jbd_unlock_bh_state(bh);
if (buffer_jbd(bh))
goto busy;
+
+   /*
+* If we free a metadata buffer which has been failed to
+* write out, the jbd2 checkpoint procedure will not detect
+* this failure and may lead to filesystem inconsistency
+* after cleanup journal tail.
+*/
+   if (buffer_write_io_error(bh)) {
+   pr_err("JBD2: Error while async write back metadata bh 
%llu.",
+  (unsigned long long)bh->b_blocknr);
+   has_write_io_error = true;
+   }
} while ((bh = bh->b_this_page) != head);
 
ret = try_to_free_buffers(page);
 
 busy:
+   if (has_write_io_error)
+   jbd2_journal_abort(journal, -EIO);
+
return ret;
 }
 
-- 
2.25.1



[PATCH AUTOSEL 4.14 06/11] s390/cio: add cond_resched() in the slow_eval_known_fn() loop

2020-08-24 Thread Sasha Levin
From: Vineeth Vijayan 

[ Upstream commit 0b8eb2ee9da1e8c9b8082f404f3948aa82a057b2 ]

The scanning through subchannels during the time of an event could
take significant amount of time in case of platforms with lots of
known subchannels. This might result in higher scheduling latencies
for other tasks especially on systems with a single CPU. Add
cond_resched() call, as the loop in slow_eval_known_fn() can be
executed for a longer duration.

Reviewed-by: Peter Oberparleiter 
Signed-off-by: Vineeth Vijayan 
Signed-off-by: Heiko Carstens 
Signed-off-by: Sasha Levin 
---
 drivers/s390/cio/css.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index dadff1838fec1..e2026d54dd375 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -581,6 +581,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void 
*data)
rc = css_evaluate_known_subchannel(sch, 1);
if (rc == -EAGAIN)
css_schedule_eval(sch->schid);
+   /*
+* The loop might take long time for platforms with lots of
+* known devices. Allow scheduling here.
+*/
+   cond_resched();
}
return 0;
 }
-- 
2.25.1



[PATCH AUTOSEL 4.14 07/11] scsi: ufs: Fix possible infinite loop in ufshcd_hold

2020-08-24 Thread Sasha Levin
From: Stanley Chu 

[ Upstream commit 93b6c5db06028a3b55122bbb74d0715dd8ca4ae0 ]

In ufshcd_suspend(), after clk-gating is suspended and link is set
as Hibern8 state, ufshcd_hold() is still possibly invoked before
ufshcd_suspend() returns. For example, MediaTek's suspend vops may
issue UIC commands which would call ufshcd_hold() during the command
issuing flow.

Now if UFSHCD_CAP_HIBERN8_WITH_CLK_GATING capability is enabled,
then ufshcd_hold() may enter infinite loops because there is no
clk-ungating work scheduled or pending. In this case, ufshcd_hold()
shall just bypass, and keep the link as Hibern8 state.

Link: https://lore.kernel.org/r/20200809050734.18740-1-stanley@mediatek.com
Reviewed-by: Avri Altman 
Co-developed-by: Andy Teng 
Signed-off-by: Andy Teng 
Signed-off-by: Stanley Chu 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1e2a97a10033b..8144a54371c35 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1423,6 +1423,7 @@ static void ufshcd_ungate_work(struct work_struct *work)
 int ufshcd_hold(struct ufs_hba *hba, bool async)
 {
int rc = 0;
+   bool flush_result;
unsigned long flags;
 
if (!ufshcd_is_clkgating_allowed(hba))
@@ -1454,7 +1455,9 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
break;
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
-   flush_work(>clk_gating.ungate_work);
+   flush_result = flush_work(>clk_gating.ungate_work);
+   if (hba->clk_gating.is_suspended && !flush_result)
+   goto out;
spin_lock_irqsave(hba->host->host_lock, flags);
goto start;
}
-- 
2.25.1



[PATCH AUTOSEL 4.14 05/11] spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate

2020-08-24 Thread Sasha Levin
From: Amelie Delaunay 

[ Upstream commit 9cc61973bf9385b19ff5dda4a2a7e265fcba85e4 ]

Fix spi->clk_rate when it is odd to the nearest lowest even value because
minimum SPI divider is 2.

Signed-off-by: Amelie Delaunay 
Signed-off-by: Alain Volmat 
Link: 
https://lore.kernel.org/r/1597043558-29668-4-git-send-email-alain.vol...@st.com
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-stm32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index ba9743fa2326d..179749f354c33 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -254,7 +254,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 
speed_hz)
 {
u32 div, mbrdiv;
 
-   div = DIV_ROUND_UP(spi->clk_rate, speed_hz);
+   /* Ensure spi->clk_rate is even */
+   div = DIV_ROUND_UP(spi->clk_rate & ~0x1, speed_hz);
 
/*
 * SPI framework set xfer->speed_hz to master->max_speed_hz if
-- 
2.25.1



[PATCH AUTOSEL 4.14 04/11] fs: prevent BUG_ON in submit_bh_wbc()

2020-08-24 Thread Sasha Levin
From: Xianting Tian 

[ Upstream commit 377254b2cd2252c7c3151b113cbdf93a7736c2e9 ]

If a device is hot-removed --- for example, when a physical device is
unplugged from pcie slot or a nbd device's network is shutdown ---
this can result in a BUG_ON() crash in submit_bh_wbc().  This is
because the when the block device dies, the buffer heads will have
their Buffer_Mapped flag get cleared, leading to the crash in
submit_bh_wbc.

We had attempted to work around this problem in commit a17712c8
("ext4: check superblock mapped prior to committing").  Unfortunately,
it's still possible to hit the BUG_ON(!buffer_mapped(bh)) if the
device dies between when the work-around check in ext4_commit_super()
and when submit_bh_wbh() is finally called:

Code path:
ext4_commit_super
judge if 'buffer_mapped(sbh)' is false, return <== commit a17712c8
  lock_buffer(sbh)
  ...
  unlock_buffer(sbh)
   __sync_dirty_buffer(sbh,...
lock_buffer(sbh)
judge if 'buffer_mapped(sbh))' is false, return <== 
added by this patch
submit_bh(...,sbh)
submit_bh_wbc(...,sbh,...)

[100722.966497] kernel BUG at fs/buffer.c:3095! <== BUG_ON(!buffer_mapped(bh))' 
in submit_bh_wbc()
[100722.966503] invalid opcode:  [#1] SMP
[100722.966566] task: 8817e15a9e40 task.stack: c90024744000
[100722.966574] RIP: 0010:submit_bh_wbc+0x180/0x190
[100722.966575] RSP: 0018:c90024747a90 EFLAGS: 00010246
[100722.966576] RAX: 00620005 RBX: 8818a80603a8 RCX: 

[100722.966576] RDX: 8818a80603a8 RSI: 00020800 RDI: 
0001
[100722.966577] RBP: c90024747ac0 R08:  R09: 
88207f94170d
[100722.966578] R10: 000437c8 R11: 0001 R12: 
00020800
[100722.966578] R13: 0001 R14: 0bf9a438 R15: 
88195f333000
[100722.966580] FS:  7fa2eee27700() GS:88203d84() 
knlGS:
[100722.966580] CS:  0010 DS:  ES:  CR0: 80050033
[100722.966581] CR2: 00f0b008 CR3: 00201a622003 CR4: 
007606e0
[100722.966582] DR0:  DR1:  DR2: 

[100722.966583] DR3:  DR6: fffe0ff0 DR7: 
0400
[100722.966583] PKRU: 5554
[100722.966583] Call Trace:
[100722.966588]  __sync_dirty_buffer+0x6e/0xd0
[100722.966614]  ext4_commit_super+0x1d8/0x290 [ext4]
[100722.966626]  __ext4_std_error+0x78/0x100 [ext4]
[100722.966635]  ? __ext4_journal_get_write_access+0xca/0x120 [ext4]
[100722.966646]  ext4_reserve_inode_write+0x58/0xb0 [ext4]
[100722.966655]  ? ext4_dirty_inode+0x48/0x70 [ext4]
[100722.93]  ext4_mark_inode_dirty+0x53/0x1e0 [ext4]
[100722.966671]  ? __ext4_journal_start_sb+0x6d/0xf0 [ext4]
[100722.966679]  ext4_dirty_inode+0x48/0x70 [ext4]
[100722.966682]  __mark_inode_dirty+0x17f/0x350
[100722.966686]  generic_update_time+0x87/0xd0
[100722.966687]  touch_atime+0xa9/0xd0
[100722.966690]  generic_file_read_iter+0xa09/0xcd0
[100722.966694]  ? page_cache_tree_insert+0xb0/0xb0
[100722.966704]  ext4_file_read_iter+0x4a/0x100 [ext4]
[100722.966707]  ? __inode_security_revalidate+0x4f/0x60
[100722.966709]  __vfs_read+0xec/0x160
[100722.966711]  vfs_read+0x8c/0x130
[100722.966712]  SyS_pread64+0x87/0xb0
[100722.966716]  do_syscall_64+0x67/0x1b0
[100722.966719]  entry_SYSCALL64_slow_path+0x25/0x25

To address this, add the check of 'buffer_mapped(bh)' to
__sync_dirty_buffer().  This also has the benefit of fixing this for
other file systems.

With this addition, we can drop the workaround in ext4_commit_supper().

[ Commit description rewritten by tytso. ]

Signed-off-by: Xianting Tian 
Link: 
https://lore.kernel.org/r/1596211825-8750-1-git-send-email-xianting_t...@126.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/buffer.c | 9 +
 fs/ext4/super.c | 7 ---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index cae7f24a0410e..9fbeddb6834a4 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3250,6 +3250,15 @@ int __sync_dirty_buffer(struct buffer_head *bh, int 
op_flags)
WARN_ON(atomic_read(>b_count) < 1);
lock_buffer(bh);
if (test_clear_buffer_dirty(bh)) {
+   /*
+* The bh should be mapped, but it might not be if the
+* device was hot-removed. Not much we can do but fail the I/O.
+*/
+   if (!buffer_mapped(bh)) {
+   unlock_buffer(bh);
+   return -EIO;
+   }
+
get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index da0cb9a7d6fdc..634c822d1dc98 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4861,13 +4861,6 @@ static int 

[PATCH AUTOSEL 4.9 1/8] jbd2: make sure jh have b_transaction set in refile/unfile_buffer

2020-08-24 Thread Sasha Levin
From: Lukas Czerner 

[ Upstream commit 24dc9864914eb5813173cfa53313fcd02e4aea7d ]

Callers of __jbd2_journal_unfile_buffer() and
__jbd2_journal_refile_buffer() assume that the b_transaction is set. In
fact if it's not, we can end up with journal_head refcounting errors
leading to crash much later that might be very hard to track down. Add
asserts to make sure that is the case.

We also make sure that b_next_transaction is NULL in
__jbd2_journal_unfile_buffer() since the callers expect that as well and
we should not get into that stage in this state anyway, leading to
problems later on if we do.

Tested with fstests.

Signed-off-by: Lukas Czerner 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/20200617092549.6712-1-lczer...@redhat.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/jbd2/transaction.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 8de458d64134a..1478512ecab3e 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1896,6 +1896,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct 
journal_head *jh)
  */
 static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
 {
+   J_ASSERT_JH(jh, jh->b_transaction != NULL);
+   J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
+
__jbd2_journal_temp_unlink_buffer(jh);
jh->b_transaction = NULL;
jbd2_journal_put_journal_head(jh);
@@ -2443,6 +2446,13 @@ void __jbd2_journal_refile_buffer(struct journal_head 
*jh)
 
was_dirty = test_clear_buffer_jbddirty(bh);
__jbd2_journal_temp_unlink_buffer(jh);
+
+   /*
+* b_transaction must be set, otherwise the new b_transaction won't
+* be holding jh reference
+*/
+   J_ASSERT_JH(jh, jh->b_transaction != NULL);
+
/*
 * We set b_transaction here because b_next_transaction will inherit
 * our jh reference and thus __jbd2_journal_file_buffer() must not
-- 
2.25.1



[PATCH AUTOSEL 4.14 10/11] net: gianfar: Add of_node_put() before goto statement

2020-08-24 Thread Sasha Levin
From: Sumera Priyadarsini 

[ Upstream commit 989e4da042ca4a56bbaca9223d1a93639ad11e17 ]

Every iteration of for_each_available_child_of_node() decrements
reference count of the previous node, however when control
is transferred from the middle of the loop, as in the case of
a return or break or goto, there is no decrement thus ultimately
resulting in a memory leak.

Fix a potential memory leak in gianfar.c by inserting of_node_put()
before the goto statement.

Issue found with Coccinelle.

Signed-off-by: Sumera Priyadarsini 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/gianfar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index e4a2c74a9b47e..6b95334e172d1 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -844,8 +844,10 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
continue;
 
err = gfar_parse_group(child, priv, model);
-   if (err)
+   if (err) {
+   of_node_put(child);
goto err_grp_init;
+   }
}
} else { /* SQ_SG_MODE */
err = gfar_parse_group(np, priv, model);
-- 
2.25.1



[GIT PULL] Btrfs fixes for 5.9-rc3

2020-08-24 Thread David Sterba
Hi,

a few more fixes. Please pull, Thanks.

- fix swapfile activation on subvolumes with deleted snapshots

- error value mixup when removing directory entries from tree log

- fix lzo compression level reset after previous level setting

- fix space cache memory leak after transaction abort

- fix const function attribute

- more error handling improvements


The following changes since commit c57dd1f2f6a7cd1bb61802344f59ccdc5278c983:

  btrfs: trim: fix underflow in trim length to prevent access beyond device 
boundary (2020-08-12 10:15:58 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-5.9-rc2-tag

for you to fetch changes up to a84d5d429f9eb56f81b388609841ed993f0ddfca:

  btrfs: detect nocow for swap after snapshot delete (2020-08-21 12:21:23 +0200)


Boris Burkov (1):
  btrfs: detect nocow for swap after snapshot delete

David Sterba (1):
  btrfs: use the correct const function attribute for btrfs_get_num_csums

Filipe Manana (1):
  btrfs: fix space cache memory leak after transaction abort

Johannes Thumshirn (1):
  btrfs: handle errors from async submission

Josef Bacik (1):
  btrfs: check the right error variable in btrfs_del_dir_entries_in_log

Marcos Paulo de Souza (1):
  btrfs: reset compression level for lzo on remount

 fs/btrfs/ctree.c|  2 +-
 fs/btrfs/ctree.h|  6 +++---
 fs/btrfs/disk-io.c  |  1 +
 fs/btrfs/extent-tree.c  | 17 +++--
 fs/btrfs/file.c |  2 +-
 fs/btrfs/free-space-cache.c |  2 +-
 fs/btrfs/inode.c| 29 ++---
 fs/btrfs/super.c|  1 +
 fs/btrfs/tree-log.c | 10 ++
 9 files changed, 39 insertions(+), 31 deletions(-)


[PATCH AUTOSEL 4.14 08/11] scsi: ufs: Improve interrupt handling for shared interrupts

2020-08-24 Thread Sasha Levin
From: Adrian Hunter 

[ Upstream commit 127d5f7c4b653b8be5eb3b2c7bbe13728f9003ff ]

For shared interrupts, the interrupt status might be zero, so check that
first.

Link: https://lore.kernel.org/r/20200811133936.19171-2-adrian.hun...@intel.com
Reviewed-by: Avri Altman 
Signed-off-by: Adrian Hunter 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 8144a54371c35..4eaecc3cdebc8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5371,7 +5371,7 @@ static void ufshcd_sl_intr(struct ufs_hba *hba, u32 
intr_status)
  */
 static irqreturn_t ufshcd_intr(int irq, void *__hba)
 {
-   u32 intr_status, enabled_intr_status;
+   u32 intr_status, enabled_intr_status = 0;
irqreturn_t retval = IRQ_NONE;
struct ufs_hba *hba = __hba;
int retries = hba->nutrs;
@@ -5385,7 +5385,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
 * read, make sure we handle them by checking the interrupt status
 * again in a loop until we process all of the reqs before returning.
 */
-   do {
+   while (intr_status && retries--) {
enabled_intr_status =
intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
if (intr_status)
@@ -5396,7 +5396,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
}
 
intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
-   } while (intr_status && --retries);
+   }
 
spin_unlock(hba->host->host_lock);
return retval;
-- 
2.25.1



[PATCH AUTOSEL 4.9 3/8] fs: prevent BUG_ON in submit_bh_wbc()

2020-08-24 Thread Sasha Levin
From: Xianting Tian 

[ Upstream commit 377254b2cd2252c7c3151b113cbdf93a7736c2e9 ]

If a device is hot-removed --- for example, when a physical device is
unplugged from pcie slot or a nbd device's network is shutdown ---
this can result in a BUG_ON() crash in submit_bh_wbc().  This is
because the when the block device dies, the buffer heads will have
their Buffer_Mapped flag get cleared, leading to the crash in
submit_bh_wbc.

We had attempted to work around this problem in commit a17712c8
("ext4: check superblock mapped prior to committing").  Unfortunately,
it's still possible to hit the BUG_ON(!buffer_mapped(bh)) if the
device dies between when the work-around check in ext4_commit_super()
and when submit_bh_wbh() is finally called:

Code path:
ext4_commit_super
judge if 'buffer_mapped(sbh)' is false, return <== commit a17712c8
  lock_buffer(sbh)
  ...
  unlock_buffer(sbh)
   __sync_dirty_buffer(sbh,...
lock_buffer(sbh)
judge if 'buffer_mapped(sbh))' is false, return <== 
added by this patch
submit_bh(...,sbh)
submit_bh_wbc(...,sbh,...)

[100722.966497] kernel BUG at fs/buffer.c:3095! <== BUG_ON(!buffer_mapped(bh))' 
in submit_bh_wbc()
[100722.966503] invalid opcode:  [#1] SMP
[100722.966566] task: 8817e15a9e40 task.stack: c90024744000
[100722.966574] RIP: 0010:submit_bh_wbc+0x180/0x190
[100722.966575] RSP: 0018:c90024747a90 EFLAGS: 00010246
[100722.966576] RAX: 00620005 RBX: 8818a80603a8 RCX: 

[100722.966576] RDX: 8818a80603a8 RSI: 00020800 RDI: 
0001
[100722.966577] RBP: c90024747ac0 R08:  R09: 
88207f94170d
[100722.966578] R10: 000437c8 R11: 0001 R12: 
00020800
[100722.966578] R13: 0001 R14: 0bf9a438 R15: 
88195f333000
[100722.966580] FS:  7fa2eee27700() GS:88203d84() 
knlGS:
[100722.966580] CS:  0010 DS:  ES:  CR0: 80050033
[100722.966581] CR2: 00f0b008 CR3: 00201a622003 CR4: 
007606e0
[100722.966582] DR0:  DR1:  DR2: 

[100722.966583] DR3:  DR6: fffe0ff0 DR7: 
0400
[100722.966583] PKRU: 5554
[100722.966583] Call Trace:
[100722.966588]  __sync_dirty_buffer+0x6e/0xd0
[100722.966614]  ext4_commit_super+0x1d8/0x290 [ext4]
[100722.966626]  __ext4_std_error+0x78/0x100 [ext4]
[100722.966635]  ? __ext4_journal_get_write_access+0xca/0x120 [ext4]
[100722.966646]  ext4_reserve_inode_write+0x58/0xb0 [ext4]
[100722.966655]  ? ext4_dirty_inode+0x48/0x70 [ext4]
[100722.93]  ext4_mark_inode_dirty+0x53/0x1e0 [ext4]
[100722.966671]  ? __ext4_journal_start_sb+0x6d/0xf0 [ext4]
[100722.966679]  ext4_dirty_inode+0x48/0x70 [ext4]
[100722.966682]  __mark_inode_dirty+0x17f/0x350
[100722.966686]  generic_update_time+0x87/0xd0
[100722.966687]  touch_atime+0xa9/0xd0
[100722.966690]  generic_file_read_iter+0xa09/0xcd0
[100722.966694]  ? page_cache_tree_insert+0xb0/0xb0
[100722.966704]  ext4_file_read_iter+0x4a/0x100 [ext4]
[100722.966707]  ? __inode_security_revalidate+0x4f/0x60
[100722.966709]  __vfs_read+0xec/0x160
[100722.966711]  vfs_read+0x8c/0x130
[100722.966712]  SyS_pread64+0x87/0xb0
[100722.966716]  do_syscall_64+0x67/0x1b0
[100722.966719]  entry_SYSCALL64_slow_path+0x25/0x25

To address this, add the check of 'buffer_mapped(bh)' to
__sync_dirty_buffer().  This also has the benefit of fixing this for
other file systems.

With this addition, we can drop the workaround in ext4_commit_supper().

[ Commit description rewritten by tytso. ]

Signed-off-by: Xianting Tian 
Link: 
https://lore.kernel.org/r/1596211825-8750-1-git-send-email-xianting_t...@126.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/buffer.c | 9 +
 fs/ext4/super.c | 7 ---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index a89be9741d125..52f1a60417d1d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3203,6 +3203,15 @@ int __sync_dirty_buffer(struct buffer_head *bh, int 
op_flags)
WARN_ON(atomic_read(>b_count) < 1);
lock_buffer(bh);
if (test_clear_buffer_dirty(bh)) {
+   /*
+* The bh should be mapped, but it might not be if the
+* device was hot-removed. Not much we can do but fail the I/O.
+*/
+   if (!buffer_mapped(bh)) {
+   unlock_buffer(bh);
+   return -EIO;
+   }
+
get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 370e4273042c5..472fa29c6f604 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4680,13 +4680,6 @@ static int 

[PATCH AUTOSEL 4.9 5/8] scsi: ufs: Fix possible infinite loop in ufshcd_hold

2020-08-24 Thread Sasha Levin
From: Stanley Chu 

[ Upstream commit 93b6c5db06028a3b55122bbb74d0715dd8ca4ae0 ]

In ufshcd_suspend(), after clk-gating is suspended and link is set
as Hibern8 state, ufshcd_hold() is still possibly invoked before
ufshcd_suspend() returns. For example, MediaTek's suspend vops may
issue UIC commands which would call ufshcd_hold() during the command
issuing flow.

Now if UFSHCD_CAP_HIBERN8_WITH_CLK_GATING capability is enabled,
then ufshcd_hold() may enter infinite loops because there is no
clk-ungating work scheduled or pending. In this case, ufshcd_hold()
shall just bypass, and keep the link as Hibern8 state.

Link: https://lore.kernel.org/r/20200809050734.18740-1-stanley@mediatek.com
Reviewed-by: Avri Altman 
Co-developed-by: Andy Teng 
Signed-off-by: Andy Teng 
Signed-off-by: Stanley Chu 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index af4b0a2021d6c..1eee82b18be4e 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -657,6 +657,7 @@ static void ufshcd_ungate_work(struct work_struct *work)
 int ufshcd_hold(struct ufs_hba *hba, bool async)
 {
int rc = 0;
+   bool flush_result;
unsigned long flags;
 
if (!ufshcd_is_clkgating_allowed(hba))
@@ -688,7 +689,9 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
break;
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
-   flush_work(>clk_gating.ungate_work);
+   flush_result = flush_work(>clk_gating.ungate_work);
+   if (hba->clk_gating.is_suspended && !flush_result)
+   goto out;
spin_lock_irqsave(hba->host->host_lock, flags);
goto start;
}
-- 
2.25.1



[PATCH AUTOSEL 4.14 11/11] powerpc/perf: Fix soft lockups due to missed interrupt accounting

2020-08-24 Thread Sasha Levin
From: Athira Rajeev 

[ Upstream commit 17899eaf88d689529b866371344c8f269ba79b5f ]

Performance monitor interrupt handler checks if any counter has
overflown and calls record_and_restart() in core-book3s which invokes
perf_event_overflow() to record the sample information. Apart from
creating sample, perf_event_overflow() also does the interrupt and
period checks via perf_event_account_interrupt().

Currently we record information only if the SIAR (Sampled Instruction
Address Register) valid bit is set (using siar_valid() check) and
hence the interrupt check.

But it is possible that we do sampling for some events that are not
generating valid SIAR, and hence there is no chance to disable the
event if interrupts are more than max_samples_per_tick. This leads to
soft lockup.

Fix this by adding perf_event_account_interrupt() in the invalid SIAR
code path for a sampling event. ie if SIAR is invalid, just do
interrupt check and don't record the sample information.

Reported-by: Alexey Kardashevskiy 
Signed-off-by: Athira Rajeev 
Tested-by: Alexey Kardashevskiy 
Signed-off-by: Michael Ellerman 
Link: 
https://lore.kernel.org/r/1596717992-7321-1-git-send-email-atraj...@linux.vnet.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/perf/core-book3s.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 3188040022c4f..78f75e48dfe7f 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2096,6 +2096,10 @@ static void record_and_restart(struct perf_event *event, 
unsigned long val,
 
if (perf_event_overflow(event, , regs))
power_pmu_stop(event, 0);
+   } else if (period) {
+   /* Account for interrupt in case of invalid SIAR */
+   if (perf_event_account_interrupt(event))
+   power_pmu_stop(event, 0);
}
 }
 
-- 
2.25.1



[PATCH AUTOSEL 4.9 2/8] jbd2: abort journal if free a async write error metadata buffer

2020-08-24 Thread Sasha Levin
From: "zhangyi (F)" 

[ Upstream commit c044f3d8360d2ecf831ba2cc9f08cf9fb2c699fb ]

If we free a metadata buffer which has been failed to async write out
in the background, the jbd2 checkpoint procedure will not detect this
failure in jbd2_log_do_checkpoint(), so it may lead to filesystem
inconsistency after cleanup journal tail. This patch abort the journal
if free a buffer has write_io_error flag to prevent potential further
inconsistency.

Signed-off-by: zhangyi (F) 
Link: https://lore.kernel.org/r/20200620025427.1756360-5-yi.zh...@huawei.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/jbd2/transaction.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 1478512ecab3e..cfbf5474bccab 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1990,6 +1990,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
 {
struct buffer_head *head;
struct buffer_head *bh;
+   bool has_write_io_error = false;
int ret = 0;
 
J_ASSERT(PageLocked(page));
@@ -2014,11 +2015,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
jbd_unlock_bh_state(bh);
if (buffer_jbd(bh))
goto busy;
+
+   /*
+* If we free a metadata buffer which has been failed to
+* write out, the jbd2 checkpoint procedure will not detect
+* this failure and may lead to filesystem inconsistency
+* after cleanup journal tail.
+*/
+   if (buffer_write_io_error(bh)) {
+   pr_err("JBD2: Error while async write back metadata bh 
%llu.",
+  (unsigned long long)bh->b_blocknr);
+   has_write_io_error = true;
+   }
} while ((bh = bh->b_this_page) != head);
 
ret = try_to_free_buffers(page);
 
 busy:
+   if (has_write_io_error)
+   jbd2_journal_abort(journal, -EIO);
+
return ret;
 }
 
-- 
2.25.1



[PATCH AUTOSEL 4.9 6/8] scsi: ufs: Improve interrupt handling for shared interrupts

2020-08-24 Thread Sasha Levin
From: Adrian Hunter 

[ Upstream commit 127d5f7c4b653b8be5eb3b2c7bbe13728f9003ff ]

For shared interrupts, the interrupt status might be zero, so check that
first.

Link: https://lore.kernel.org/r/20200811133936.19171-2-adrian.hun...@intel.com
Reviewed-by: Avri Altman 
Signed-off-by: Adrian Hunter 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1eee82b18be4e..b0841a3fab522 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4398,7 +4398,7 @@ static void ufshcd_sl_intr(struct ufs_hba *hba, u32 
intr_status)
  */
 static irqreturn_t ufshcd_intr(int irq, void *__hba)
 {
-   u32 intr_status, enabled_intr_status;
+   u32 intr_status, enabled_intr_status = 0;
irqreturn_t retval = IRQ_NONE;
struct ufs_hba *hba = __hba;
int retries = hba->nutrs;
@@ -4412,7 +4412,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
 * read, make sure we handle them by checking the interrupt status
 * again in a loop until we process all of the reqs before returning.
 */
-   do {
+   while (intr_status && retries--) {
enabled_intr_status =
intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
if (intr_status)
@@ -4423,7 +4423,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
}
 
intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
-   } while (intr_status && --retries);
+   }
 
spin_unlock(hba->host->host_lock);
return retval;
-- 
2.25.1



[PATCH AUTOSEL 4.9 7/8] net: gianfar: Add of_node_put() before goto statement

2020-08-24 Thread Sasha Levin
From: Sumera Priyadarsini 

[ Upstream commit 989e4da042ca4a56bbaca9223d1a93639ad11e17 ]

Every iteration of for_each_available_child_of_node() decrements
reference count of the previous node, however when control
is transferred from the middle of the loop, as in the case of
a return or break or goto, there is no decrement thus ultimately
resulting in a memory leak.

Fix a potential memory leak in gianfar.c by inserting of_node_put()
before the goto statement.

Issue found with Coccinelle.

Signed-off-by: Sumera Priyadarsini 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/gianfar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index b665d27f8e299..95ab44aa0eeab 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -844,8 +844,10 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
continue;
 
err = gfar_parse_group(child, priv, model);
-   if (err)
+   if (err) {
+   of_node_put(child);
goto err_grp_init;
+   }
}
} else { /* SQ_SG_MODE */
err = gfar_parse_group(np, priv, model);
-- 
2.25.1



Re: [PATCH stable v4.9 v2] arm64: entry: Place an SB sequence following an ERET instruction

2020-08-24 Thread Florian Fainelli




On 8/24/2020 9:32 AM, Will Deacon wrote:

Hi Florian,

On Fri, Aug 21, 2020 at 10:16:23AM -0700, Florian Fainelli wrote:

On 8/21/20 9:03 AM, Will Deacon wrote:

On Fri, Aug 07, 2020 at 03:14:29PM +0200, Greg KH wrote:

On Thu, Aug 06, 2020 at 01:00:54PM -0700, Florian Fainelli wrote:

Greg, did you have a chance to queue those changes for 4.9, 4.14 and 4.19?

https://lore.kernel.org/linux-arm-kernel/20200720182538.13304-1-f.faine...@gmail.com/
https://lore.kernel.org/linux-arm-kernel/20200720182937.14099-1-f.faine...@gmail.com/
https://lore.kernel.org/linux-arm-kernel/20200709195034.15185-1-f.faine...@gmail.com/


Nope, I was waiting for Will's "ack" for these.


This patch doesn't even build for me (the 'sb' macro is not defined in 4.9),
and I really wonder why we bother backporting it at all. Nobody's ever shown
it to be a problem in practice, and it's clear that this is just being
submitted to tick a box rather than anything else (otherwise it would build,
right?).


Doh, I completely missed submitting the patch this depended on that's
why I did not notice the build failure locally, sorry about that, what a
shame.

Would not be the same "tick a box" argument be used against your
original submission then? Sure, I have not been able to demonstrate in
real life this was a problem, however the same can be said about a lot
security related fixes.


Sort of, although I wrote the original patch because it was dead easy to do
and saved having to think too much about the problem, whereas the complexity
of backporting largerly diminishes that imo.


What if it becomes exploitable in the future, would not it be nice to
have it in a 6 year LTS kernel?


Even if people are stuck on an old LTS, they should still be taking the
regular updates for it, and we would obviously need to backport the fix if
it turned out to be exploitable (and hey, we could even test it then!).


So I'm not going to Ack any of them. As with a lot of this side-channel
stuff the cure is far worse than the disease.

Assuming that my v3 does build correctly, which it will, would you be
keen on changing your position?


Note that I'm not trying to block this patch from going in, I'm just saying
that I'm not supportive of it. Perhaps somebody from Arm can review it if
they think it's worth the effort.


How about I submit the actual full series (two patches) and we take the 
discussion from there?


Thanks for responding!
--
Florian


Re: [PATCH v2 1/2] PM / Domains: Add GENPD_FLAG_NO_SUSPEND/RESUME flags

2020-08-24 Thread Bjorn Andersson
On Fri 21 Aug 14:41 PDT 2020, Stephen Boyd wrote:

> Quoting Sibi Sankar (2020-08-21 13:49:20)
> > Add GENPD_FLAG_NO_SUSPEND/RESUME flags to instruct genpd to keep the
> > status of the PM domain unaltered during suspend/resume respectively.
> > The flags are aimed at power domains coupled to co-processors which
> > enter low-power modes independent to that of the application processor.
> > 
> > Specifically the flags are to be used by the power domains exposed
> > by the AOSS QMP driver linked to modem, adsp, cdsp remoteprocs. These
> > power domains are used to notify the Always on Subsystem (AOSS) that
> > a particular co-processor is up. AOSS uses this information to wait
> > for the co-processors to suspend before starting its sleep sequence.
> > The application processor powers off these power domains only if the
> > co-processor has crashed or powered off and remains unaltered during
> > system suspend/resume.
> 
> Why are these power domains instead of some QMP message sent during
> remote proc power up?

The understanding I gained as I researched this, was that with this
property enabled resources related to the particular subsystem will be
kept enabled when the apss enters some power save mode. So my
interpretation was that it does "keep something powered".

> If this has been discussed before feel free to
> disregard and please link to prior mailing list discussions.
> 

There where some discussions related to the "QDSS clk" in that series,
but I don't remember getting any feedback on modelling these things as
power-domains.

> I find it odd that this is modeled as a power domain instead of some
> Qualcomm specific message that the remoteproc driver sends to AOSS. Is
> there some sort of benefit the driver gets from using the power domain
> APIs for this vs. using a custom API?

We need to send "up" and "down" notifications and this needs to happen
at the same time as other standard resources are enabled/disabled.

Further more, at the time the all resources handled by the downstream
driver was either power-domains (per above understanding) or clocks, so
it made sense to me not to spin up a custom API.

Regards,
Bjorn


[PATCH AUTOSEL 5.8 33/63] ALSA: hda/realtek: Add model alc298-samsung-headphone

2020-08-24 Thread Sasha Levin
From: Mike Pozulp 

[ Upstream commit 23dc958689449be85e39351a8c809c3d344b155b ]

The very quiet and distorted headphone output bug that afflicted my
Samsung Notebook 9 is appearing in many other Samsung laptops. Expose
the quirk which fixed my laptop as a model so other users can try it.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207423
Signed-off-by: Mike Pozulp 
Link: https://lore.kernel.org/r/20200817043219.458889-1-pozulp.ker...@gmail.com
Signed-off-by: Takashi Iwai 
Signed-off-by: Sasha Levin 
---
 sound/pci/hda/patch_realtek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8626e59f1e6a9..ce9cf6013e9d3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7956,6 +7956,7 @@ static const struct hda_model_fixup alc269_fixup_models[] 
= {
{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
{.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
{.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = 
"alc256-medion-headset"},
+   {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = 
"alc298-samsung-headphone"},
{}
 };
 #define ALC225_STANDARD_PINS \
-- 
2.25.1



[PATCH AUTOSEL 4.4 2/6] jbd2: abort journal if free a async write error metadata buffer

2020-08-24 Thread Sasha Levin
From: "zhangyi (F)" 

[ Upstream commit c044f3d8360d2ecf831ba2cc9f08cf9fb2c699fb ]

If we free a metadata buffer which has been failed to async write out
in the background, the jbd2 checkpoint procedure will not detect this
failure in jbd2_log_do_checkpoint(), so it may lead to filesystem
inconsistency after cleanup journal tail. This patch abort the journal
if free a buffer has write_io_error flag to prevent potential further
inconsistency.

Signed-off-by: zhangyi (F) 
Link: https://lore.kernel.org/r/20200620025427.1756360-5-yi.zh...@huawei.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/jbd2/transaction.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 622610934c9ad..ce2bf9d74224c 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -2000,6 +2000,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
 {
struct buffer_head *head;
struct buffer_head *bh;
+   bool has_write_io_error = false;
int ret = 0;
 
J_ASSERT(PageLocked(page));
@@ -2024,11 +2025,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
jbd_unlock_bh_state(bh);
if (buffer_jbd(bh))
goto busy;
+
+   /*
+* If we free a metadata buffer which has been failed to
+* write out, the jbd2 checkpoint procedure will not detect
+* this failure and may lead to filesystem inconsistency
+* after cleanup journal tail.
+*/
+   if (buffer_write_io_error(bh)) {
+   pr_err("JBD2: Error while async write back metadata bh 
%llu.",
+  (unsigned long long)bh->b_blocknr);
+   has_write_io_error = true;
+   }
} while ((bh = bh->b_this_page) != head);
 
ret = try_to_free_buffers(page);
 
 busy:
+   if (has_write_io_error)
+   jbd2_journal_abort(journal, -EIO);
+
return ret;
 }
 
-- 
2.25.1



Re: [RFC] security: replace indirect calls with static calls

2020-08-24 Thread Casey Schaufler
On 8/24/2020 8:20 AM, Brendan Jackman wrote:
> On Fri, 21 Aug 2020 at 00:46, Casey Schaufler  wrote:
>> On 8/20/2020 9:47 AM, Brendan Jackman wrote:
> [...]
>> What does NOP really look like?
> The NOP is the same as a regular function call but the CALL
> instruction is replaced with a NOP instruction. The code that sets up
> the call parameters is unchanged, and so is the code that expects to
> get the return value in eax or whatever.

Right. Are you saying that NOP is in-line assembler in your switch?

> That means we cannot actually
> call the static_calls for NULL slots, we'd get undefined behaviour
> (except for void hooks) - this is what Peter is talking about in the
> sibling thread.

Referring to the "sibling thread" is kinda confusing, and
assumes everyone is one all the right mailing lists, and knows
which other thread you're talking about.

>
> For this reason, there are _no gaps_ in the callback table. For a
> given LSM hook, all the slots after base_slot_idx are filled,

Why go to all the trouble of maintaining the base_slot_idx
if NOP is so cheap? Why not fill all unused slots with NOP?
Worst case would be a hook with no users, in which case you
have 11 NOPS in the void hook case and 11 "if (ret != DEFAULT_RET)"
and 11 NOPS in the int case. No switch magic required. Even
better, in the int case you have two calls/slot, the first is the
module supplied function (or NOP) and the second is
int isit(int ret) { return (ret != DEFAULT_RET) ? ret : 0; }
(or NOP).

The no security module case degenerates to 22 NOP instructions
and no if checks of any sort. I'm not the performance guy, but
that seems better than maintaining and checking base_slot_idx
to me.
 

>  and all
> before are empty, so jumping to base_slot_idx ensures that we don't
> reach an empty slot. That's what the switch trick is all about.

I hates tricks. They're so susceptible to clever attacks.


>>> if ret != 0:
>> I assume you'd want "ret != DEFAULT_RET" instead of "ret != 0".
> Yeah that's a good question - but the existing behaviour is to always
> check against 0 (DEFAULT_RET is called IRC in the real code),
> which does seem strange.

If you don't do this correctly you'll make a real mess of the security.

>> So what goes in for empty slots? What about gaps in the table?
> It's a NOP, but we never execute it (explained above). There are no gaps.

Right. Unused slots have NOP. NOP is (assumed to be) cheap.


>>> +#define __UNROLL_MACRO_LOOP_20(MACRO, ...) \
>>> + __UNROLL_MACRO_LOOP_19(MACRO, __VA_ARGS__) \
>>> + MACRO(19, __VA_ARGS__)
>>> +
>> Where does "20" come from? Why are you unrolling beyond 11?
> It's just an arbitrary limit on the unrolling macro implementation, we
> aren't actually unrolling beyond 11 where the macro is used (N is set
> to 11).

I'm not a fan of including macros you can't use, especially
when they're just obvious variants of other macros.


>>>   With this use of the table and the
>>> switch, it is possible to jump directly to the first used slot and execute
>>> all of the slots after. This essentially makes the entry point of the table
>>> dynamic. Instead, it would also be possible to start from 0 and break after
>>> the final populated slot, but that would require an additional conditional
>>> after each slot.
>>>
>>> This macro is used to generate the code for each static slot, (e.g. each
>>> case statement in the previous example). This will expand into a call to
>>> MACRO for each static slot defined. For example, if with again 5 slots:
>>>
>>> SECURITY_FOREACH_STATIC_SLOT(MACRO, x, y) ->
>>>
>>>   MACRO(0, x, y)
>>>   MACRO(1, x, y)
>>>   MACRO(2, x, y)
>>>   MACRO(3, x, y)
>>>   MACRO(4, x, y)
>>>
>>> This is used in conjunction with LSM_HOOK definitions in
>>> linux/lsm_hook_defs.h to execute a macro for each static slot of each LSM
>>> hook.
>>>
>>> The patches for static calls [6] are not upstreamed yet.
>>>
>>> The number of available slots for each LSM hook is currently fixed at
>>> 11 (the number of LSMs in the kernel). Ideally, it should automatically
>>> adapt to the number of LSMs compiled into the kernel.
>> #define SECURITY_STATIC_SLOT_COUNT ( \
>> 1 + /* Capability module is always there */ \
>> (IS_ENABLED(CONFIG_SECURITY_SELINUX) ? 1 : 0) + \
>> (IS_ENABLED(CONFIG_SECURITY_SMACK) ? 1 : 0) + \
>> ... \
>> (IS_ENABLED(CONFIG_BPF_LSM) ? 1 : 0))
>>
> Yeah, that's exactly what we need but it needs to be expanded to an
> integer literal at preprocessor time, those +s won't work :(

 Gosh. It works in my module stacking code.


>>> If there’s no practical way to implement such automatic adaptation, an
>>> option instead would be to remove the panic call by falling-back to the old
>>> linked-list mechanism, which is still present anyway (see below).
>>>
>>> A few special cases of LSM don't use the macro call_[int/void]_hook but
>>> have their own calling logic. The linked-lists are kept as a 

[PATCH AUTOSEL 4.9 8/8] powerpc/perf: Fix soft lockups due to missed interrupt accounting

2020-08-24 Thread Sasha Levin
From: Athira Rajeev 

[ Upstream commit 17899eaf88d689529b866371344c8f269ba79b5f ]

Performance monitor interrupt handler checks if any counter has
overflown and calls record_and_restart() in core-book3s which invokes
perf_event_overflow() to record the sample information. Apart from
creating sample, perf_event_overflow() also does the interrupt and
period checks via perf_event_account_interrupt().

Currently we record information only if the SIAR (Sampled Instruction
Address Register) valid bit is set (using siar_valid() check) and
hence the interrupt check.

But it is possible that we do sampling for some events that are not
generating valid SIAR, and hence there is no chance to disable the
event if interrupts are more than max_samples_per_tick. This leads to
soft lockup.

Fix this by adding perf_event_account_interrupt() in the invalid SIAR
code path for a sampling event. ie if SIAR is invalid, just do
interrupt check and don't record the sample information.

Reported-by: Alexey Kardashevskiy 
Signed-off-by: Athira Rajeev 
Tested-by: Alexey Kardashevskiy 
Signed-off-by: Michael Ellerman 
Link: 
https://lore.kernel.org/r/1596717992-7321-1-git-send-email-atraj...@linux.vnet.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/perf/core-book3s.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index ba49ae6625f1b..a10b67df83bae 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2042,6 +2042,10 @@ static void record_and_restart(struct perf_event *event, 
unsigned long val,
 
if (perf_event_overflow(event, , regs))
power_pmu_stop(event, 0);
+   } else if (period) {
+   /* Account for interrupt in case of invalid SIAR */
+   if (perf_event_account_interrupt(event))
+   power_pmu_stop(event, 0);
}
 }
 
-- 
2.25.1



Re: [PATCH 0/4] Infiniband Subsystem: Remove pci-dma-compat wrapper APIs.

2020-08-24 Thread Jason Gunthorpe
On Sun, Aug 09, 2020 at 12:54:28PM +0530, Suraj Upadhyay wrote:
> Hii Developers,
> 
>   This patch series will replace all the legacy pci-dma-compat wrappers
> with the dma-mapping APIs directly in the INFINIBAND Subsystem.
> 
> This task is done through a coccinelle script which is described in each 
> commit
> message.
> 
> The changes are compile tested.
> 
> Thanks,
> 
> Suraj Upadhyay.
> 
> Suraj Upadhyay (4):
>   IB/hfi1: Remove pci-dma-compat wrapper APIs
>   IB/mthca: Remove pci-dma-compat wrapper APIs
>   RDMA/qib: Remove pci-dma-compat wrapper APIs
>   RDMA/pvrdma: Remove pci-dma-compat wrapper APIs

Aside from Joe's notes it doesn't apply either:

 Applying: RDMA/efa : Remove pci-dma-compat wrapper APIs
 Using index info to reconstruct a base tree...
 error: patch failed: drivers/infiniband/hw/efa/efa_main.c:405
 error: drivers/infiniband/hw/efa/efa_main.c: patch does not apply
 error: Did you hand edit your patch?
 It does not apply to blobs recorded in its index.

Try to avoid hand editing patches..

Please resend

Jason


[PATCH AUTOSEL 4.4 6/6] powerpc/perf: Fix soft lockups due to missed interrupt accounting

2020-08-24 Thread Sasha Levin
From: Athira Rajeev 

[ Upstream commit 17899eaf88d689529b866371344c8f269ba79b5f ]

Performance monitor interrupt handler checks if any counter has
overflown and calls record_and_restart() in core-book3s which invokes
perf_event_overflow() to record the sample information. Apart from
creating sample, perf_event_overflow() also does the interrupt and
period checks via perf_event_account_interrupt().

Currently we record information only if the SIAR (Sampled Instruction
Address Register) valid bit is set (using siar_valid() check) and
hence the interrupt check.

But it is possible that we do sampling for some events that are not
generating valid SIAR, and hence there is no chance to disable the
event if interrupts are more than max_samples_per_tick. This leads to
soft lockup.

Fix this by adding perf_event_account_interrupt() in the invalid SIAR
code path for a sampling event. ie if SIAR is invalid, just do
interrupt check and don't record the sample information.

Reported-by: Alexey Kardashevskiy 
Signed-off-by: Athira Rajeev 
Tested-by: Alexey Kardashevskiy 
Signed-off-by: Michael Ellerman 
Link: 
https://lore.kernel.org/r/1596717992-7321-1-git-send-email-atraj...@linux.vnet.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/perf/core-book3s.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 30e2e8efbe6b7..aab13558e9700 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2040,6 +2040,10 @@ static void record_and_restart(struct perf_event *event, 
unsigned long val,
 
if (perf_event_overflow(event, , regs))
power_pmu_stop(event, 0);
+   } else if (period) {
+   /* Account for interrupt in case of invalid SIAR */
+   if (perf_event_account_interrupt(event))
+   power_pmu_stop(event, 0);
}
 }
 
-- 
2.25.1



[PATCH AUTOSEL 4.4 3/6] s390/cio: add cond_resched() in the slow_eval_known_fn() loop

2020-08-24 Thread Sasha Levin
From: Vineeth Vijayan 

[ Upstream commit 0b8eb2ee9da1e8c9b8082f404f3948aa82a057b2 ]

The scanning through subchannels during the time of an event could
take significant amount of time in case of platforms with lots of
known subchannels. This might result in higher scheduling latencies
for other tasks especially on systems with a single CPU. Add
cond_resched() call, as the loop in slow_eval_known_fn() can be
executed for a longer duration.

Reviewed-by: Peter Oberparleiter 
Signed-off-by: Vineeth Vijayan 
Signed-off-by: Heiko Carstens 
Signed-off-by: Sasha Levin 
---
 drivers/s390/cio/css.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 8ecc956ecb59c..370a3a2c6de73 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -529,6 +529,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void 
*data)
rc = css_evaluate_known_subchannel(sch, 1);
if (rc == -EAGAIN)
css_schedule_eval(sch->schid);
+   /*
+* The loop might take long time for platforms with lots of
+* known devices. Allow scheduling here.
+*/
+   cond_resched();
}
return 0;
 }
-- 
2.25.1



[PATCH AUTOSEL 4.4 5/6] net: gianfar: Add of_node_put() before goto statement

2020-08-24 Thread Sasha Levin
From: Sumera Priyadarsini 

[ Upstream commit 989e4da042ca4a56bbaca9223d1a93639ad11e17 ]

Every iteration of for_each_available_child_of_node() decrements
reference count of the previous node, however when control
is transferred from the middle of the loop, as in the case of
a return or break or goto, there is no decrement thus ultimately
resulting in a memory leak.

Fix a potential memory leak in gianfar.c by inserting of_node_put()
before the goto statement.

Issue found with Coccinelle.

Signed-off-by: Sumera Priyadarsini 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/gianfar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index 37cc1f838dd8b..96310e2ee5458 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -845,8 +845,10 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
continue;
 
err = gfar_parse_group(child, priv, model);
-   if (err)
+   if (err) {
+   of_node_put(child);
goto err_grp_init;
+   }
}
} else { /* SQ_SG_MODE */
err = gfar_parse_group(np, priv, model);
-- 
2.25.1



RE: x86/kprobes: kretprobe fails to triggered if kprobe at function entry is not optimized (trigger by int3 breakpoint)

2020-08-24 Thread eddy...@trendmicro.com
> -Original Message-
> From: Masami Hiramatsu 
> Sent: Monday, August 24, 2020 11:54 PM
> To: Eddy Wu (RD-TW) 
> Cc: Peter Zijlstra ; linux-kernel@vger.kernel.org; 
> x...@kernel.org; David S. Miller 
> Subject: Re: x86/kprobes: kretprobe fails to triggered if kprobe at function 
> entry is not optimized (trigger by int3 breakpoint)
>
>
> This message was sent from outside of Trend Micro. Please do not click links 
> or open attachments unless you recognise the source of this
> email and know the content is safe.
>
>
> On Mon, 24 Aug 2020 12:02:58 +
> "eddy...@trendmicro.com"  wrote:
>
> > Greetings!
> >
> > Starting from kernel 5.8 (x86_64), kretprobe handler will always missed if 
> > corresponding kprobe on function entry is not optimized
> (using break point instead).
>
> Oops, good catch. I always enabled ftrace hook for kretprobe, I didn't 
> noticed that.
>
> > Step to reproduce this:
> > 1) Build the kretprobe example module (CONFIG_SAMPLE_KRETPROBES=m)
> > 2) Disable jump optimization (`sysctl debug.kprobes-optimization=0` or 
> > register any kprobe.post_handler at same location)
> > 3) Insert the kretprobe_example module
> > 4) Launch some process to trigger _do_fork
> > 5) Remove kretprobe_example module
> > 6) dmesg shows that all probing instances are missed
> >
> > Example output:
> > # sysctl debug.kprobes-optimization=0
> > debug.kprobes-optimization = 0
> > # insmod samples/kprobes/kretprobe_example.ko
> > # ls > /dev/null
> > # rmmod kretprobe_example
> > # dmesg
> > [48555.067295] Planted return probe at _do_fork: 38ae0211
> > [48560.229459] kretprobe at 38ae0211 unregistered
> > [48560.229460] Missed probing 3 instances of _do_fork
> >
> > After bisecting, I found this behavior seems to introduce by this commit: 
> > (5.8-rc1)
> > 0d00449c7a28a1514595630735df383dec606812 x86: Replace ist_enter() with 
> > nmi_enter()
> > This make kprobe_int3_handler() effectively running as NMI context, which 
> > pre_handler_kretprobe() explicitly checked to prevent
> recursion.
>
> Thanks for the bisecting!
>
> >
> > (in_nmi() check appears from v3.17)
> > f96f56780ca584930bb3a2769d73fd9a101bcbbe kprobes: Skip kretprobe hit in NMI 
> > context to avoid deadlock
> >
> > To make kretprobe work again with int3 breakpoint, I think we can replace 
> > the in_nmi() check with in_nmi() == (1 << NMI_SHIFT) at
> kprobe_int3_handler() and skip kretprobe if nested NMI.
>
> Ah, I see. Now int3 is a kind of NMI, so in the handler in_nmi() always 
> returns !0.
>
> > Did a quick test on 5.9-rc2 and it seems to be working.
> > I'm not sure if it is the best way to do since it may also require change 
> > to other architecture as well, any thought?
>
> Hmm, this behavior is arch-dependent. So I think we need an weak function 
> like this.
>
> @kernel/kprobes.c
>
> bool __weak arch_kprobe_in_nmi(void)
> {
> return in_nmi()
> }
>
> @arch/x86/kernel/kprobes/core.c
>
> bool arch_kprobe_in_nmi(void)
> {
>/*
> * Since the int3 is one of NMI, we have to check in_nmi() is
> * bigger than 1 << NMI_SHIFT instead of !0.
> */
>return in_nmi() > (1 << NMI_SHIFT);
> }
>
> And use arch_kprobe_in_nmi() instead of in_nmi() in kprobes.c.
>
> Thanks,
>
> --
> Masami Hiramatsu 

Kretprobe might still trigger from NMI with nmi counter == 1 (if entry kprobe 
is jump-optimized).
The arch- dependent weak function looks cleaner than doing this in 
kprobe_int3_handler() under x86/, but I don't know if there is a way to check 
if called by specific int3 handler or not.

My original patch below, need to change all architecture support kretprobe 
though

Thanks

---
 arch/x86/kernel/kprobes/core.c |  6 ++
 include/linux/kprobes.h|  1 +
 kernel/kprobes.c   | 13 +
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index fdadc37d72af..1b785aef85ef 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -699,6 +699,12 @@ int kprobe_int3_handler(struct pt_regs *regs)
 set_current_kprobe(p, regs, kcb);
 kcb->kprobe_status = KPROBE_HIT_ACTIVE;

+if (p->pre_handler == pre_handler_kretprobe && in_nmi() != (1 << NMI_SHIFT)) {
+struct kretprobe *rp = container_of(p, struct kretprobe, kp);
+rp->nmissed++;
+setup_singlestep(p, regs, kcb, 0);
+return 1;
+}
 /*
  * If we have no pre-handler or it returned 0, we
  * continue with normal processing.  If we have a
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 9be1bff4f586..3ded8e46ada5 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -494,5 +494,6 @@ static nokprobe_inline bool kprobe_page_fault(struct 
pt_regs *regs,
 return false;
 return kprobe_fault_handler(regs, trap);
 }
+int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs);

 #endif /* _LINUX_KPROBES_H */
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 

[PATCH AUTOSEL 4.19 14/21] scsi: ufs: Improve interrupt handling for shared interrupts

2020-08-24 Thread Sasha Levin
From: Adrian Hunter 

[ Upstream commit 127d5f7c4b653b8be5eb3b2c7bbe13728f9003ff ]

For shared interrupts, the interrupt status might be zero, so check that
first.

Link: https://lore.kernel.org/r/20200811133936.19171-2-adrian.hun...@intel.com
Reviewed-by: Avri Altman 
Signed-off-by: Adrian Hunter 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ff6912f9f49f7..72879280df776 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5603,7 +5603,7 @@ static void ufshcd_sl_intr(struct ufs_hba *hba, u32 
intr_status)
  */
 static irqreturn_t ufshcd_intr(int irq, void *__hba)
 {
-   u32 intr_status, enabled_intr_status;
+   u32 intr_status, enabled_intr_status = 0;
irqreturn_t retval = IRQ_NONE;
struct ufs_hba *hba = __hba;
int retries = hba->nutrs;
@@ -5617,7 +5617,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
 * read, make sure we handle them by checking the interrupt status
 * again in a loop until we process all of the reqs before returning.
 */
-   do {
+   while (intr_status && retries--) {
enabled_intr_status =
intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
if (intr_status)
@@ -5628,7 +5628,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
}
 
intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
-   } while (intr_status && --retries);
+   }
 
spin_unlock(hba->host->host_lock);
return retval;
-- 
2.25.1



[PATCH AUTOSEL 4.4 1/6] jbd2: make sure jh have b_transaction set in refile/unfile_buffer

2020-08-24 Thread Sasha Levin
From: Lukas Czerner 

[ Upstream commit 24dc9864914eb5813173cfa53313fcd02e4aea7d ]

Callers of __jbd2_journal_unfile_buffer() and
__jbd2_journal_refile_buffer() assume that the b_transaction is set. In
fact if it's not, we can end up with journal_head refcounting errors
leading to crash much later that might be very hard to track down. Add
asserts to make sure that is the case.

We also make sure that b_next_transaction is NULL in
__jbd2_journal_unfile_buffer() since the callers expect that as well and
we should not get into that stage in this state anyway, leading to
problems later on if we do.

Tested with fstests.

Signed-off-by: Lukas Czerner 
Reviewed-by: Jan Kara 
Link: https://lore.kernel.org/r/20200617092549.6712-1-lczer...@redhat.com
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/jbd2/transaction.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 3233e5ac9774f..622610934c9ad 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1906,6 +1906,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct 
journal_head *jh)
  */
 static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
 {
+   J_ASSERT_JH(jh, jh->b_transaction != NULL);
+   J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
+
__jbd2_journal_temp_unlink_buffer(jh);
jh->b_transaction = NULL;
jbd2_journal_put_journal_head(jh);
@@ -2453,6 +2456,13 @@ void __jbd2_journal_refile_buffer(struct journal_head 
*jh)
 
was_dirty = test_clear_buffer_jbddirty(bh);
__jbd2_journal_temp_unlink_buffer(jh);
+
+   /*
+* b_transaction must be set, otherwise the new b_transaction won't
+* be holding jh reference
+*/
+   J_ASSERT_JH(jh, jh->b_transaction != NULL);
+
/*
 * We set b_transaction here because b_next_transaction will inherit
 * our jh reference and thus __jbd2_journal_file_buffer() must not
-- 
2.25.1



[PATCH AUTOSEL 5.4 17/38] libbpf: Handle GCC built-in types for Arm NEON

2020-08-24 Thread Sasha Levin
From: Jean-Philippe Brucker 

[ Upstream commit 702eddc77a905782083b14ccd05b23840675fd18 ]

When building Arm NEON (SIMD) code from lib/raid6/neon.uc, GCC emits
DWARF information using a base type "__Poly8_t", which is internal to
GCC and not recognized by Clang. This causes build failures when
building with Clang a vmlinux.h generated from an arm64 kernel that was
built with GCC.

vmlinux.h:47284:9: error: unknown type name '__Poly8_t'
typedef __Poly8_t poly8x16_t[16];
^

The polyX_t types are defined as unsigned integers in the "Arm C
Language Extension" document (101028_Q220_00_en). Emit typedefs based on
standard integer types for the GCC internal types, similar to those
emitted by Clang.

Including linux/kernel.h to use ARRAY_SIZE() incidentally redefined
max(), causing a build bug due to different types, hence the seemingly
unrelated change.

Reported-by: Jakov Petrina 
Signed-off-by: Jean-Philippe Brucker 
Signed-off-by: Alexei Starovoitov 
Acked-by: Andrii Nakryiko 
Link: 
https://lore.kernel.org/bpf/20200812143909.3293280-1-jean-phili...@linaro.org
Signed-off-by: Sasha Levin 
---
 tools/lib/bpf/btf_dump.c | 35 ++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index d9e386b8f47ed..07fcc8e79662d 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "btf.h"
 #include "hashmap.h"
 #include "libbpf.h"
@@ -543,6 +544,9 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 
id, bool through_ptr)
}
 }
 
+static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id,
+ const struct btf_type *t);
+
 static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id,
 const struct btf_type *t);
 static void btf_dump_emit_struct_def(struct btf_dump *d, __u32 id,
@@ -665,6 +669,9 @@ static void btf_dump_emit_type(struct btf_dump *d, __u32 
id, __u32 cont_id)
 
switch (kind) {
case BTF_KIND_INT:
+   /* Emit type alias definitions if necessary */
+   btf_dump_emit_missing_aliases(d, id, t);
+
tstate->emit_state = EMITTED;
break;
case BTF_KIND_ENUM:
@@ -899,7 +906,7 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
btf_dump_printf(d, ": %d", m_sz);
off = m_off + m_sz;
} else {
-   m_sz = max(0, btf__resolve_size(d->btf, m->type));
+   m_sz = max(0LL, btf__resolve_size(d->btf, m->type));
off = m_off + m_sz * 8;
}
btf_dump_printf(d, ";");
@@ -919,6 +926,32 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
btf_dump_printf(d, " __attribute__((packed))");
 }
 
+static const char *missing_base_types[][2] = {
+   /*
+* GCC emits typedefs to its internal __PolyX_t types when compiling Arm
+* SIMD intrinsics. Alias them to standard base types.
+*/
+   { "__Poly8_t",  "unsigned char" },
+   { "__Poly16_t", "unsigned short" },
+   { "__Poly64_t", "unsigned long long" },
+   { "__Poly128_t","unsigned __int128" },
+};
+
+static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id,
+ const struct btf_type *t)
+{
+   const char *name = btf_dump_type_name(d, id);
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(missing_base_types); i++) {
+   if (strcmp(name, missing_base_types[i][0]) == 0) {
+   btf_dump_printf(d, "typedef %s %s;\n\n",
+   missing_base_types[i][1], name);
+   break;
+   }
+   }
+}
+
 static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id,
   const struct btf_type *t)
 {
-- 
2.25.1



[PATCH AUTOSEL 4.14 09/11] scsi: ufs: Clean up completed request without interrupt notification

2020-08-24 Thread Sasha Levin
From: Stanley Chu 

[ Upstream commit b10178ee7fa88b68a9e8adc06534d2605cb0ec23 ]

If somehow no interrupt notification is raised for a completed request and
its doorbell bit is cleared by host, UFS driver needs to cleanup its
outstanding bit in ufshcd_abort(). Otherwise, system may behave abnormally
in the following scenario:

After ufshcd_abort() returns, this request will be requeued by SCSI layer
with its outstanding bit set. Any future completed request will trigger
ufshcd_transfer_req_compl() to handle all "completed outstanding bits". At
this time the "abnormal outstanding bit" will be detected and the "requeued
request" will be chosen to execute request post-processing flow. This is
wrong because this request is still "alive".

Link: https://lore.kernel.org/r/20200811141859.27399-2-huob...@gmail.com
Reviewed-by: Can Guo 
Acked-by: Avri Altman 
Signed-off-by: Stanley Chu 
Signed-off-by: Bean Huo 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 4eaecc3cdebc8..4f32d794c9378 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5692,7 +5692,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
/* command completed already */
dev_err(hba->dev, "%s: cmd at tag %d successfully 
cleared from DB.\n",
__func__, tag);
-   goto out;
+   goto cleanup;
} else {
dev_err(hba->dev,
"%s: no response from device. tag = %d, err 
%d\n",
@@ -5726,6 +5726,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
goto out;
}
 
+cleanup:
scsi_dma_unmap(cmd);
 
spin_lock_irqsave(host->host_lock, flags);
-- 
2.25.1



[PATCH AUTOSEL 5.7 39/54] scsi: qla2xxx: Indicate correct supported speeds for Mezz card

2020-08-24 Thread Sasha Levin
From: Quinn Tran 

[ Upstream commit 4709272f6327cc4a8ee1dc55771bcf9718346980 ]

Correct the supported speeds for 16G Mezz card.

Link: https://lore.kernel.org/r/20200806111014.28434-4-njav...@marvell.com
Reviewed-by: Himanshu Madhani 
Signed-off-by: Quinn Tran 
Signed-off-by: Nilesh Javali 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/qla2xxx/qla_gs.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 7074073446701..3bfb5678f6515 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1505,11 +1505,11 @@ qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t 
cmd,
 static uint
 qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
 {
+   uint speeds = 0;
+
if (IS_CNA_CAPABLE(ha))
return FDMI_PORT_SPEED_10GB;
if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) {
-   uint speeds = 0;
-
if (ha->max_supported_speed == 2) {
if (ha->min_supported_speed <= 6)
speeds |= FDMI_PORT_SPEED_64GB;
@@ -1536,9 +1536,16 @@ qla25xx_fdmi_port_speed_capability(struct qla_hw_data 
*ha)
}
return speeds;
}
-   if (IS_QLA2031(ha))
-   return FDMI_PORT_SPEED_16GB|FDMI_PORT_SPEED_8GB|
-   FDMI_PORT_SPEED_4GB;
+   if (IS_QLA2031(ha)) {
+   if ((ha->pdev->subsystem_vendor == 0x103C) &&
+   (ha->pdev->subsystem_device == 0x8002)) {
+   speeds = FDMI_PORT_SPEED_16GB;
+   } else {
+   speeds = FDMI_PORT_SPEED_16GB|FDMI_PORT_SPEED_8GB|
+   FDMI_PORT_SPEED_4GB;
+   }
+   return speeds;
+   }
if (IS_QLA25XX(ha))
return FDMI_PORT_SPEED_8GB|FDMI_PORT_SPEED_4GB|
FDMI_PORT_SPEED_2GB|FDMI_PORT_SPEED_1GB;
-- 
2.25.1



[PATCH AUTOSEL 4.4 4/6] scsi: ufs: Fix possible infinite loop in ufshcd_hold

2020-08-24 Thread Sasha Levin
From: Stanley Chu 

[ Upstream commit 93b6c5db06028a3b55122bbb74d0715dd8ca4ae0 ]

In ufshcd_suspend(), after clk-gating is suspended and link is set
as Hibern8 state, ufshcd_hold() is still possibly invoked before
ufshcd_suspend() returns. For example, MediaTek's suspend vops may
issue UIC commands which would call ufshcd_hold() during the command
issuing flow.

Now if UFSHCD_CAP_HIBERN8_WITH_CLK_GATING capability is enabled,
then ufshcd_hold() may enter infinite loops because there is no
clk-ungating work scheduled or pending. In this case, ufshcd_hold()
shall just bypass, and keep the link as Hibern8 state.

Link: https://lore.kernel.org/r/20200809050734.18740-1-stanley@mediatek.com
Reviewed-by: Avri Altman 
Co-developed-by: Andy Teng 
Signed-off-by: Andy Teng 
Signed-off-by: Stanley Chu 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/ufs/ufshcd.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d15cd7a02f9b4..d7a0a64f64536 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -575,6 +575,7 @@ static void ufshcd_ungate_work(struct work_struct *work)
 int ufshcd_hold(struct ufs_hba *hba, bool async)
 {
int rc = 0;
+   bool flush_result;
unsigned long flags;
 
if (!ufshcd_is_clkgating_allowed(hba))
@@ -601,7 +602,9 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
break;
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
-   flush_work(>clk_gating.ungate_work);
+   flush_result = flush_work(>clk_gating.ungate_work);
+   if (hba->clk_gating.is_suspended && !flush_result)
+   goto out;
spin_lock_irqsave(hba->host->host_lock, flags);
goto start;
}
-- 
2.25.1



[PATCH AUTOSEL 4.9 4/8] s390/cio: add cond_resched() in the slow_eval_known_fn() loop

2020-08-24 Thread Sasha Levin
From: Vineeth Vijayan 

[ Upstream commit 0b8eb2ee9da1e8c9b8082f404f3948aa82a057b2 ]

The scanning through subchannels during the time of an event could
take significant amount of time in case of platforms with lots of
known subchannels. This might result in higher scheduling latencies
for other tasks especially on systems with a single CPU. Add
cond_resched() call, as the loop in slow_eval_known_fn() can be
executed for a longer duration.

Reviewed-by: Peter Oberparleiter 
Signed-off-by: Vineeth Vijayan 
Signed-off-by: Heiko Carstens 
Signed-off-by: Sasha Levin 
---
 drivers/s390/cio/css.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 39a2b0cde9e42..d81fdcd6a1fe0 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -529,6 +529,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void 
*data)
rc = css_evaluate_known_subchannel(sch, 1);
if (rc == -EAGAIN)
css_schedule_eval(sch->schid);
+   /*
+* The loop might take long time for platforms with lots of
+* known devices. Allow scheduling here.
+*/
+   cond_resched();
}
return 0;
 }
-- 
2.25.1



[PATCH AUTOSEL 5.4 36/38] powerpc/perf: Fix soft lockups due to missed interrupt accounting

2020-08-24 Thread Sasha Levin
From: Athira Rajeev 

[ Upstream commit 17899eaf88d689529b866371344c8f269ba79b5f ]

Performance monitor interrupt handler checks if any counter has
overflown and calls record_and_restart() in core-book3s which invokes
perf_event_overflow() to record the sample information. Apart from
creating sample, perf_event_overflow() also does the interrupt and
period checks via perf_event_account_interrupt().

Currently we record information only if the SIAR (Sampled Instruction
Address Register) valid bit is set (using siar_valid() check) and
hence the interrupt check.

But it is possible that we do sampling for some events that are not
generating valid SIAR, and hence there is no chance to disable the
event if interrupts are more than max_samples_per_tick. This leads to
soft lockup.

Fix this by adding perf_event_account_interrupt() in the invalid SIAR
code path for a sampling event. ie if SIAR is invalid, just do
interrupt check and don't record the sample information.

Reported-by: Alexey Kardashevskiy 
Signed-off-by: Athira Rajeev 
Tested-by: Alexey Kardashevskiy 
Signed-off-by: Michael Ellerman 
Link: 
https://lore.kernel.org/r/1596717992-7321-1-git-send-email-atraj...@linux.vnet.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/perf/core-book3s.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index ca92e01d0bd1b..e32f7700303bc 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2106,6 +2106,10 @@ static void record_and_restart(struct perf_event *event, 
unsigned long val,
 
if (perf_event_overflow(event, , regs))
power_pmu_stop(event, 0);
+   } else if (period) {
+   /* Account for interrupt in case of invalid SIAR */
+   if (perf_event_account_interrupt(event))
+   power_pmu_stop(event, 0);
}
 }
 
-- 
2.25.1



[PATCH AUTOSEL 5.4 20/38] ALSA: hda/realtek: Add model alc298-samsung-headphone

2020-08-24 Thread Sasha Levin
From: Mike Pozulp 

[ Upstream commit 23dc958689449be85e39351a8c809c3d344b155b ]

The very quiet and distorted headphone output bug that afflicted my
Samsung Notebook 9 is appearing in many other Samsung laptops. Expose
the quirk which fixed my laptop as a model so other users can try it.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207423
Signed-off-by: Mike Pozulp 
Link: https://lore.kernel.org/r/20200817043219.458889-1-pozulp.ker...@gmail.com
Signed-off-by: Takashi Iwai 
Signed-off-by: Sasha Levin 
---
 sound/pci/hda/patch_realtek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 88629906f314c..e230909af980c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7926,6 +7926,7 @@ static const struct hda_model_fixup alc269_fixup_models[] 
= {
{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
{.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
{.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = 
"alc256-medion-headset"},
+   {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = 
"alc298-samsung-headphone"},
{}
 };
 #define ALC225_STANDARD_PINS \
-- 
2.25.1



[PATCH AUTOSEL 5.7 38/54] scsi: qla2xxx: Flush I/O on zone disable

2020-08-24 Thread Sasha Levin
From: Quinn Tran 

[ Upstream commit a117579d0205b5a0592a3a98493e2b875e4da236 ]

Perform implicit logout to flush I/O on zone disable.

Link: https://lore.kernel.org/r/20200806111014.28434-3-njav...@marvell.com
Reviewed-by: Himanshu Madhani 
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
Signed-off-by: Nilesh Javali 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/qla2xxx/qla_gs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index c6b6a3250312e..7074073446701 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3436,7 +3436,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t 
*sp)
list_for_each_entry(fcport, >vp_fcports, list) {
if ((fcport->flags & FCF_FABRIC_DEVICE) != 0) {
fcport->scan_state = QLA_FCPORT_SCAN;
-   fcport->logout_on_delete = 0;
}
}
goto login_logout;
-- 
2.25.1



[PATCH AUTOSEL 5.8 38/63] scsi: fcoe: Fix I/O path allocation

2020-08-24 Thread Sasha Levin
From: Mike Christie 

[ Upstream commit fa39ab5184d64563cd36f2fb5f0d3fbad83a432c ]

ixgbe_fcoe_ddp_setup() can be called from the main I/O path and is called
with a spin_lock held, so we have to use GFP_ATOMIC allocation instead of
GFP_KERNEL.

Link: 
https://lore.kernel.org/r/1596831813-9839-1-git-send-email-michael.chris...@oracle.com
cc: Hannes Reinecke 
Reviewed-by: Lee Duncan 
Signed-off-by: Mike Christie 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
index ec7a11d13fdc0..9e70b9a674409 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
@@ -192,7 +192,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, 
u16 xid,
}
 
/* alloc the udl from per cpu ddp pool */
-   ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_KERNEL, >udp);
+   ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_ATOMIC, >udp);
if (!ddp->udl) {
e_err(drv, "failed allocated ddp context\n");
goto out_noddp_unmap;
-- 
2.25.1



[PATCH AUTOSEL 5.7 45/54] net: gianfar: Add of_node_put() before goto statement

2020-08-24 Thread Sasha Levin
From: Sumera Priyadarsini 

[ Upstream commit 989e4da042ca4a56bbaca9223d1a93639ad11e17 ]

Every iteration of for_each_available_child_of_node() decrements
reference count of the previous node, however when control
is transferred from the middle of the loop, as in the case of
a return or break or goto, there is no decrement thus ultimately
resulting in a memory leak.

Fix a potential memory leak in gianfar.c by inserting of_node_put()
before the goto statement.

Issue found with Coccinelle.

Signed-off-by: Sumera Priyadarsini 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/gianfar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index b3c69e9038eac..d20d865979abd 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -750,8 +750,10 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
continue;
 
err = gfar_parse_group(child, priv, model);
-   if (err)
+   if (err) {
+   of_node_put(child);
goto err_grp_init;
+   }
}
} else { /* SQ_SG_MODE */
err = gfar_parse_group(np, priv, model);
-- 
2.25.1



[PATCH AUTOSEL 5.7 37/54] scsi: qla2xxx: Flush all sessions on zone disable

2020-08-24 Thread Sasha Levin
From: Quinn Tran 

[ Upstream commit 10ae30ba664822f62de169a61628e31c999c7cc8 ]

On Zone Disable, certain switches would ignore all commands. This causes
timeout for both switch scan command and abort of that command. On
detection of this condition, all sessions will be shutdown.

Link: https://lore.kernel.org/r/20200806111014.28434-2-njav...@marvell.com
Reviewed-by: Himanshu Madhani 
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
Signed-off-by: Nilesh Javali 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/qla2xxx/qla_gs.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index df670fba2ab8a..c6b6a3250312e 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3736,6 +3736,18 @@ static void qla2x00_async_gpnft_gnnft_sp_done(srb_t *sp, 
int res)
unsigned long flags;
const char *name = sp->name;
 
+   if (res == QLA_OS_TIMER_EXPIRED) {
+   /* switch is ignoring all commands.
+* This might be a zone disable behavior.
+* This means we hit 64s timeout.
+* 22s GPNFT + 44s Abort = 64s
+*/
+   ql_dbg(ql_dbg_disc, vha, 0x,
+  "%s: Switch Zone check please .\n",
+  name);
+   qla2x00_mark_all_devices_lost(vha);
+   }
+
/*
 * We are in an Interrupt context, queue up this
 * sp for GNNFT_DONE work. This will allow all
-- 
2.25.1



[PATCH AUTOSEL 5.8 61/63] bpf: selftests: global_funcs: Check err_str before strstr

2020-08-24 Thread Sasha Levin
From: Yauheni Kaliuta 

[ Upstream commit c210773d6c6f595f5922d56b7391fe343bc7310e ]

The error path in libbpf.c:load_program() has calls to pr_warn()
which ends up for global_funcs tests to
test_global_funcs.c:libbpf_debug_print().

For the tests with no struct test_def::err_str initialized with a
string, it causes call of strstr() with NULL as the second argument
and it segfaults.

Fix it by calling strstr() only for non-NULL err_str.

Signed-off-by: Yauheni Kaliuta 
Signed-off-by: Alexei Starovoitov 
Acked-by: Yonghong Song 
Link: 
https://lore.kernel.org/bpf/20200820115843.39454-1-yauheni.kali...@redhat.com
Signed-off-by: Sasha Levin 
---
 tools/testing/selftests/bpf/prog_tests/test_global_funcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c 
b/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
index 25b068591e9a4..193002b14d7f6 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
@@ -19,7 +19,7 @@ static int libbpf_debug_print(enum libbpf_print_level level,
log_buf = va_arg(args, char *);
if (!log_buf)
goto out;
-   if (strstr(log_buf, err_str) == 0)
+   if (err_str && strstr(log_buf, err_str) == 0)
found = true;
 out:
printf(format, log_buf);
-- 
2.25.1



[PATCH AUTOSEL 5.8 22/63] libbpf: Handle GCC built-in types for Arm NEON

2020-08-24 Thread Sasha Levin
From: Jean-Philippe Brucker 

[ Upstream commit 702eddc77a905782083b14ccd05b23840675fd18 ]

When building Arm NEON (SIMD) code from lib/raid6/neon.uc, GCC emits
DWARF information using a base type "__Poly8_t", which is internal to
GCC and not recognized by Clang. This causes build failures when
building with Clang a vmlinux.h generated from an arm64 kernel that was
built with GCC.

vmlinux.h:47284:9: error: unknown type name '__Poly8_t'
typedef __Poly8_t poly8x16_t[16];
^

The polyX_t types are defined as unsigned integers in the "Arm C
Language Extension" document (101028_Q220_00_en). Emit typedefs based on
standard integer types for the GCC internal types, similar to those
emitted by Clang.

Including linux/kernel.h to use ARRAY_SIZE() incidentally redefined
max(), causing a build bug due to different types, hence the seemingly
unrelated change.

Reported-by: Jakov Petrina 
Signed-off-by: Jean-Philippe Brucker 
Signed-off-by: Alexei Starovoitov 
Acked-by: Andrii Nakryiko 
Link: 
https://lore.kernel.org/bpf/20200812143909.3293280-1-jean-phili...@linaro.org
Signed-off-by: Sasha Levin 
---
 tools/lib/bpf/btf_dump.c | 35 ++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index bbb4303172606..4edf76c5a7101 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "btf.h"
 #include "hashmap.h"
 #include "libbpf.h"
@@ -548,6 +549,9 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 
id, bool through_ptr)
}
 }
 
+static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id,
+ const struct btf_type *t);
+
 static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id,
 const struct btf_type *t);
 static void btf_dump_emit_struct_def(struct btf_dump *d, __u32 id,
@@ -670,6 +674,9 @@ static void btf_dump_emit_type(struct btf_dump *d, __u32 
id, __u32 cont_id)
 
switch (kind) {
case BTF_KIND_INT:
+   /* Emit type alias definitions if necessary */
+   btf_dump_emit_missing_aliases(d, id, t);
+
tstate->emit_state = EMITTED;
break;
case BTF_KIND_ENUM:
@@ -869,7 +876,7 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
btf_dump_printf(d, ": %d", m_sz);
off = m_off + m_sz;
} else {
-   m_sz = max(0, btf__resolve_size(d->btf, m->type));
+   m_sz = max(0LL, btf__resolve_size(d->btf, m->type));
off = m_off + m_sz * 8;
}
btf_dump_printf(d, ";");
@@ -889,6 +896,32 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
btf_dump_printf(d, " __attribute__((packed))");
 }
 
+static const char *missing_base_types[][2] = {
+   /*
+* GCC emits typedefs to its internal __PolyX_t types when compiling Arm
+* SIMD intrinsics. Alias them to standard base types.
+*/
+   { "__Poly8_t",  "unsigned char" },
+   { "__Poly16_t", "unsigned short" },
+   { "__Poly64_t", "unsigned long long" },
+   { "__Poly128_t","unsigned __int128" },
+};
+
+static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id,
+ const struct btf_type *t)
+{
+   const char *name = btf_dump_type_name(d, id);
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(missing_base_types); i++) {
+   if (strcmp(name, missing_base_types[i][0]) == 0) {
+   btf_dump_printf(d, "typedef %s %s;\n\n",
+   missing_base_types[i][1], name);
+   break;
+   }
+   }
+}
+
 static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id,
   const struct btf_type *t)
 {
-- 
2.25.1



[PATCH AUTOSEL 5.8 16/63] spi: stm32: always perform registers configuration prior to transfer

2020-08-24 Thread Sasha Levin
From: Alain Volmat 

[ Upstream commit 60ccb3515fc61a0124c70aa37317f75b67560024 ]

SPI registers content may have been lost upon suspend/resume sequence.
So, always compute and apply the necessary configuration in
stm32_spi_transfer_one_setup routine.

Signed-off-by: Alain Volmat 
Link: 
https://lore.kernel.org/r/1597043558-29668-6-git-send-email-alain.vol...@st.com
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-stm32.c | 42 +
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 571dea72bf7e6..37dac7f0b8609 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1596,41 +1596,33 @@ static int stm32_spi_transfer_one_setup(struct 
stm32_spi *spi,
unsigned long flags;
unsigned int comm_type;
int nb_words, ret = 0;
+   int mbr;
 
spin_lock_irqsave(>lock, flags);
 
spi->cur_xferlen = transfer->len;
 
-   if (spi->cur_bpw != transfer->bits_per_word) {
-   spi->cur_bpw = transfer->bits_per_word;
-   spi->cfg->set_bpw(spi);
-   }
-
-   if (spi->cur_speed != transfer->speed_hz) {
-   int mbr;
-
-   /* Update spi->cur_speed with real clock speed */
-   mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
-   spi->cfg->baud_rate_div_min,
-   spi->cfg->baud_rate_div_max);
-   if (mbr < 0) {
-   ret = mbr;
-   goto out;
-   }
+   spi->cur_bpw = transfer->bits_per_word;
+   spi->cfg->set_bpw(spi);
 
-   transfer->speed_hz = spi->cur_speed;
-   stm32_spi_set_mbr(spi, mbr);
+   /* Update spi->cur_speed with real clock speed */
+   mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
+   spi->cfg->baud_rate_div_min,
+   spi->cfg->baud_rate_div_max);
+   if (mbr < 0) {
+   ret = mbr;
+   goto out;
}
 
-   comm_type = stm32_spi_communication_type(spi_dev, transfer);
-   if (spi->cur_comm != comm_type) {
-   ret = spi->cfg->set_mode(spi, comm_type);
+   transfer->speed_hz = spi->cur_speed;
+   stm32_spi_set_mbr(spi, mbr);
 
-   if (ret < 0)
-   goto out;
+   comm_type = stm32_spi_communication_type(spi_dev, transfer);
+   ret = spi->cfg->set_mode(spi, comm_type);
+   if (ret < 0)
+   goto out;
 
-   spi->cur_comm = comm_type;
-   }
+   spi->cur_comm = comm_type;
 
if (spi->cfg->set_data_idleness)
spi->cfg->set_data_idleness(spi, transfer->len);
-- 
2.25.1



[PATCH AUTOSEL 5.8 18/63] drm/amd/powerplay: correct UVD/VCE PG state on custom pptable uploading

2020-08-24 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 2c5b8080d810d98e3e59617680218499b17c84a1 ]

The UVD/VCE PG state is managed by UVD and VCE IP. It's error-prone to
assume the bootup state in SMU based on the dpm status.

Signed-off-by: Evan Quan 
Acked-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
index b7f3f8b62c2ac..9bd2874a122b4 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
@@ -1640,12 +1640,6 @@ static void vega20_init_powergate_state(struct pp_hwmgr 
*hwmgr)
 
data->uvd_power_gated = true;
data->vce_power_gated = true;
-
-   if (data->smu_features[GNLD_DPM_UVD].enabled)
-   data->uvd_power_gated = false;
-
-   if (data->smu_features[GNLD_DPM_VCE].enabled)
-   data->vce_power_gated = false;
 }
 
 static int vega20_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
-- 
2.25.1



[PATCH AUTOSEL 5.8 14/63] spi: stm32: fix fifo threshold level in case of short transfer

2020-08-24 Thread Sasha Levin
From: Amelie Delaunay 

[ Upstream commit 3373e9004acc0603242622b4378c64bc01d21b5f ]

When transfer is shorter than half of the fifo, set the data packet size
up to transfer size instead of up to half of the fifo.
Check also that threshold is set at least to 1 data frame.

Signed-off-by: Amelie Delaunay 
Signed-off-by: Alain Volmat 
Link: 
https://lore.kernel.org/r/1597043558-29668-3-git-send-email-alain.vol...@st.com
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-stm32.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 814a3ec3b8ada..e5450233f3f8b 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -467,20 +467,27 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, 
u32 speed_hz,
 /**
  * stm32h7_spi_prepare_fthlv - Determine FIFO threshold level
  * @spi: pointer to the spi controller data structure
+ * @xfer_len: length of the message to be transferred
  */
-static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
+static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi, u32 xfer_len)
 {
-   u32 fthlv, half_fifo;
+   u32 fthlv, half_fifo, packet;
 
/* data packet should not exceed 1/2 of fifo space */
half_fifo = (spi->fifo_size / 2);
 
+   /* data_packet should not exceed transfer length */
+   if (half_fifo > xfer_len)
+   packet = xfer_len;
+   else
+   packet = half_fifo;
+
if (spi->cur_bpw <= 8)
-   fthlv = half_fifo;
+   fthlv = packet;
else if (spi->cur_bpw <= 16)
-   fthlv = half_fifo / 2;
+   fthlv = packet / 2;
else
-   fthlv = half_fifo / 4;
+   fthlv = packet / 4;
 
/* align packet size with data registers access */
if (spi->cur_bpw > 8)
@@ -488,6 +495,9 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
else
fthlv -= (fthlv % 4); /* multiple of 4 */
 
+   if (!fthlv)
+   fthlv = 1;
+
return fthlv;
 }
 
@@ -1393,7 +1403,7 @@ static void stm32h7_spi_set_bpw(struct stm32_spi *spi)
cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) &
 STM32H7_SPI_CFG1_DSIZE;
 
-   spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi);
+   spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi, spi->cur_xferlen);
fthlv = spi->cur_fthlv - 1;
 
cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV;
@@ -1588,6 +1598,8 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi 
*spi,
 
spin_lock_irqsave(>lock, flags);
 
+   spi->cur_xferlen = transfer->len;
+
if (spi->cur_bpw != transfer->bits_per_word) {
spi->cur_bpw = transfer->bits_per_word;
spi->cfg->set_bpw(spi);
@@ -1635,8 +1647,6 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi 
*spi,
goto out;
}
 
-   spi->cur_xferlen = transfer->len;
-
dev_dbg(spi->dev, "transfer communication mode set to %d\n",
spi->cur_comm);
dev_dbg(spi->dev,
-- 
2.25.1



[PATCH AUTOSEL 5.8 20/63] drm/amd/display: Switch to immediate mode for updating infopackets

2020-08-24 Thread Sasha Levin
From: Anthony Koo 

[ Upstream commit abba907c7a20032c2d504fd5afe3af7d440a09d0 ]

[Why]
Using FRAME_UPDATE will result in infopacket to be potentially updated
one frame late.
In commit stream scenarios for previously active stream, some stale
infopacket data from previous config might be erroneously sent out on
initial frame after stream is re-enabled.

[How]
Switch to using IMMEDIATE_UPDATE mode

Signed-off-by: Anthony Koo 
Reviewed-by: Ashley Thomas 
Acked-by: Qingqing Zhuo 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 .../amd/display/dc/dcn10/dcn10_stream_encoder.c  | 16 
 .../amd/display/dc/dcn10/dcn10_stream_encoder.h  | 14 ++
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
index 07b2f9399671d..842abb4c475bc 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
@@ -121,35 +121,35 @@ void enc1_update_generic_info_packet(
switch (packet_index) {
case 0:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC0_FRAME_UPDATE, 1);
+   AFMT_GENERIC0_IMMEDIATE_UPDATE, 1);
break;
case 1:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC1_FRAME_UPDATE, 1);
+   AFMT_GENERIC1_IMMEDIATE_UPDATE, 1);
break;
case 2:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC2_FRAME_UPDATE, 1);
+   AFMT_GENERIC2_IMMEDIATE_UPDATE, 1);
break;
case 3:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC3_FRAME_UPDATE, 1);
+   AFMT_GENERIC3_IMMEDIATE_UPDATE, 1);
break;
case 4:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC4_FRAME_UPDATE, 1);
+   AFMT_GENERIC4_IMMEDIATE_UPDATE, 1);
break;
case 5:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC5_FRAME_UPDATE, 1);
+   AFMT_GENERIC5_IMMEDIATE_UPDATE, 1);
break;
case 6:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC6_FRAME_UPDATE, 1);
+   AFMT_GENERIC6_IMMEDIATE_UPDATE, 1);
break;
case 7:
REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-   AFMT_GENERIC7_FRAME_UPDATE, 1);
+   AFMT_GENERIC7_IMMEDIATE_UPDATE, 1);
break;
default:
break;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
index f9b9e221c698b..7507000a99ac4 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
@@ -273,7 +273,14 @@ struct dcn10_stream_enc_registers {
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC2_FRAME_UPDATE, 
mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC3_FRAME_UPDATE, 
mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC4_FRAME_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC0_IMMEDIATE_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC1_IMMEDIATE_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC2_IMMEDIATE_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC3_IMMEDIATE_UPDATE, 
mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC4_IMMEDIATE_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC5_IMMEDIATE_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC6_IMMEDIATE_UPDATE, 
mask_sh),\
+   SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_IMMEDIATE_UPDATE, 
mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC5_FRAME_UPDATE, 
mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC6_FRAME_UPDATE, 
mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_FRAME_UPDATE, 
mask_sh),\
@@ -337,7 +344,14 @@ struct dcn10_stream_enc_registers {
type AFMT_GENERIC2_FRAME_UPDATE;\
type AFMT_GENERIC3_FRAME_UPDATE;\
type AFMT_GENERIC4_FRAME_UPDATE;\
+   type AFMT_GENERIC0_IMMEDIATE_UPDATE;\
+   type AFMT_GENERIC1_IMMEDIATE_UPDATE;\
+   type AFMT_GENERIC2_IMMEDIATE_UPDATE;\
+   type AFMT_GENERIC3_IMMEDIATE_UPDATE;\
type AFMT_GENERIC4_IMMEDIATE_UPDATE;\
+   type 

[PATCH AUTOSEL 5.8 15/63] spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate

2020-08-24 Thread Sasha Levin
From: Amelie Delaunay 

[ Upstream commit 9cc61973bf9385b19ff5dda4a2a7e265fcba85e4 ]

Fix spi->clk_rate when it is odd to the nearest lowest even value because
minimum SPI divider is 2.

Signed-off-by: Amelie Delaunay 
Signed-off-by: Alain Volmat 
Link: 
https://lore.kernel.org/r/1597043558-29668-4-git-send-email-alain.vol...@st.com
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-stm32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index e5450233f3f8b..571dea72bf7e6 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -441,7 +441,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 
speed_hz,
 {
u32 div, mbrdiv;
 
-   div = DIV_ROUND_UP(spi->clk_rate, speed_hz);
+   /* Ensure spi->clk_rate is even */
+   div = DIV_ROUND_UP(spi->clk_rate & ~0x1, speed_hz);
 
/*
 * SPI framework set xfer->speed_hz to master->max_speed_hz if
-- 
2.25.1



[PATCH AUTOSEL 5.8 11/63] ext4: correctly restore system zone info when remount fails

2020-08-24 Thread Sasha Levin
From: Jan Kara 

[ Upstream commit 0f5bde1db174f6c471f0bd27198575719dabe3e5 ]

When remounting filesystem fails late during remount handling and
block_validity mount option is also changed during the remount, we fail
to restore system zone information to a state matching the mount option.
This is mostly harmless, just the block validity checking will not match
the situation described by the mount option. Make sure these two are always
consistent.

Reported-by: Lukas Czerner 
Reviewed-by: Lukas Czerner 
Signed-off-by: Jan Kara 
Link: https://lore.kernel.org/r/20200728130437.7804-7-j...@suse.cz
Signed-off-by: Theodore Ts'o 
Signed-off-by: Sasha Levin 
---
 fs/ext4/block_validity.c |  8 
 fs/ext4/super.c  | 29 +
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 16e9b2fda03ae..30ff442453ff0 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -262,14 +262,6 @@ int ext4_setup_system_zone(struct super_block *sb)
int flex_size = ext4_flex_bg_size(sbi);
int ret;
 
-   if (!test_opt(sb, BLOCK_VALIDITY)) {
-   if (sbi->system_blks)
-   ext4_release_system_zone(sb);
-   return 0;
-   }
-   if (sbi->system_blks)
-   return 0;
-
system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL);
if (!system_blks)
return -ENOMEM;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 54d1c09329e55..4c8253188d8df 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4698,11 +4698,13 @@ static int ext4_fill_super(struct super_block *sb, void 
*data, int silent)
 
ext4_set_resv_clusters(sb);
 
-   err = ext4_setup_system_zone(sb);
-   if (err) {
-   ext4_msg(sb, KERN_ERR, "failed to initialize system "
-"zone (%d)", err);
-   goto failed_mount4a;
+   if (test_opt(sb, BLOCK_VALIDITY)) {
+   err = ext4_setup_system_zone(sb);
+   if (err) {
+   ext4_msg(sb, KERN_ERR, "failed to initialize system "
+"zone (%d)", err);
+   goto failed_mount4a;
+   }
}
 
ext4_ext_init(sb);
@@ -5716,9 +5718,16 @@ static int ext4_remount(struct super_block *sb, int 
*flags, char *data)
ext4_register_li_request(sb, first_not_zeroed);
}
 
-   err = ext4_setup_system_zone(sb);
-   if (err)
-   goto restore_opts;
+   /*
+* Handle creation of system zone data early because it can fail.
+* Releasing of existing data is done when we are sure remount will
+* succeed.
+*/
+   if (test_opt(sb, BLOCK_VALIDITY) && !sbi->system_blks) {
+   err = ext4_setup_system_zone(sb);
+   if (err)
+   goto restore_opts;
+   }
 
if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
err = ext4_commit_super(sb, 1);
@@ -5740,6 +5749,8 @@ static int ext4_remount(struct super_block *sb, int 
*flags, char *data)
}
}
 #endif
+   if (!test_opt(sb, BLOCK_VALIDITY) && sbi->system_blks)
+   ext4_release_system_zone(sb);
 
/*
 * Some options can be enabled by ext4 and/or by VFS mount flag
@@ -5761,6 +5772,8 @@ static int ext4_remount(struct super_block *sb, int 
*flags, char *data)
sbi->s_commit_interval = old_opts.s_commit_interval;
sbi->s_min_batch_time = old_opts.s_min_batch_time;
sbi->s_max_batch_time = old_opts.s_max_batch_time;
+   if (!test_opt(sb, BLOCK_VALIDITY) && sbi->system_blks)
+   ext4_release_system_zone(sb);
 #ifdef CONFIG_QUOTA
sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
for (i = 0; i < EXT4_MAXQUOTAS; i++) {
-- 
2.25.1



[PATCH AUTOSEL 5.8 13/63] spi: stm32h7: fix race condition at end of transfer

2020-08-24 Thread Sasha Levin
From: Antonio Borneo 

[ Upstream commit 135dd873d3c76d812ae64c668adef3f2c59ed27f ]

The caller of stm32_spi_transfer_one(), spi_transfer_one_message(),
is waiting for us to call spi_finalize_current_transfer() and will
eventually schedule a new transfer, if available.
We should guarantee that the spi controller is really available
before calling spi_finalize_current_transfer().

Move the call to spi_finalize_current_transfer() _after_ the call
to stm32_spi_disable().

Signed-off-by: Antonio Borneo 
Signed-off-by: Alain Volmat 
Link: 
https://lore.kernel.org/r/1597043558-29668-2-git-send-email-alain.vol...@st.com
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 4a21feae0103d..814a3ec3b8ada 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -971,8 +971,8 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void 
*dev_id)
spin_unlock_irqrestore(>lock, flags);
 
if (end) {
-   spi_finalize_current_transfer(master);
stm32h7_spi_disable(spi);
+   spi_finalize_current_transfer(master);
}
 
return IRQ_HANDLED;
-- 
2.25.1



[PATCH AUTOSEL 5.8 01/63] spi: stm32: clear only asserted irq flags on interrupt

2020-08-24 Thread Sasha Levin
From: Tobias Schramm 

[ Upstream commit ae1ba50f1e706dfd7ce402ac52c1f1f10becad68 ]

Previously the stm32h7 interrupt thread cleared all non-masked interrupts.
If an interrupt was to occur during the handling of another interrupt its
flag would be unset, resulting in a lost interrupt.
This patches fixes the issue by clearing only the currently set interrupt
flags.

Signed-off-by: Tobias Schramm 
Link: https://lore.kernel.org/r/20200804195136.1485392-1-t.schr...@manjaro.org
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 4c643dfc7fbbc..4a21feae0103d 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -966,7 +966,7 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void 
*dev_id)
if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
stm32h7_spi_read_rxfifo(spi, false);
 
-   writel_relaxed(mask, spi->base + STM32H7_SPI_IFCR);
+   writel_relaxed(sr & mask, spi->base + STM32H7_SPI_IFCR);
 
spin_unlock_irqrestore(>lock, flags);
 
-- 
2.25.1



[PATCH 06/12] MIPS: Convert ICACHE_REFILLS_WORKAROUND_WAR into a config option

2020-08-24 Thread Thomas Bogendoerfer
Use a new config option to enable I-cache refill workaround and remove
define from different war.h files.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/Kconfig  |  9 +
 arch/mips/include/asm/mach-cavium-octeon/war.h |  1 -
 arch/mips/include/asm/mach-generic/war.h   |  1 -
 arch/mips/include/asm/mach-ip22/war.h  |  1 -
 arch/mips/include/asm/mach-ip27/war.h  |  1 -
 arch/mips/include/asm/mach-ip28/war.h  |  1 -
 arch/mips/include/asm/mach-ip30/war.h  |  1 -
 arch/mips/include/asm/mach-ip32/war.h  |  1 -
 arch/mips/include/asm/mach-malta/war.h |  1 -
 arch/mips/include/asm/mach-rc32434/war.h   |  1 -
 arch/mips/include/asm/mach-rm/war.h|  1 -
 arch/mips/include/asm/mach-sibyte/war.h|  1 -
 arch/mips/include/asm/mach-tx49xx/war.h|  1 -
 arch/mips/include/asm/war.h| 10 --
 arch/mips/kernel/signal.c  |  8 +++-
 15 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7db9611d7800..c32f6160f854 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -568,6 +568,7 @@ config MIPS_MALTA
select SYS_SUPPORTS_VPE_LOADER
select SYS_SUPPORTS_ZBOOT
select USE_OF
+   select WAR_ICACHE_REFILLS
select ZONE_DMA32 if 64BIT
help
  This enables support for the MIPS Technologies Malta evaluation
@@ -756,6 +757,7 @@ config SGI_IP32
select SYS_HAS_CPU_NEVADA
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
+   select WAR_ICACHE_REFILLS
help
  If you want this kernel to run on SGI O2 workstation, say Y here.
 
@@ -2666,6 +2668,13 @@ config WAR_R4600_V2_HIT_CACHEOP
 config WAR_TX49XX_ICACHE_INDEX_INV
bool
 
+# The RM7000 processors and the E9000 cores have a bug (though PMC-Sierra
+# opposes it being called that) where invalid instructions in the same
+# I-cache line worth of instructions being fetched may case spurious
+# exceptions.
+config WAR_ICACHE_REFILLS
+   bool
+
 #
 # - Highmem only makes sense for the 32-bit kernel.
 # - The current highmem code will only work properly on physically indexed
diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 1cb30485dc94..1061917152c6 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -11,7 +11,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define ICACHE_REFILLS_WORKAROUND_WAR  0
 #define R1_LLSC_WAR0
 #define MIPS34K_MISSED_ITLB_WAR0
 
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index 79530836cc79..966f40aedf16 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -10,7 +10,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define ICACHE_REFILLS_WORKAROUND_WAR  0
 #define R1_LLSC_WAR0
 #define MIPS34K_MISSED_ITLB_WAR0
 
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index 35286ba3ec57..99f6531e5b9b 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -10,7 +10,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define ICACHE_REFILLS_WORKAROUND_WAR  0
 #define R1_LLSC_WAR0
 #define MIPS34K_MISSED_ITLB_WAR0
 
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index a18293c16ade..d8dfa7258bea 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -10,7 +10,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define ICACHE_REFILLS_WORKAROUND_WAR  0
 #define R1_LLSC_WAR1
 #define MIPS34K_MISSED_ITLB_WAR0
 
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
index 1a6092e5c7b3..f252df761ec8 100644
--- a/arch/mips/include/asm/mach-ip28/war.h
+++ b/arch/mips/include/asm/mach-ip28/war.h
@@ -10,7 +10,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define ICACHE_REFILLS_WORKAROUND_WAR  0
 #define R1_LLSC_WAR1
 #define MIPS34K_MISSED_ITLB_WAR0
 
diff --git a/arch/mips/include/asm/mach-ip30/war.h 
b/arch/mips/include/asm/mach-ip30/war.h
index 031c7b9c5236..58ff9ca345b7 100644
--- a/arch/mips/include/asm/mach-ip30/war.h
+++ b/arch/mips/include/asm/mach-ip30/war.h
@@ -7,7 +7,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR  

[PATCH 08/12] MIPS: Convert MIPS34K_MISSED_ITLB_WAR into a config option

2020-08-24 Thread Thomas Bogendoerfer
Use a new config option to enable MIPS 34K ITLB workaround and remove
define from different war.h files.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/Kconfig  | 4 
 arch/mips/include/asm/mach-cavium-octeon/war.h | 1 -
 arch/mips/include/asm/mach-generic/war.h   | 1 -
 arch/mips/include/asm/mach-ip22/war.h  | 1 -
 arch/mips/include/asm/mach-ip27/war.h  | 1 -
 arch/mips/include/asm/mach-ip28/war.h  | 1 -
 arch/mips/include/asm/mach-ip30/war.h  | 1 -
 arch/mips/include/asm/mach-ip32/war.h  | 1 -
 arch/mips/include/asm/mach-malta/war.h | 1 -
 arch/mips/include/asm/mach-rc32434/war.h   | 1 -
 arch/mips/include/asm/mach-rm/war.h| 1 -
 arch/mips/include/asm/mach-sibyte/war.h| 2 --
 arch/mips/include/asm/mach-tx49xx/war.h| 1 -
 arch/mips/include/asm/mipsregs.h   | 4 ++--
 arch/mips/include/asm/war.h| 7 ---
 15 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index acb790b556a8..7991a04274da 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2683,6 +2683,10 @@ config WAR_ICACHE_REFILLS
 config WAR_R1_LLSC
bool
 
+# 34K core erratum: "Problems Executing the TLBR Instruction"
+config WAR_MIPS34K_MISSED_ITLB
+   bool
+
 #
 # - Highmem only makes sense for the 32-bit kernel.
 # - The current highmem code will only work properly on physically indexed
diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 52be3785e3e2..9aa4ea5522a9 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -11,7 +11,6 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #define CAVIUM_OCTEON_DCACHE_PREFETCH_WAR  \
OCTEON_IS_MODEL(OCTEON_CN6XXX)
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index 2229c8377288..4f25636661d5 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -10,6 +10,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MACH_GENERIC_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index f10efe589f93..09169cfbf932 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -10,6 +10,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP22_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index 0a07cf6731c0..1c81d5464235 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -10,6 +10,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP27_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
index 9fdc6425c22c..ff66adbaaae5 100644
--- a/arch/mips/include/asm/mach-ip28/war.h
+++ b/arch/mips/include/asm/mach-ip28/war.h
@@ -10,6 +10,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP28_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip30/war.h 
b/arch/mips/include/asm/mach-ip30/war.h
index 8a8ec5578083..b00469a39835 100644
--- a/arch/mips/include/asm/mach-ip30/war.h
+++ b/arch/mips/include/asm/mach-ip30/war.h
@@ -7,6 +7,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP30_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip32/war.h 
b/arch/mips/include/asm/mach-ip32/war.h
index 9e8c0c2a4c26..c57a9cd2e50b 100644
--- a/arch/mips/include/asm/mach-ip32/war.h
+++ b/arch/mips/include/asm/mach-ip32/war.h
@@ -10,6 +10,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP32_WAR_H */
diff --git a/arch/mips/include/asm/mach-malta/war.h 
b/arch/mips/include/asm/mach-malta/war.h
index 76f7de21b7dd..73c9e6d84a8f 100644
--- a/arch/mips/include/asm/mach-malta/war.h
+++ b/arch/mips/include/asm/mach-malta/war.h
@@ -10,6 +10,5 @@
 
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
-#define MIPS34K_MISSED_ITLB_WAR0
 
 #endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git 

[PATCH 12/12] MIPS: Remove mach-*/war.h

2020-08-24 Thread Thomas Bogendoerfer
After conversion of all WAR defines we can now remove all mach-*/war.h
files.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/include/asm/mach-cavium-octeon/war.h | 12 
 arch/mips/include/asm/mach-generic/war.h   | 11 ---
 arch/mips/include/asm/mach-ip22/war.h  | 11 ---
 arch/mips/include/asm/mach-ip27/war.h  | 11 ---
 arch/mips/include/asm/mach-ip28/war.h  | 11 ---
 arch/mips/include/asm/mach-ip30/war.h  |  8 
 arch/mips/include/asm/mach-ip32/war.h  | 11 ---
 arch/mips/include/asm/mach-malta/war.h | 11 ---
 arch/mips/include/asm/mach-rc32434/war.h   | 11 ---
 arch/mips/include/asm/mach-rm/war.h| 11 ---
 arch/mips/include/asm/mach-sibyte/war.h| 11 ---
 arch/mips/include/asm/mach-tx49xx/war.h| 11 ---
 arch/mips/include/asm/war.h|  2 --
 13 files changed, 132 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-cavium-octeon/war.h
 delete mode 100644 arch/mips/include/asm/mach-generic/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip22/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip27/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip28/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip30/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip32/war.h
 delete mode 100644 arch/mips/include/asm/mach-malta/war.h
 delete mode 100644 arch/mips/include/asm/mach-rc32434/war.h
 delete mode 100644 arch/mips/include/asm/mach-rm/war.h
 delete mode 100644 arch/mips/include/asm/mach-sibyte/war.h
 delete mode 100644 arch/mips/include/asm/mach-tx49xx/war.h

diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
deleted file mode 100644
index ba6df0a186e9..
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2002, 2004, 2007 by Ralf Baechle 
- * Copyright (C) 2008 Cavium Networks 
- */
-#ifndef __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
-#define __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
-
-#endif /* __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H */
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
deleted file mode 100644
index 94796ad7e7de..
--- a/arch/mips/include/asm/mach-generic/war.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2002, 2004, 2007 by Ralf Baechle 
- */
-#ifndef __ASM_MACH_GENERIC_WAR_H
-#define __ASM_MACH_GENERIC_WAR_H
-
-#endif /* __ASM_MACH_GENERIC_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
deleted file mode 100644
index 12cf05dd46d3..
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2002, 2004, 2007 by Ralf Baechle 
- */
-#ifndef __ASM_MIPS_MACH_IP22_WAR_H
-#define __ASM_MIPS_MACH_IP22_WAR_H
-
-#endif /* __ASM_MIPS_MACH_IP22_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
deleted file mode 100644
index 0852fe64594d..
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2002, 2004, 2007 by Ralf Baechle 
- */
-#ifndef __ASM_MIPS_MACH_IP27_WAR_H
-#define __ASM_MIPS_MACH_IP27_WAR_H
-
-#endif /* __ASM_MIPS_MACH_IP27_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
deleted file mode 100644
index 32796925700a..
--- a/arch/mips/include/asm/mach-ip28/war.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2002, 2004, 2007 by Ralf Baechle 
- */
-#ifndef __ASM_MIPS_MACH_IP28_WAR_H
-#define __ASM_MIPS_MACH_IP28_WAR_H
-
-#endif /* __ASM_MIPS_MACH_IP28_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip30/war.h 
b/arch/mips/include/asm/mach-ip30/war.h
deleted file mode 100644
index ea77545f5128..
--- a/arch/mips/include/asm/mach-ip30/war.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2002, 

[PATCH 10/12] MIPS: Get rid of BCM1250_M3_WAR

2020-08-24 Thread Thomas Bogendoerfer
BCM1250_M3_WAR is depending on CONFIG_CONFIG_SB1_PASS_2_WORKAROUNDS.
So using this option directly lets and remove define.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/include/asm/mach-cavium-octeon/war.h |  2 --
 arch/mips/include/asm/mach-generic/war.h   |  2 --
 arch/mips/include/asm/mach-ip22/war.h  |  2 --
 arch/mips/include/asm/mach-ip27/war.h  |  2 --
 arch/mips/include/asm/mach-ip28/war.h  |  2 --
 arch/mips/include/asm/mach-ip30/war.h  |  2 --
 arch/mips/include/asm/mach-ip32/war.h  |  2 --
 arch/mips/include/asm/mach-malta/war.h |  2 --
 arch/mips/include/asm/mach-rc32434/war.h   |  2 --
 arch/mips/include/asm/mach-rm/war.h|  2 --
 arch/mips/include/asm/mach-sibyte/war.h| 14 --
 arch/mips/include/asm/mach-tx49xx/war.h|  2 --
 arch/mips/include/asm/war.h| 14 --
 arch/mips/mm/tlbex.c   |  6 +-
 14 files changed, 5 insertions(+), 51 deletions(-)

diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 0a2bf6b7af94..616de70e697c 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -9,8 +9,6 @@
 #ifndef __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 #define __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #define CAVIUM_OCTEON_DCACHE_PREFETCH_WAR  \
OCTEON_IS_MODEL(OCTEON_CN6XXX)
 
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index 6b7de91435e3..94796ad7e7de 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MACH_GENERIC_WAR_H
 #define __ASM_MACH_GENERIC_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MACH_GENERIC_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index 70de6a5008d3..12cf05dd46d3 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_IP22_WAR_H
 #define __ASM_MIPS_MACH_IP22_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_IP22_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index 5b01e8fe245f..0852fe64594d 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_IP27_WAR_H
 #define __ASM_MIPS_MACH_IP27_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_IP27_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
index ba4267e2d34d..32796925700a 100644
--- a/arch/mips/include/asm/mach-ip28/war.h
+++ b/arch/mips/include/asm/mach-ip28/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_IP28_WAR_H
 #define __ASM_MIPS_MACH_IP28_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_IP28_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip30/war.h 
b/arch/mips/include/asm/mach-ip30/war.h
index f404e22b7798..ea77545f5128 100644
--- a/arch/mips/include/asm/mach-ip30/war.h
+++ b/arch/mips/include/asm/mach-ip30/war.h
@@ -5,6 +5,4 @@
 #ifndef __ASM_MIPS_MACH_IP30_WAR_H
 #define __ASM_MIPS_MACH_IP30_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_IP30_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip32/war.h 
b/arch/mips/include/asm/mach-ip32/war.h
index 01475db746ec..3e81408795b4 100644
--- a/arch/mips/include/asm/mach-ip32/war.h
+++ b/arch/mips/include/asm/mach-ip32/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_IP32_WAR_H
 #define __ASM_MIPS_MACH_IP32_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_IP32_WAR_H */
diff --git a/arch/mips/include/asm/mach-malta/war.h 
b/arch/mips/include/asm/mach-malta/war.h
index 68b204ff59a6..0f5401c0e888 100644
--- a/arch/mips/include/asm/mach-malta/war.h
+++ b/arch/mips/include/asm/mach-malta/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_MIPS_WAR_H
 #define __ASM_MIPS_MACH_MIPS_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git a/arch/mips/include/asm/mach-rc32434/war.h 
b/arch/mips/include/asm/mach-rc32434/war.h
index 68b204ff59a6..0f5401c0e888 100644
--- a/arch/mips/include/asm/mach-rc32434/war.h
+++ b/arch/mips/include/asm/mach-rc32434/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_MIPS_WAR_H
 #define __ASM_MIPS_MACH_MIPS_WAR_H
 
-#define BCM1250_M3_WAR 0
-
 #endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git a/arch/mips/include/asm/mach-rm/war.h 
b/arch/mips/include/asm/mach-rm/war.h
index 093a3894ae41..723c9de79ea1 100644
--- a/arch/mips/include/asm/mach-rm/war.h
+++ b/arch/mips/include/asm/mach-rm/war.h
@@ -8,6 +8,4 @@
 #ifndef __ASM_MIPS_MACH_RM_WAR_H
 #define 

[PATCH 09/12] MIPS: Replace SIBYTE_1956_WAR by CONFIG_SB1_PASS_2_WORKAROUNDS

2020-08-24 Thread Thomas Bogendoerfer
SB1250 uart bug is related to PASS 2 workarounds. Use config
CONFIG_SB1_PASS_2_WORKAROUNDS directly and get rid of SIBYTE_1956_WAR.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/include/asm/mach-cavium-octeon/war.h | 1 -
 arch/mips/include/asm/mach-generic/war.h   | 1 -
 arch/mips/include/asm/mach-ip22/war.h  | 1 -
 arch/mips/include/asm/mach-ip27/war.h  | 1 -
 arch/mips/include/asm/mach-ip28/war.h  | 1 -
 arch/mips/include/asm/mach-ip30/war.h  | 1 -
 arch/mips/include/asm/mach-ip32/war.h  | 1 -
 arch/mips/include/asm/mach-malta/war.h | 1 -
 arch/mips/include/asm/mach-rc32434/war.h   | 1 -
 arch/mips/include/asm/mach-rm/war.h| 1 -
 arch/mips/include/asm/mach-sibyte/war.h| 2 --
 arch/mips/include/asm/mach-tx49xx/war.h| 1 -
 arch/mips/include/asm/war.h| 7 ---
 drivers/tty/serial/sb1250-duart.c  | 9 -
 14 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 9aa4ea5522a9..0a2bf6b7af94 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -10,7 +10,6 @@
 #define __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #define CAVIUM_OCTEON_DCACHE_PREFETCH_WAR  \
OCTEON_IS_MODEL(OCTEON_CN6XXX)
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index 4f25636661d5..6b7de91435e3 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MACH_GENERIC_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MACH_GENERIC_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index 09169cfbf932..70de6a5008d3 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MIPS_MACH_IP22_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP22_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index 1c81d5464235..5b01e8fe245f 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MIPS_MACH_IP27_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP27_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
index ff66adbaaae5..ba4267e2d34d 100644
--- a/arch/mips/include/asm/mach-ip28/war.h
+++ b/arch/mips/include/asm/mach-ip28/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MIPS_MACH_IP28_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP28_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip30/war.h 
b/arch/mips/include/asm/mach-ip30/war.h
index b00469a39835..f404e22b7798 100644
--- a/arch/mips/include/asm/mach-ip30/war.h
+++ b/arch/mips/include/asm/mach-ip30/war.h
@@ -6,6 +6,5 @@
 #define __ASM_MIPS_MACH_IP30_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP30_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip32/war.h 
b/arch/mips/include/asm/mach-ip32/war.h
index c57a9cd2e50b..01475db746ec 100644
--- a/arch/mips/include/asm/mach-ip32/war.h
+++ b/arch/mips/include/asm/mach-ip32/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MIPS_MACH_IP32_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_IP32_WAR_H */
diff --git a/arch/mips/include/asm/mach-malta/war.h 
b/arch/mips/include/asm/mach-malta/war.h
index 73c9e6d84a8f..68b204ff59a6 100644
--- a/arch/mips/include/asm/mach-malta/war.h
+++ b/arch/mips/include/asm/mach-malta/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MIPS_MACH_MIPS_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git a/arch/mips/include/asm/mach-rc32434/war.h 
b/arch/mips/include/asm/mach-rc32434/war.h
index 73c9e6d84a8f..68b204ff59a6 100644
--- a/arch/mips/include/asm/mach-rc32434/war.h
+++ b/arch/mips/include/asm/mach-rc32434/war.h
@@ -9,6 +9,5 @@
 #define __ASM_MIPS_MACH_MIPS_WAR_H
 
 #define BCM1250_M3_WAR 0
-#define SIBYTE_1956_WAR0
 
 #endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git a/arch/mips/include/asm/mach-rm/war.h 
b/arch/mips/include/asm/mach-rm/war.h
index c396a31706ac..093a3894ae41 100644
--- a/arch/mips/include/asm/mach-rm/war.h
+++ 

[PATCH 00/12] Convert WAR defines to config options

2020-08-24 Thread Thomas Bogendoerfer
This patches convert workaround (WAR) defines into config options and
gets rid of mach-*/war.h files.

Thomas Bogendoerfer (12):
  MIPS: Convert R4600_V1_INDEX_ICACHEOP into a config option
  MIPS: Convert R4600_V1_HIT_CACHEOP into a config option
  MIPS: Convert R4600_V2_HIT_CACHEOP into a config option
  MIPS: Remove MIPS4K_ICACHE_REFILL_WAR and MIPS_CACHE_SYNC_WAR
  MIPS: Convert TX49XX_ICACHE_INDEX_INV into a config option
  MIPS: Convert ICACHE_REFILLS_WORKAROUND_WAR into a config option
  MIPS: Convert R1_LLSC_WAR info a config option
  MIPS: Convert MIPS34K_MISSED_ITLB_WAR into a config option
  MIPS: Replace SIBYTE_1956_WAR by CONFIG_SB1_PASS_2_WORKAROUNDS
  MIPS: Get rid of BCM1250_M3_WAR
  MIPS: Get rid of CAVIUM_OCTEON_DCACHE_PREFETCH_WAR
  MIPS: Remove mach-*/war.h

 arch/mips/Kconfig  |  80 +
 arch/mips/cavium-octeon/setup.c|   2 +-
 arch/mips/include/asm/futex.h  |   4 +-
 arch/mips/include/asm/llsc.h   |   2 +-
 arch/mips/include/asm/local.h  |   4 +-
 arch/mips/include/asm/mach-cavium-octeon/war.h |  27 -
 arch/mips/include/asm/mach-generic/war.h   |  23 
 arch/mips/include/asm/mach-ip22/war.h  |  27 -
 arch/mips/include/asm/mach-ip27/war.h  |  23 
 arch/mips/include/asm/mach-ip28/war.h  |  23 
 arch/mips/include/asm/mach-ip30/war.h  |  24 
 arch/mips/include/asm/mach-ip32/war.h  |  23 
 arch/mips/include/asm/mach-malta/war.h |  23 
 arch/mips/include/asm/mach-rc32434/war.h   |  23 
 arch/mips/include/asm/mach-rm/war.h|  27 -
 arch/mips/include/asm/mach-sibyte/war.h|  38 ---
 arch/mips/include/asm/mach-tx49xx/war.h|  23 
 arch/mips/include/asm/mipsregs.h   |   4 +-
 arch/mips/include/asm/war.h| 150 -
 arch/mips/kernel/signal.c  |   8 +-
 arch/mips/kernel/syscall.c |   2 +-
 arch/mips/mm/c-r4k.c   |  17 +--
 arch/mips/mm/page.c|  16 ++-
 arch/mips/mm/tlbex.c   |   8 +-
 arch/mips/mm/uasm.c|   2 +-
 drivers/tty/serial/sb1250-duart.c  |   9 +-
 26 files changed, 127 insertions(+), 485 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-cavium-octeon/war.h
 delete mode 100644 arch/mips/include/asm/mach-generic/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip22/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip27/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip28/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip30/war.h
 delete mode 100644 arch/mips/include/asm/mach-ip32/war.h
 delete mode 100644 arch/mips/include/asm/mach-malta/war.h
 delete mode 100644 arch/mips/include/asm/mach-rc32434/war.h
 delete mode 100644 arch/mips/include/asm/mach-rm/war.h
 delete mode 100644 arch/mips/include/asm/mach-sibyte/war.h
 delete mode 100644 arch/mips/include/asm/mach-tx49xx/war.h

-- 
2.16.4



[PATCH 01/12] MIPS: Convert R4600_V1_INDEX_ICACHEOP into a config option

2020-08-24 Thread Thomas Bogendoerfer
Use a new config option to enable R4600 V1 index I-cacheop workaround
and remove define from different war.h files.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/Kconfig  |  8 
 arch/mips/include/asm/mach-cavium-octeon/war.h |  1 -
 arch/mips/include/asm/mach-generic/war.h   |  1 -
 arch/mips/include/asm/mach-ip22/war.h  |  1 -
 arch/mips/include/asm/mach-ip27/war.h  |  1 -
 arch/mips/include/asm/mach-ip28/war.h  |  1 -
 arch/mips/include/asm/mach-ip30/war.h  |  1 -
 arch/mips/include/asm/mach-ip32/war.h  |  1 -
 arch/mips/include/asm/mach-malta/war.h |  1 -
 arch/mips/include/asm/mach-rc32434/war.h   |  1 -
 arch/mips/include/asm/mach-rm/war.h|  1 -
 arch/mips/include/asm/mach-sibyte/war.h|  1 -
 arch/mips/include/asm/mach-tx49xx/war.h|  1 -
 arch/mips/include/asm/war.h| 10 --
 arch/mips/mm/c-r4k.c   |  6 --
 15 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 99220e7e465e..90f8aa04e2ec 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -638,6 +638,7 @@ config SGI_IP22
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
+   select WAR_R4600_V1_INDEX_ICACHEOP
select MIPS_L1_CACHE_SHIFT_7
help
  This are the SGI Indy, Challenge S and Indigo2, as well as certain
@@ -2607,6 +2608,13 @@ config MIPS_ASID_BITS_VARIABLE
 config MIPS_CRC_SUPPORT
bool
 
+# R4600 erratum.  Due to the lack of errata information the exact
+# technical details aren't known.  I've experimentally found that disabling
+# interrupts during indexed I-cache flushes seems to be sufficient to deal
+# with the issue.
+config WAR_R4600_V1_INDEX_ICACHEOP
+   bool
+
 #
 # - Highmem only makes sense for the 32-bit kernel.
 # - The current highmem code will only work properly on physically indexed
diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 2421411b7636..1e01e2f20086 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -9,7 +9,6 @@
 #ifndef __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 #define __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 
-#define R4600_V1_INDEX_ICACHEOP_WAR0
 #define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index f0f4a35d0870..7614a1545d1c 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MACH_GENERIC_WAR_H
 #define __ASM_MACH_GENERIC_WAR_H
 
-#define R4600_V1_INDEX_ICACHEOP_WAR0
 #define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index b48eb4ac362d..3424c1e8a24f 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -12,7 +12,6 @@
  * R4600 CPU modules for the Indy come with both V1.7 and V2.0 processors.
  */
 
-#define R4600_V1_INDEX_ICACHEOP_WAR1
 #define R4600_V1_HIT_CACHEOP_WAR   1
 #define R4600_V2_HIT_CACHEOP_WAR   1
 #define BCM1250_M3_WAR 0
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index ef3efce0094a..5a91a7564fb9 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MIPS_MACH_IP27_WAR_H
 #define __ASM_MIPS_MACH_IP27_WAR_H
 
-#define R4600_V1_INDEX_ICACHEOP_WAR0
 #define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
index 61cd67354829..0dc70d59909e 100644
--- a/arch/mips/include/asm/mach-ip28/war.h
+++ b/arch/mips/include/asm/mach-ip28/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MIPS_MACH_IP28_WAR_H
 #define __ASM_MIPS_MACH_IP28_WAR_H
 
-#define R4600_V1_INDEX_ICACHEOP_WAR0
 #define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
diff --git a/arch/mips/include/asm/mach-ip30/war.h 
b/arch/mips/include/asm/mach-ip30/war.h
index a1fa0c1f5300..9f5c3305674c 100644
--- a/arch/mips/include/asm/mach-ip30/war.h
+++ b/arch/mips/include/asm/mach-ip30/war.h
@@ -5,7 +5,6 @@
 #ifndef __ASM_MIPS_MACH_IP30_WAR_H
 #define __ASM_MIPS_MACH_IP30_WAR_H
 
-#define R4600_V1_INDEX_ICACHEOP_WAR0
 #define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
diff --git 

[PATCH 03/12] MIPS: Convert R4600_V2_HIT_CACHEOP into a config option

2020-08-24 Thread Thomas Bogendoerfer
Use a new config option to enable R4600 V2 cacheop hit workaround
and remove define from different war.h files.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/Kconfig  | 14 ++
 arch/mips/include/asm/mach-cavium-octeon/war.h |  1 -
 arch/mips/include/asm/mach-generic/war.h   |  1 -
 arch/mips/include/asm/mach-ip22/war.h  |  5 -
 arch/mips/include/asm/mach-ip27/war.h  |  1 -
 arch/mips/include/asm/mach-ip28/war.h  |  1 -
 arch/mips/include/asm/mach-ip30/war.h  |  1 -
 arch/mips/include/asm/mach-ip32/war.h  |  1 -
 arch/mips/include/asm/mach-malta/war.h |  1 -
 arch/mips/include/asm/mach-rc32434/war.h   |  1 -
 arch/mips/include/asm/mach-rm/war.h|  5 -
 arch/mips/include/asm/mach-sibyte/war.h|  2 --
 arch/mips/include/asm/mach-tx49xx/war.h|  1 -
 arch/mips/include/asm/war.h| 15 ---
 arch/mips/mm/c-r4k.c   |  3 ++-
 arch/mips/mm/page.c| 10 ++
 16 files changed, 22 insertions(+), 41 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 4d3179b66456..3cbeca6da823 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -640,6 +640,7 @@ config SGI_IP22
select SYS_SUPPORTS_BIG_ENDIAN
select WAR_R4600_V1_INDEX_ICACHEOP
select WAR_R4600_V1_HIT_CACHEOP
+   select WAR_R4600_V2_HIT_CACHEOP
select MIPS_L1_CACHE_SHIFT_7
help
  This are the SGI Indy, Challenge S and Indigo2, as well as certain
@@ -877,6 +878,7 @@ config SNI_RM
select SYS_SUPPORTS_BIG_ENDIAN
select SYS_SUPPORTS_HIGHMEM
select SYS_SUPPORTS_LITTLE_ENDIAN
+   select WAR_R4600_V2_HIT_CACHEOP
help
  The SNI RM200/300/400 are MIPS-based machines manufactured by
  Siemens Nixdorf Informationssysteme (SNI), parent company of Pyramid
@@ -2643,6 +2645,18 @@ config WAR_R4600_V1_INDEX_ICACHEOP
 config WAR_R4600_V1_HIT_CACHEOP
bool
 
+# Writeback and invalidate the primary cache dcache before DMA.
+#
+# R4600 v2.0 bug: "The CACHE instructions Hit_Writeback_Inv_D,
+# Hit_Writeback_D, Hit_Invalidate_D and Create_Dirty_Exclusive_D will only
+# operate correctly if the internal data cache refill buffer is empty.  These
+# CACHE instructions should be separated from any potential data cache miss
+# by a load instruction to an uncached address to empty the response buffer."
+# (Revision 2.0 device errata from IDT available on https://www.idt.com/
+# in .pdf format.)
+config WAR_R4600_V2_HIT_CACHEOP
+   bool
+
 #
 # - Highmem only makes sense for the 32-bit kernel.
 # - The current highmem code will only work properly on physically indexed
diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 915ce0352c20..4bc396d0fdd9 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -9,7 +9,6 @@
 #ifndef __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 #define __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 
-#define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
 #define MIPS4K_ICACHE_REFILL_WAR   0
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index 44d14be2e1e5..4d46a880b832 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MACH_GENERIC_WAR_H
 #define __ASM_MACH_GENERIC_WAR_H
 
-#define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
 #define MIPS4K_ICACHE_REFILL_WAR   0
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index 9154c54d428a..a5a1c41df74e 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -8,11 +8,6 @@
 #ifndef __ASM_MIPS_MACH_IP22_WAR_H
 #define __ASM_MIPS_MACH_IP22_WAR_H
 
-/*
- * R4600 CPU modules for the Indy come with both V1.7 and V2.0 processors.
- */
-
-#define R4600_V2_HIT_CACHEOP_WAR   1
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
 #define MIPS4K_ICACHE_REFILL_WAR   0
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index e7c070c85b7c..5891d506cffd 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MIPS_MACH_IP27_WAR_H
 #define __ASM_MIPS_MACH_IP27_WAR_H
 
-#define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
 #define MIPS4K_ICACHE_REFILL_WAR   0
diff --git a/arch/mips/include/asm/mach-ip28/war.h 
b/arch/mips/include/asm/mach-ip28/war.h
index 22d9f78bf552..346fc567ebb3 

[PATCH 02/12] MIPS: Convert R4600_V1_HIT_CACHEOP into a config option

2020-08-24 Thread Thomas Bogendoerfer
Use a new config option to enable R4600 V1 cacheop hit workaround
and remove define from the different war.h files.

Signed-off-by: Thomas Bogendoerfer 
---
 arch/mips/Kconfig  | 28 +++
 arch/mips/include/asm/mach-cavium-octeon/war.h |  1 -
 arch/mips/include/asm/mach-generic/war.h   |  1 -
 arch/mips/include/asm/mach-ip22/war.h  |  1 -
 arch/mips/include/asm/mach-ip27/war.h  |  1 -
 arch/mips/include/asm/mach-ip28/war.h  |  1 -
 arch/mips/include/asm/mach-ip30/war.h  |  1 -
 arch/mips/include/asm/mach-ip32/war.h  |  1 -
 arch/mips/include/asm/mach-malta/war.h |  1 -
 arch/mips/include/asm/mach-rc32434/war.h   |  1 -
 arch/mips/include/asm/mach-rm/war.h|  1 -
 arch/mips/include/asm/mach-sibyte/war.h|  1 -
 arch/mips/include/asm/mach-tx49xx/war.h|  1 -
 arch/mips/include/asm/war.h| 31 --
 arch/mips/mm/c-r4k.c   |  2 +-
 arch/mips/mm/page.c|  6 +++--
 16 files changed, 33 insertions(+), 46 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 90f8aa04e2ec..4d3179b66456 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -639,6 +639,7 @@ config SGI_IP22
select SYS_SUPPORTS_64BIT_KERNEL
select SYS_SUPPORTS_BIG_ENDIAN
select WAR_R4600_V1_INDEX_ICACHEOP
+   select WAR_R4600_V1_HIT_CACHEOP
select MIPS_L1_CACHE_SHIFT_7
help
  This are the SGI Indy, Challenge S and Indigo2, as well as certain
@@ -2615,6 +2616,33 @@ config MIPS_CRC_SUPPORT
 config WAR_R4600_V1_INDEX_ICACHEOP
bool
 
+# Pleasures of the R4600 V1.x.  Cite from the IDT R4600 V1.7 errata:
+#
+#  18. The CACHE instructions Hit_Writeback_Invalidate_D, Hit_Writeback_D,
+#  Hit_Invalidate_D and Create_Dirty_Excl_D should only be
+#  executed if there is no other dcache activity. If the dcache is
+#  accessed for another instruction immeidately preceding when these
+#  cache instructions are executing, it is possible that the dcache
+#  tag match outputs used by these cache instructions will be
+#  incorrect. These cache instructions should be preceded by at least
+#  four instructions that are not any kind of load or store
+#  instruction.
+#
+#  This is not allowed:lw
+#  nop
+#  nop
+#  nop
+#  cache   Hit_Writeback_Invalidate_D
+#
+#  This is allowed:lw
+#  nop
+#  nop
+#  nop
+#  nop
+#  cache   Hit_Writeback_Invalidate_D
+config WAR_R4600_V1_HIT_CACHEOP
+   bool
+
 #
 # - Highmem only makes sense for the 32-bit kernel.
 # - The current highmem code will only work properly on physically indexed
diff --git a/arch/mips/include/asm/mach-cavium-octeon/war.h 
b/arch/mips/include/asm/mach-cavium-octeon/war.h
index 1e01e2f20086..915ce0352c20 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/war.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/war.h
@@ -9,7 +9,6 @@
 #ifndef __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 #define __ASM_MIPS_MACH_CAVIUM_OCTEON_WAR_H
 
-#define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
diff --git a/arch/mips/include/asm/mach-generic/war.h 
b/arch/mips/include/asm/mach-generic/war.h
index 7614a1545d1c..44d14be2e1e5 100644
--- a/arch/mips/include/asm/mach-generic/war.h
+++ b/arch/mips/include/asm/mach-generic/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MACH_GENERIC_WAR_H
 #define __ASM_MACH_GENERIC_WAR_H
 
-#define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
diff --git a/arch/mips/include/asm/mach-ip22/war.h 
b/arch/mips/include/asm/mach-ip22/war.h
index 3424c1e8a24f..9154c54d428a 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -12,7 +12,6 @@
  * R4600 CPU modules for the Indy come with both V1.7 and V2.0 processors.
  */
 
-#define R4600_V1_HIT_CACHEOP_WAR   1
 #define R4600_V2_HIT_CACHEOP_WAR   1
 #define BCM1250_M3_WAR 0
 #define SIBYTE_1956_WAR0
diff --git a/arch/mips/include/asm/mach-ip27/war.h 
b/arch/mips/include/asm/mach-ip27/war.h
index 5a91a7564fb9..e7c070c85b7c 100644
--- a/arch/mips/include/asm/mach-ip27/war.h
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -8,7 +8,6 @@
 #ifndef __ASM_MIPS_MACH_IP27_WAR_H
 #define __ASM_MIPS_MACH_IP27_WAR_H
 
-#define R4600_V1_HIT_CACHEOP_WAR   0
 #define R4600_V2_HIT_CACHEOP_WAR   0
 #define BCM1250_M3_WAR 0
 #define 

[PATCH v2 05/19] dt-bindings: perf: fsl-imx-ddr: Add i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: ddr-pmu@3d80:
compatible:0: 'fsl,imx8mm-ddr-pmu' is not one of ['fsl,imx8-ddr-pmu', 
'fsl,imx8m-ddr-pmu', 'fsl,imx8mp-ddr-pmu']
From schema: Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: ddr-pmu@3d80:
compatible: ['fsl,imx8mm-ddr-pmu', 'fsl,imx8m-ddr-pmu'] is too long

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: ddr-pmu@3d80:
compatible: Additional items are not allowed ('fsl,imx8m-ddr-pmu' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 

---

Changes since v1:
1. Handle also fsl,imx8mp-ddr-pmu
---
 .../devicetree/bindings/perf/fsl-imx-ddr.yaml| 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml 
b/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml
index 9ed8f44adabe..5aad9f4e0b2a 100644
--- a/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml
+++ b/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml
@@ -11,10 +11,18 @@ maintainers:
 
 properties:
   compatible:
-enum:
-  - fsl,imx8-ddr-pmu
-  - fsl,imx8m-ddr-pmu
-  - fsl,imx8mp-ddr-pmu
+oneOf:
+  - enum:
+  - fsl,imx8-ddr-pmu
+  - fsl,imx8m-ddr-pmu
+  - fsl,imx8mp-ddr-pmu
+  - items:
+  - enum:
+  - fsl,imx8mm-ddr-pmu
+  - fsl,imx8mn-ddr-pmu
+  - fsl,imx8mq-ddr-pmu
+  - fsl,imx8mp-ddr-pmu
+  - const: fsl,imx8m-ddr-pmu
 
   reg:
 maxItems: 1
-- 
2.17.1



Re: [PATCH stable v4.9 v2] arm64: entry: Place an SB sequence following an ERET instruction

2020-08-24 Thread Will Deacon
Hi Florian,

On Fri, Aug 21, 2020 at 10:16:23AM -0700, Florian Fainelli wrote:
> On 8/21/20 9:03 AM, Will Deacon wrote:
> > On Fri, Aug 07, 2020 at 03:14:29PM +0200, Greg KH wrote:
> >> On Thu, Aug 06, 2020 at 01:00:54PM -0700, Florian Fainelli wrote:
> >>> Greg, did you have a chance to queue those changes for 4.9, 4.14 and 4.19?
> >>>
> >>> https://lore.kernel.org/linux-arm-kernel/20200720182538.13304-1-f.faine...@gmail.com/
> >>> https://lore.kernel.org/linux-arm-kernel/20200720182937.14099-1-f.faine...@gmail.com/
> >>> https://lore.kernel.org/linux-arm-kernel/20200709195034.15185-1-f.faine...@gmail.com/
> >>
> >> Nope, I was waiting for Will's "ack" for these.
> > 
> > This patch doesn't even build for me (the 'sb' macro is not defined in 4.9),
> > and I really wonder why we bother backporting it at all. Nobody's ever shown
> > it to be a problem in practice, and it's clear that this is just being
> > submitted to tick a box rather than anything else (otherwise it would build,
> > right?).
> 
> Doh, I completely missed submitting the patch this depended on that's
> why I did not notice the build failure locally, sorry about that, what a
> shame.
> 
> Would not be the same "tick a box" argument be used against your
> original submission then? Sure, I have not been able to demonstrate in
> real life this was a problem, however the same can be said about a lot
> security related fixes.

Sort of, although I wrote the original patch because it was dead easy to do
and saved having to think too much about the problem, whereas the complexity
of backporting largerly diminishes that imo.

> What if it becomes exploitable in the future, would not it be nice to
> have it in a 6 year LTS kernel?

Even if people are stuck on an old LTS, they should still be taking the
regular updates for it, and we would obviously need to backport the fix if
it turned out to be exploitable (and hey, we could even test it then!).

> > So I'm not going to Ack any of them. As with a lot of this side-channel
> > stuff the cure is far worse than the disease.
> Assuming that my v3 does build correctly, which it will, would you be
> keen on changing your position?

Note that I'm not trying to block this patch from going in, I'm just saying
that I'm not supportive of it. Perhaps somebody from Arm can review it if
they think it's worth the effort.

Will


[PATCH v2 06/19] dt-bindings: pwm: imx-pwm: Add i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: pwm@3066:
compatible:0: 'fsl,imx8mm-pwm' is not one of ['fsl,imx1-pwm', 
'fsl,imx27-pwm']
From schema: Documentation/devicetree/bindings/pwm/imx-pwm.yaml

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: pwm@3066:
compatible: ['fsl,imx8mm-pwm', 'fsl,imx27-pwm'] is too long

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: pwm@3066:
compatible: Additional items are not allowed ('fsl,imx27-pwm' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 Documentation/devicetree/bindings/pwm/imx-pwm.yaml | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/pwm/imx-pwm.yaml 
b/Documentation/devicetree/bindings/pwm/imx-pwm.yaml
index 01df06777cba..473863eb67e5 100644
--- a/Documentation/devicetree/bindings/pwm/imx-pwm.yaml
+++ b/Documentation/devicetree/bindings/pwm/imx-pwm.yaml
@@ -19,9 +19,17 @@ properties:
   - 3
 
   compatible:
-enum:
-  - fsl,imx1-pwm
-  - fsl,imx27-pwm
+oneOf:
+  - enum:
+  - fsl,imx1-pwm
+  - fsl,imx27-pwm
+  - items:
+  - enum:
+  - fsl,imx8mm-pwm
+  - fsl,imx8mn-pwm
+  - fsl,imx8mp-pwm
+  - fsl,imx8mq-pwm
+  - const: fsl,imx27-pwm
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 07/19] dt-bindings: serial: fsl-imx-uart: Add i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: pwm@3066:
compatible:0: 'fsl,imx8mm-pwm' is not one of ['fsl,imx1-pwm', 
'fsl,imx27-pwm']
From schema: Documentation/devicetree/bindings/pwm/imx-pwm.yaml

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: pwm@3066:
compatible: ['fsl,imx8mm-pwm', 'fsl,imx27-pwm'] is too long

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: pwm@3066:
compatible: Additional items are not allowed ('fsl,imx27-pwm' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 

---

Changes since v1:
1. Fix subject prefix
---
 Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml 
b/Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
index cba3f83ccd5f..3d896173b3b0 100644
--- a/Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
@@ -36,6 +36,10 @@ properties:
 - fsl,imx6sx-uart
 - fsl,imx6ul-uart
 - fsl,imx7d-uart
+- fsl,imx8mm-uart
+- fsl,imx8mn-uart
+- fsl,imx8mp-uart
+- fsl,imx8mq-uart
   - const: fsl,imx6q-uart
 
   reg:
-- 
2.17.1



[PATCH v2 09/19] dt-bindings: mtd: gpmi-nand: Add i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: nand-controller@33002000:
compatible:0: 'fsl,imx8mm-gpmi-nand' is not one of ['fsl,imx23-gpmi-nand', 
'fsl,imx28-gpmi-nand', 'fsl,imx6q-gpmi-nand', 'fsl,imx6sx-gpmi-nand', 
'fsl,imx7d-gpmi-nand']
From schema: Documentation/devicetree/bindings/mtd/gpmi-nand.yaml

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: nand-controller@33002000:
compatible: ['fsl,imx8mm-gpmi-nand', 'fsl,imx7d-gpmi-nand'] is too long

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: nand-controller@33002000:
compatible: Additional items are not allowed ('fsl,imx7d-gpmi-nand' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 .../devicetree/bindings/mtd/gpmi-nand.yaml | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/gpmi-nand.yaml 
b/Documentation/devicetree/bindings/mtd/gpmi-nand.yaml
index 3201372b7f85..28ff8c581837 100644
--- a/Documentation/devicetree/bindings/mtd/gpmi-nand.yaml
+++ b/Documentation/devicetree/bindings/mtd/gpmi-nand.yaml
@@ -20,12 +20,18 @@ description: |
 
 properties:
   compatible:
-enum:
-  - fsl,imx23-gpmi-nand
-  - fsl,imx28-gpmi-nand
-  - fsl,imx6q-gpmi-nand
-  - fsl,imx6sx-gpmi-nand
-  - fsl,imx7d-gpmi-nand
+oneOf:
+  - enum:
+  - fsl,imx23-gpmi-nand
+  - fsl,imx28-gpmi-nand
+  - fsl,imx6q-gpmi-nand
+  - fsl,imx6sx-gpmi-nand
+  - fsl,imx7d-gpmi-nand
+  - items:
+  - enum:
+  - fsl,imx8mm-gpmi-nand
+  - fsl,imx8mn-gpmi-nand
+  - const: fsl,imx7d-gpmi-nand
 
   reg:
 items:
-- 
2.17.1



[PATCH v2 13/19] dt-bindings: nvmem: imx-ocotp: Update i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs use two compatibles so update the binding to
fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: efuse@3035: 
compatible:1: 'syscon' was expected
From schema: Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: efuse@3035:
compatible: ['fsl,imx8mn-ocotp', 'fsl,imx8mm-ocotp', 'syscon'] is too long

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: efuse@3035:
compatible: Additional items are not allowed ('syscon' was unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 .../devicetree/bindings/nvmem/imx-ocotp.yaml  | 39 ---
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml 
b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
index 1c9d7f05f173..b5b250185afd 100644
--- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
@@ -19,21 +19,30 @@ allOf:
 
 properties:
   compatible:
-items:
-  - enum:
-  - fsl,imx6q-ocotp
-  - fsl,imx6sl-ocotp
-  - fsl,imx6sx-ocotp
-  - fsl,imx6ul-ocotp
-  - fsl,imx6ull-ocotp
-  - fsl,imx7d-ocotp
-  - fsl,imx6sll-ocotp
-  - fsl,imx7ulp-ocotp
-  - fsl,imx8mq-ocotp
-  - fsl,imx8mm-ocotp
-  - fsl,imx8mn-ocotp
-  - fsl,imx8mp-ocotp
-  - const: syscon
+oneOf:
+  - items:
+  - enum:
+  - fsl,imx6q-ocotp
+  - fsl,imx6sl-ocotp
+  - fsl,imx6sx-ocotp
+  - fsl,imx6ul-ocotp
+  - fsl,imx6ull-ocotp
+  - fsl,imx7d-ocotp
+  - fsl,imx6sll-ocotp
+  - fsl,imx7ulp-ocotp
+  - fsl,imx8mq-ocotp
+  - fsl,imx8mm-ocotp
+  - fsl,imx8mn-ocotp
+  - fsl,imx8mp-ocotp
+  - const: syscon
+  - items:
+  # The devices are not really compatible with fsl,imx8mm-ocotp, 
however
+  # the code for getting SoC revision depends on fsl,imx8mm-ocotp 
compatible.
+  - enum:
+  - fsl,imx8mn-ocotp
+  - fsl,imx8mp-ocotp
+  - const: fsl,imx8mm-ocotp
+  - const: syscon
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 17/19] dt-bindings: serial: fsl-lpuart: Fix compatible matching

2020-08-24 Thread Krzysztof Kozlowski
The i.MX 8QXP DTSes use two compatibles so update the binding to fix
dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8qxp-mek.dt.yaml: serial@5a06:
compatible: ['fsl,imx8qxp-lpuart', 'fsl,imx7ulp-lpuart'] is too long
From schema: Documentation/devicetree/bindings/serial/fsl-lpuart.yaml

  arch/arm64/boot/dts/freescale/imx8qxp-mek.dt.yaml: serial@5a06:
compatible: Additional items are not allowed ('fsl,imx7ulp-lpuart' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 

---

Changes since v1:
1. New patch.
---
 .../devicetree/bindings/serial/fsl-lpuart.yaml | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/serial/fsl-lpuart.yaml 
b/Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
index e82c2cf9fef7..8ee651f2ef0b 100644
--- a/Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
+++ b/Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
@@ -14,13 +14,17 @@ allOf:
 
 properties:
   compatible:
-enum:
-  - fsl,vf610-lpuart
-  - fsl,ls1021a-lpuart
-  - fsl,ls1028a-lpuart
-  - fsl,imx7ulp-lpuart
-  - fsl,imx8qxp-lpuart
-  - fsl,imx8qm-lpuart
+oneOf:
+  - enum:
+  - fsl,vf610-lpuart
+  - fsl,ls1021a-lpuart
+  - fsl,ls1028a-lpuart
+  - fsl,imx7ulp-lpuart
+  - fsl,imx8qxp-lpuart
+  - fsl,imx8qm-lpuart
+  - items:
+  - const: fsl,imx8qxp-lpuart
+  - const: fsl,imx7ulp-lpuart
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 15/19] dt-bindings: arm: fsl: Add ZII Ultra boards binding

2020-08-24 Thread Krzysztof Kozlowski
Document the binding for Zodiac Inflight Innovations Ultra Boards.

Signed-off-by: Krzysztof Kozlowski 
---
 Documentation/devicetree/bindings/arm/fsl.yaml | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 377fc2a4c159..b48dbf924cfe 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -373,6 +373,14 @@ properties:
   - technexion,pico-pi-imx8m  # TechNexion PICO-PI-8M evk
   - const: fsl,imx8mq
 
+  - description: Zodiac Inflight Innovations Ultra Boards
+items:
+  - enum:
+  - zii,imx8mq-ultra-rmb3
+  - zii,imx8mq-ultra-zest
+  - const: zii,imx8mq-ultra
+  - const: fsl,imx8mq
+
   - description: i.MX8QXP based Boards
 items:
   - enum:
-- 
2.17.1



[PATCH v2 19/19] arm64: dts: imx8mq-zii-ultra: Add hog suffixes to GPIO hogs

2020-08-24 Thread Krzysztof Kozlowski
According to device tree specification, device node names should be
somewhat generic and reflecting the function of the device so add the
"hog" suffixes to all GPIO hog nodes.

Signed-off-by: Krzysztof Kozlowski 
---
 arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
index 0d1088dcaa02..fa7a041ffcfd 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
@@ -229,28 +229,28 @@
pinctrl-names = "default";
pinctrl-0 = <_gpio3_hog>;
 
-   usb-emulation {
+   usb-emulation-hog {
gpio-hog;
gpios = <10 GPIO_ACTIVE_HIGH>;
output-low;
line-name = "usb-emulation";
};
 
-   usb-mode1 {
+   usb-mode1-hog {
gpio-hog;
gpios = <11 GPIO_ACTIVE_HIGH>;
output-high;
line-name = "usb-mode1";
};
 
-   usb-pwr {
+   usb-pwr-hog {
gpio-hog;
gpios = <12 GPIO_ACTIVE_LOW>;
output-high;
line-name = "usb-pwr-ctrl-en-n";
};
 
-   usb-mode2 {
+   usb-mode2-hog {
gpio-hog;
gpios = <13 GPIO_ACTIVE_HIGH>;
output-high;
-- 
2.17.1



[PATCH v2 11/19] dt-bindings: thermal: imx8mm-thermal: Add i.MX 8M Nano compatible

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: tmu@3026:
compatible:0: 'fsl,imx8mn-tmu' is not one of ['fsl,imx8mm-tmu', 
'fsl,imx8mp-tmu']
From schema: Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: tmu@3026:
compatible: ['fsl,imx8mn-tmu', 'fsl,imx8mm-tmu'] is too long

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: tmu@3026:
compatible: Additional items are not allowed ('fsl,imx8mm-tmu' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 .../devicetree/bindings/thermal/imx8mm-thermal.yaml| 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml 
b/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml
index 38852877b8e3..89c54e08ee61 100644
--- a/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/imx8mm-thermal.yaml
@@ -18,9 +18,13 @@ description: |
 
 properties:
   compatible:
-enum:
-  - fsl,imx8mm-tmu
-  - fsl,imx8mp-tmu
+oneOf:
+  - enum:
+  - fsl,imx8mm-tmu
+  - fsl,imx8mp-tmu
+  - items:
+  - const: fsl,imx8mn-tmu
+  - const: fsl,imx8mm-tmu
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 18/19] arm64: dts: imx8mq-evk: Add hog suffix to wl-reg-on

2020-08-24 Thread Krzysztof Kozlowski
According to device tree specification, device node names should be
somewhat generic and reflecting the function of the device so add the
"hog" suffix to wl-reg-on GPIO hog.

Signed-off-by: Krzysztof Kozlowski 
---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
index 8aa9cd8e495a..a088831d2e24 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
@@ -157,7 +157,7 @@
pinctrl-names = "default";
pinctrl-0 = <_wifi_reset>;
 
-   wl-reg-on {
+   wl-reg-on-hog {
gpio-hog;
gpios = <29 GPIO_ACTIVE_HIGH>;
output-high;
-- 
2.17.1



[PATCH v2 16/19] dt-bindings: interrupt-controller: fsl,irqsteer: Fix compatible matching

2020-08-24 Thread Krzysztof Kozlowski
The i.MX 8M DTSes use two compatibles so update the binding to fix
dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mq-thor96.dt.yaml: 
interrupt-controller@32e2d000:
compatible: ['fsl,imx8m-irqsteer', 'fsl,imx-irqsteer'] is too long
From schema: 
Domentation/devicetree/bindings/interrupt-controller/fsl,irqsteer.yaml

  arch/arm64/boot/dts/freescale/imx8mq-thor96.dt.yaml: 
interrupt-controller@32e2d000:
compatible: Additional items are not allowed ('fsl,imx-irqsteer' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 .../bindings/interrupt-controller/fsl,irqsteer.yaml   | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/fsl,irqsteer.yaml 
b/Documentation/devicetree/bindings/interrupt-controller/fsl,irqsteer.yaml
index 360a575ef8b0..3b11a1a15398 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/fsl,irqsteer.yaml
+++ b/Documentation/devicetree/bindings/interrupt-controller/fsl,irqsteer.yaml
@@ -11,9 +11,11 @@ maintainers:
 
 properties:
   compatible:
-enum:
-  - fsl,imx8m-irqsteer
-  - fsl,imx-irqsteer
+oneOf:
+  - const: fsl,imx-irqsteer
+  - items:
+  - const: fsl,imx8m-irqsteer
+  - const: fsl,imx-irqsteer
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 10/19] dt-bindings: reset: fsl,imx7-src: Add i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: reset-controller@3039:
compatible:0: 'fsl,imx8mm-src' is not one of ['fsl,imx7d-src', 
'fsl,imx8mq-src', 'fsl,imx8mp-src']
From schema: Documentation/devicetree/bindings/reset/fsl,imx7-src.yaml

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: reset-controller@3039:
compatible:1: 'syscon' was expected

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: reset-controller@3039:
compatible: ['fsl,imx8mm-src', 'fsl,imx8mq-src', 'syscon'] is too long

Signed-off-by: Krzysztof Kozlowski 
---
 .../bindings/reset/fsl,imx7-src.yaml  | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/reset/fsl,imx7-src.yaml 
b/Documentation/devicetree/bindings/reset/fsl,imx7-src.yaml
index 569cd3bd3a70..00430e2eabc8 100644
--- a/Documentation/devicetree/bindings/reset/fsl,imx7-src.yaml
+++ b/Documentation/devicetree/bindings/reset/fsl,imx7-src.yaml
@@ -22,12 +22,19 @@ description: |
 
 properties:
   compatible:
-items:
-  - enum:
-  - fsl,imx7d-src
-  - fsl,imx8mq-src
-  - fsl,imx8mp-src
-  - const: syscon
+oneOf:
+  - items:
+  - enum:
+  - fsl,imx7d-src
+  - fsl,imx8mq-src
+  - fsl,imx8mp-src
+  - const: syscon
+  - items:
+  - enum:
+  - fsl,imx8mm-src
+  - fsl,imx8mn-src
+  - const: fsl,imx8mq-src
+  - const: syscon
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 12/19] dt-bindings: mmc: fsl-imx-esdhc: Fix i.MX 8 compatible matching

2020-08-24 Thread Krzysztof Kozlowski
The i.MX 8 DTSes use two compatibles so update the binding to fix
dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: mmc@30b4:
compatible: ['fsl,imx8mn-usdhc', 'fsl,imx7d-usdhc'] is too long
From schema: Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml

  arch/arm64/boot/dts/freescale/imx8mn-evk.dt.yaml: mmc@30b4:
compatible: Additional items are not allowed ('fsl,imx7d-usdhc' was 
unexpected)

  arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dt.yaml: mmc@30b4:
compatible: ['fsl,imx8mn-usdhc', 'fsl,imx7d-usdhc'] is too long

Signed-off-by: Krzysztof Kozlowski 

---

Changes since v1:
1. Handle also fsl,imx8mm-usdhc and fsl,imx8qxp-usdhc
---
 .../bindings/mmc/fsl-imx-esdhc.yaml   | 40 +++
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml 
b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
index 10b45966f1b8..54f05e2a4246 100644
--- a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
+++ b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
@@ -21,23 +21,29 @@ description: |
 
 properties:
   compatible:
-enum:
-  - fsl,imx25-esdhc
-  - fsl,imx35-esdhc
-  - fsl,imx51-esdhc
-  - fsl,imx53-esdhc
-  - fsl,imx6q-usdhc
-  - fsl,imx6sl-usdhc
-  - fsl,imx6sx-usdhc
-  - fsl,imx6ull-usdhc
-  - fsl,imx7d-usdhc
-  - fsl,imx7ulp-usdhc
-  - fsl,imx8mq-usdhc
-  - fsl,imx8mm-usdhc
-  - fsl,imx8mn-usdhc
-  - fsl,imx8mp-usdhc
-  - fsl,imx8qm-usdhc
-  - fsl,imx8qxp-usdhc
+oneOf:
+  - enum:
+  - fsl,imx25-esdhc
+  - fsl,imx35-esdhc
+  - fsl,imx51-esdhc
+  - fsl,imx53-esdhc
+  - fsl,imx6q-usdhc
+  - fsl,imx6sl-usdhc
+  - fsl,imx6sx-usdhc
+  - fsl,imx6ull-usdhc
+  - fsl,imx7d-usdhc
+  - fsl,imx7ulp-usdhc
+  - fsl,imx8mq-usdhc
+  - fsl,imx8mm-usdhc
+  - fsl,imx8qxp-usdhc
+  - items:
+  - enum:
+  - fsl,imx8mm-usdhc
+  - fsl,imx8mn-usdhc
+  - fsl,imx8mp-usdhc
+  - fsl,imx8mq-usdhc
+  - fsl,imx8qxp-usdhc
+  - const: fsl,imx7d-usdhc
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 14/19] dt-bindings: arm: fsl: Fix Toradex Colibri i.MX 8 binding

2020-08-24 Thread Krzysztof Kozlowski
The Toradex Colibri i.MX 8 Evaluation board has two Toradex compatibles
so it needs separate entry.  This fixes dtbs_check warning:

  arch/arm64/boot/dts/freescale/imx8qxp-colibri-eval-v3.dt.yaml: /:
compatible: ['toradex,colibri-imx8x-eval-v3', 'toradex,colibri-imx8x', 
'fsl,imx8qxp'] is not valid under any of the given schemas (Possible causes of 
the failure):
arch/arm64/boot/dts/freescale/imx8qxp-colibri-eval-v3.dt.yaml: /: 
compatible: ['toradex,colibri-imx8x-eval-v3', 'toradex,colibri-imx8x', 
'fsl,imx8qxp'] is too long

Signed-off-by: Krzysztof Kozlowski 
---
 Documentation/devicetree/bindings/arm/fsl.yaml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml 
b/Documentation/devicetree/bindings/arm/fsl.yaml
index 37592e7bfee9..377fc2a4c159 100644
--- a/Documentation/devicetree/bindings/arm/fsl.yaml
+++ b/Documentation/devicetree/bindings/arm/fsl.yaml
@@ -379,7 +379,13 @@ properties:
   - einfochips,imx8qxp-ai_ml  # i.MX8QXP AI_ML Board
   - fsl,imx8qxp-mek   # i.MX8QXP MEK Board
   - toradex,colibri-imx8x # Colibri iMX8X Module
+  - const: fsl,imx8qxp
+
+  - description: Toradex Colibri i.MX8 Evaluation Board
+items:
+  - enum:
   - toradex,colibri-imx8x-eval-v3 # Colibri iMX8X Module on 
Colibri Evaluation Board V3
+  - const: toradex,colibri-imx8x
   - const: fsl,imx8qxp
 
   - description:
-- 
2.17.1



Re: [PATCH] x86/entry: Fix AC assertion

2020-08-24 Thread Jürgen Groß

On 24.08.20 17:58, Andrew Cooper wrote:

On 24/08/2020 16:21, pet...@infradead.org wrote:

On Mon, Aug 24, 2020 at 03:22:06PM +0100, Andrew Cooper wrote:

On 24/08/2020 11:14, pet...@infradead.org wrote:

The WARN added in commit 3c73b81a9164 ("x86/entry, selftests: Further
improve user entry sanity checks") unconditionally triggers on my IVB
machine because it does not support SMAP.

For !SMAP hardware we patch out CLAC/STAC instructions and thus if
userspace sets AC, we'll still have it set after entry.

Technically, you don't patch in, rather than patch out.

True.


Fixes: 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity 
checks")
Signed-off-by: Peter Zijlstra (Intel) 
Acked-by: Andy Lutomirski 
---
  arch/x86/include/asm/entry-common.h |   11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

--- a/arch/x86/include/asm/entry-common.h
+++ b/arch/x86/include/asm/entry-common.h
@@ -18,8 +18,15 @@ static __always_inline void arch_check_u
 * state, not the interrupt state as imagined by Xen.
 */
unsigned long flags = native_save_fl();
-   WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
- X86_EFLAGS_NT));
+   unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT;
+
+   /*
+* For !SMAP hardware we patch out CLAC on entry.
+*/
+   if (boot_cpu_has(X86_FEATURE_SMAP))
+   mask |= X86_EFLAGS_AC;

The Xen PV ABI clears AC on entry for 64bit guests, because Linux is
actually running in Ring 3, and therefore susceptible to #AC's which
wouldn't occur natively.

So do you then want it to be something like:

if (boot_cpu_has(X86_FEATURE_SMAP) ||
(IS_ENABLED(CONFIG_64_BIT) && boot_cpu_has(X86_FEATURE_XENPV)))

? Or are you fine with the proposed?


Dealers choice, but this option would be slightly better overall.

(Are there any other cases where Linux will be running in Ring 3?  I
haven't been paying attention to recent changes in PVOps.)


I'm not aware of any other case running kernel code in ring 3.


Juergen


[PATCH v2 08/19] dt-bindings: watchdog: fsl-imx-wdt: Add i.MX 8M compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8M SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-var-som-symphony.dt.yaml: 
watchdog@3028:
compatible:0: 'fsl,imx8mm-wdt' is not one of ['fsl,imx21-wdt']
From schema: Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml

  arch/arm64/boot/dts/freescale/imx8mm-var-som-symphony.dt.yaml: 
watchdog@3028:
compatible: ['fsl,imx8mm-wdt', 'fsl,imx21-wdt'] is too long

  arch/arm64/boot/dts/freescale/imx8mm-var-som-symphony.dt.yaml: 
watchdog@3028:
compatible: Additional items are not allowed ('fsl,imx21-wdt' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 .../devicetree/bindings/watchdog/fsl-imx-wdt.yaml | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml 
b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml
index d96b93b11fad..991b4e33486e 100644
--- a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml
@@ -14,8 +14,15 @@ allOf:
 
 properties:
   compatible:
-enum:
-  - fsl,imx21-wdt
+oneOf:
+  - const: fsl,imx21-wdt
+  - items:
+  - enum:
+  - fsl,imx8mm-wdt
+  - fsl,imx8mn-wdt
+  - fsl,imx8mp-wdt
+  - fsl,imx8mq-wdt
+  - const: fsl,imx21-wdt
 
   reg:
 maxItems: 1
-- 
2.17.1



[PATCH v2 04/19] dt-bindings: gpio: fsl-imx-gpio: Add power-domains

2020-08-24 Thread Krzysztof Kozlowski
Parse also optional power-domains property to fix dtbs_check warnings
like:

  arch/arm64/boot/dts/freescale/imx8qxp-ai_ml.dt.yaml: gpio@5d08: 
'power-domains' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml

Signed-off-by: Krzysztof Kozlowski 
---
 Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml 
b/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml
index 620a52f944e8..de0b9b5f6a70 100644
--- a/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml
+++ b/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml
@@ -53,6 +53,9 @@ properties:
 
   gpio-ranges: true
 
+  power-domains:
+maxItems: 1
+
 patternProperties:
   "^(hog-[0-9]+|.+-hog(-[0-9]+)?)$":
 type: object
-- 
2.17.1



[PATCH v2 01/19] dt-bindings: gpio: fsl-imx-gpio: Add i.MX 8 compatibles

2020-08-24 Thread Krzysztof Kozlowski
DTSes with new i.MX 8 SoCs introduce their own compatibles so add them
to fix dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: gpio@3020:
compatible:0: 'fsl,imx8mm-gpio' is not one of ['fsl,imx1-gpio', 
'fsl,imx21-gpio', 'fsl,imx31-gpio', 'fsl,imx35-gpio', 'fsl,imx7d-gpio']
From schema: Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: gpio@3020:
compatible: ['fsl,imx8mm-gpio', 'fsl,imx35-gpio'] is too long

  arch/arm64/boot/dts/freescale/imx8mm-evk.dt.yaml: gpio@3020:
compatible: Additional items are not allowed ('fsl,imx35-gpio' was 
unexpected)

Signed-off-by: Krzysztof Kozlowski 
---
 .../bindings/gpio/fsl-imx-gpio.yaml   | 21 +--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml 
b/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml
index 0b223abe8cfb..454db20c2d1a 100644
--- a/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml
+++ b/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.yaml
@@ -11,12 +11,21 @@ maintainers:
 
 properties:
   compatible:
-enum:
-  - fsl,imx1-gpio
-  - fsl,imx21-gpio
-  - fsl,imx31-gpio
-  - fsl,imx35-gpio
-  - fsl,imx7d-gpio
+oneOf:
+  - enum:
+  - fsl,imx1-gpio
+  - fsl,imx21-gpio
+  - fsl,imx31-gpio
+  - fsl,imx35-gpio
+  - fsl,imx7d-gpio
+  - items:
+  - enum:
+  - fsl,imx8mm-gpio
+  - fsl,imx8mn-gpio
+  - fsl,imx8mp-gpio
+  - fsl,imx8mq-gpio
+  - fsl,imx8qxp-gpio
+  - const: fsl,imx35-gpio
 
   reg:
 maxItems: 1
-- 
2.17.1



Re: [PATCH 2/4] mm: support nesting memalloc_use_memcg()

2020-08-24 Thread Roman Gushchin
On Mon, Aug 24, 2020 at 11:36:00AM -0400, Dan Schatzberg wrote:
> From: Johannes Weiner 
> 
> The memalloc_use_memcg() function to override the default memcg
> accounting context currently doesn't nest. But the patches to make the
> loop driver cgroup-aware will end up nesting:
> 
> [   98.137605]  alloc_page_buffers+0x210/0x288
> [   98.141799]  __getblk_gfp+0x1d4/0x400
> [   98.145475]  ext4_read_block_bitmap_nowait+0x148/0xbc8
> [   98.150628]  ext4_mb_init_cache+0x25c/0x9b0
> [   98.154821]  ext4_mb_init_group+0x270/0x390
> [   98.159014]  ext4_mb_good_group+0x264/0x270
> [   98.163208]  ext4_mb_regular_allocator+0x480/0x798
> [   98.168011]  ext4_mb_new_blocks+0x958/0x10f8
> [   98.172294]  ext4_ext_map_blocks+0xec8/0x1618
> [   98.176660]  ext4_map_blocks+0x1b8/0x8a0
> [   98.180592]  ext4_writepages+0x830/0xf10
> [   98.184523]  do_writepages+0xb4/0x198
> [   98.188195]  __filemap_fdatawrite_range+0x170/0x1c8
> [   98.193086]  filemap_write_and_wait_range+0x40/0xb0
> [   98.197974]  ext4_punch_hole+0x4a4/0x660
> [   98.201907]  ext4_fallocate+0x294/0x1190
> [   98.205839]  loop_process_work+0x690/0x1100
> [   98.210032]  loop_workfn+0x2c/0x110
> [   98.213529]  process_one_work+0x3e0/0x648
> [   98.217546]  worker_thread+0x70/0x670
> [   98.221217]  kthread+0x1b8/0x1c0
> [   98.224452]  ret_from_fork+0x10/0x18
> 
> where loop_process_work() sets the memcg override to the memcg that
> submitted the IO request, and alloc_page_buffers() sets the override
> to the memcg that instantiated the cache page, which may differ.
> 
> Make memalloc_use_memcg() return the old memcg and convert existing
> users to a stacking model. Delete the unused memalloc_unuse_memcg().
> 
> Signed-off-by: Johannes Weiner 
> Reviewed-by: Shakeel Butt 
> Acked-by: Roman Gushchin 
> Reported-by: Naresh Kamboju 

Hi Dan,

JFYI: I need a similar patch for the bpf memory accounting rework,
so I ended up sending it separately (with some modifications including
different naming): https://lkml.org/lkml/2020/8/21/1464 .

Can you please, rebase your patchset using this patch?

I hope Andrew can pull this standalone patch into 5.9-rc*,
as Shakeel suggested. It will help us to avoid merge conflicts
during the 5.10 merge window.

Thanks!


[tip: x86/fsgsbase] x86/fsgsbase: Replace static_cpu_has() with boot_cpu_has()

2020-08-24 Thread tip-bot2 for Borislav Petkov
The following commit has been merged into the x86/fsgsbase branch of tip:

Commit-ID: 5f1dd4dda5c8796c405e856aaa11e187f6885924
Gitweb:
https://git.kernel.org/tip/5f1dd4dda5c8796c405e856aaa11e187f6885924
Author:Borislav Petkov 
AuthorDate:Tue, 18 Aug 2020 12:28:31 +02:00
Committer: Borislav Petkov 
CommitterDate: Mon, 24 Aug 2020 18:18:32 +02:00

x86/fsgsbase: Replace static_cpu_has() with boot_cpu_has()

ptrace and prctl() are not really fast paths to warrant the use of
static_cpu_has() and cause alternatives patching for no good reason.
Replace with boot_cpu_has() which is simple and fast enough.

No functional changes.

Signed-off-by: Borislav Petkov 
Link: https://lkml.kernel.org/r/20200818103715.32736-1...@alien8.de
---
 arch/x86/include/asm/fsgsbase.h | 4 ++--
 arch/x86/kernel/process_64.c| 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/fsgsbase.h b/arch/x86/include/asm/fsgsbase.h
index d552646..35cff5f 100644
--- a/arch/x86/include/asm/fsgsbase.h
+++ b/arch/x86/include/asm/fsgsbase.h
@@ -57,7 +57,7 @@ static inline unsigned long x86_fsbase_read_cpu(void)
 {
unsigned long fsbase;
 
-   if (static_cpu_has(X86_FEATURE_FSGSBASE))
+   if (boot_cpu_has(X86_FEATURE_FSGSBASE))
fsbase = rdfsbase();
else
rdmsrl(MSR_FS_BASE, fsbase);
@@ -67,7 +67,7 @@ static inline unsigned long x86_fsbase_read_cpu(void)
 
 static inline void x86_fsbase_write_cpu(unsigned long fsbase)
 {
-   if (static_cpu_has(X86_FEATURE_FSGSBASE))
+   if (boot_cpu_has(X86_FEATURE_FSGSBASE))
wrfsbase(fsbase);
else
wrmsrl(MSR_FS_BASE, fsbase);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 9afefe3..df342be 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -407,7 +407,7 @@ unsigned long x86_gsbase_read_cpu_inactive(void)
 {
unsigned long gsbase;
 
-   if (static_cpu_has(X86_FEATURE_FSGSBASE)) {
+   if (boot_cpu_has(X86_FEATURE_FSGSBASE)) {
unsigned long flags;
 
local_irq_save(flags);
@@ -422,7 +422,7 @@ unsigned long x86_gsbase_read_cpu_inactive(void)
 
 void x86_gsbase_write_cpu_inactive(unsigned long gsbase)
 {
-   if (static_cpu_has(X86_FEATURE_FSGSBASE)) {
+   if (boot_cpu_has(X86_FEATURE_FSGSBASE)) {
unsigned long flags;
 
local_irq_save(flags);
@@ -439,7 +439,7 @@ unsigned long x86_fsbase_read_task(struct task_struct *task)
 
if (task == current)
fsbase = x86_fsbase_read_cpu();
-   else if (static_cpu_has(X86_FEATURE_FSGSBASE) ||
+   else if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
 (task->thread.fsindex == 0))
fsbase = task->thread.fsbase;
else
@@ -454,7 +454,7 @@ unsigned long x86_gsbase_read_task(struct task_struct *task)
 
if (task == current)
gsbase = x86_gsbase_read_cpu_inactive();
-   else if (static_cpu_has(X86_FEATURE_FSGSBASE) ||
+   else if (boot_cpu_has(X86_FEATURE_FSGSBASE) ||
 (task->thread.gsindex == 0))
gsbase = task->thread.gsbase;
else


RE: x86/kprobes: kretprobe fails to triggered if kprobe at function entry is not optimized (trigger by int3 breakpoint)

2020-08-24 Thread eddy...@trendmicro.com
> -Original Message-
> From: Peter Zijlstra 
> Sent: Monday, August 24, 2020 10:14 PM
> To: Eddy Wu 
> Cc: Masami Hiramatsu ; linux-kernel@vger.kernel.org; 
> x...@kernel.org; David S. Miller 
> Subject: Re: x86/kprobes: kretprobe fails to triggered if kprobe at function 
> entry is not optimized (trigger by int3 breakpoint)
>
> On Mon, Aug 24, 2020 at 12:02:58PM +, eddy...@trendmicro.com wrote:
> > After bisecting, I found this behavior seems to introduce by this
> > commit: (5.8-rc1) 0d00449c7a28a1514595630735df383dec606812 x86:
> > Replace ist_enter() with nmi_enter() This make kprobe_int3_handler()
> > effectively running as NMI context, which pre_handler_kretprobe()
> > explicitly checked to prevent recursion.
> >
> > (in_nmi() check appears from v3.17)
> > f96f56780ca584930bb3a2769d73fd9a101bcbbe kprobes: Skip kretprobe hit
> > in NMI context to avoid deadlock
> >
> > To make kretprobe work again with int3 breakpoint, I think we can
> > replace the in_nmi() check with in_nmi() == (1 << NMI_SHIFT) at
> > kprobe_int3_handler() and skip kretprobe if nested NMI.  Did a quick
> > test on 5.9-rc2 and it seems to be working.  I'm not sure if it is the
> > best way to do since it may also require change to other architecture
> > as well, any thought?
>
> Masami, would it be possible to have a kretprobe specific recursion
> count here?
>
> I did the below, but i'm not at all sure that isn't horrible broken. I
> can't really find many rp->lock sites and this might break things by
> limiting contention.
>
> ---
>
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index 9be1bff4f586..0bff314cc800 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -153,6 +153,7 @@ struct kretprobe {
> size_t data_size;
> struct hlist_head free_instances;
> raw_spinlock_t lock;
> +   atomic_t recursion;
>  };
>
>  struct kretprobe_instance {
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 287b263c9cb9..27fd096bcb9a 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1934,22 +1934,17 @@ unsigned long __weak arch_deref_entry_point(void 
> *entry)
>  static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
>  {
> struct kretprobe *rp = container_of(p, struct kretprobe, kp);
> -   unsigned long hash, flags = 0;
> struct kretprobe_instance *ri;
> -
> -   /*
> -* To avoid deadlocks, prohibit return probing in NMI contexts,
> -* just skip the probe and increase the (inexact) 'nmissed'
> -* statistical counter, so that the user is informed that
> -* something happened:
> -*/
> -   if (unlikely(in_nmi())) {
> -   rp->nmissed++;
> -   return 0;
> -   }
> +   unsigned long hash, flags;
> +   int rec;
>
> /* TODO: consider to only swap the RA after the last pre_handler 
> fired */
> hash = hash_ptr(current, KPROBE_HASH_BITS);
> +   rec = atomic_fetch_inc_acquire(>recursion);
> +   if (rec) {
> +   rp->nmissed++;
> +   goto out;
> +   }
> raw_spin_lock_irqsave(>lock, flags);
> if (!hlist_empty(>free_instances)) {
> ri = hlist_entry(rp->free_instances.first,
> @@ -1964,7 +1959,7 @@ static int pre_handler_kretprobe(struct kprobe *p, 
> struct pt_regs *regs)
> raw_spin_lock_irqsave(>lock, flags);
> hlist_add_head(>hlist, >free_instances);
> raw_spin_unlock_irqrestore(>lock, flags);
> -   return 0;
> +   goto out;
> }
>
> arch_prepare_kretprobe(ri, regs);
> @@ -1978,6 +1973,8 @@ static int pre_handler_kretprobe(struct kprobe *p, 
> struct pt_regs *regs)
> rp->nmissed++;
> raw_spin_unlock_irqrestore(>lock, flags);
> }
> +out:
> +   atomic_dec(>recursion);
> return 0;
>  }
>  NOKPROBE_SYMBOL(pre_handler_kretprobe);
>
I think kprobe_int3_handler() already prevented pre_handler_kretprobe() from 
recursing, we need to protect critical section in recycle_rp_inst() that might 
be interrupt by NMI.
There is another kretprobe_table_lock has other call site maybe be interrupt by 
NMI too
TREND MICRO EMAIL NOTICE

The information contained in this email and any attachments is confidential and 
may be subject to copyright or other intellectual property protection. If you 
are not the intended recipient, you are not authorized to use or disclose this 
information, and we request that you notify us by reply mail or telephone and 
delete the original message from your mail system.

For details about what personal information we collect and why, please see our 
Privacy Notice on our website at: Read privacy 
policy


Re: [PATCH stable-4.4.y backport] KVM: arm/arm64: Don't reschedule in unmap_stage2_range()

2020-08-24 Thread Greg KH
On Mon, Aug 24, 2020 at 12:28:54PM +0100, Will Deacon wrote:
> Upstream commits fdfe7cbd5880 ("KVM: Pass MMU notifier range flags to
> kvm_unmap_hva_range()") and b5331379bc62 ("KVM: arm64: Only reschedule
> if MMU_NOTIFIER_RANGE_BLOCKABLE is not set") fix a "sleeping from invalid
> context" BUG caused by unmap_stage2_range() attempting to reschedule when
> called on the OOM path.
> 
> Unfortunately, these patches rely on the MMU notifier callback being
> passed knowledge about whether or not blocking is permitted, which was
> introduced in 4.19. Rather than backport this considerable amount of
> infrastructure just for KVM on arm, instead just remove the conditional
> reschedule.
> 
> Cc:  # v4.4 only
> Cc: Marc Zyngier 
> Cc: Suzuki K Poulose 
> Cc: James Morse 
> Signed-off-by: Will Deacon 

Thanks for tall the backports, now queued up.

greg k-h


Re: [PATCH 6/7] mm: Pass pvec directly to find_get_entries

2020-08-24 Thread Jan Kara
On Wed 19-08-20 16:05:54, Matthew Wilcox (Oracle) wrote:
> All callers of find_get_entries() use a pvec, so pass it directly
> instead of manipulating it in the caller.
> 
> Signed-off-by: Matthew Wilcox (Oracle) 

Rather than passing pvec to find_get_entries() and then making everybody
use it, won't it more consistent WRT the naming to make everybody use
pagevec_lookup_entries() (which is trivial at this point in the series) and
then rename find_get_entries() to pagevec_lookup_entries()? I.e., I'd prefer
if the final function was called pagevec_lookup_entries() because that is
IMO more consistent with how other functions are named in this area...

Honza

> ---
>  include/linux/pagemap.h |  3 +--
>  mm/filemap.c| 14 ++
>  mm/shmem.c  | 11 +++
>  mm/swap.c   |  4 +---
>  4 files changed, 11 insertions(+), 21 deletions(-)
> 
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 3f0dc8d00f2a..9d465dd8b379 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -387,8 +387,7 @@ static inline struct page *find_subpage(struct page 
> *head, pgoff_t index)
>  struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
>  struct page *find_lock_entry(struct address_space *mapping, pgoff_t offset);
>  unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
> - pgoff_t end, unsigned int nr_entries, struct page **entries,
> - pgoff_t *indices);
> + pgoff_t end, struct pagevec *pvec, pgoff_t *indices);
>  unsigned find_get_pages_range(struct address_space *mapping, pgoff_t *start,
>   pgoff_t end, unsigned int nr_pages,
>   struct page **pages);
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 159cf3d6f1ae..892c7beef392 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1743,8 +1743,7 @@ EXPORT_SYMBOL(pagecache_get_page);
>   * @mapping: The address_space to search
>   * @start:   The starting page cache index
>   * @end: The highest page cache index to return.
> - * @nr_entries:  The maximum number of entries
> - * @entries: Where the resulting entries are placed
> + * @pvec:Where the resulting entries are placed
>   * @indices: The cache indices corresponding to the entries in @entries
>   *
>   * find_get_entries() will search for and return a group of up to
> @@ -1767,15 +1766,12 @@ EXPORT_SYMBOL(pagecache_get_page);
>   * Return: the number of pages and shadow entries which were found.
>   */
>  unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
> - pgoff_t end, unsigned int nr_entries, struct page **entries,
> - pgoff_t *indices)
> + pgoff_t end, struct pagevec *pvec, pgoff_t *indices)
>  {
>   XA_STATE(xas, >i_pages, start);
>   struct page *page;
>   unsigned int ret = 0;
> -
> - if (!nr_entries)
> - return 0;
> + unsigned nr_entries = PAGEVEC_SIZE;
>  
>   rcu_read_lock();
>   xas_for_each(, page, end) {
> @@ -1806,7 +1802,7 @@ unsigned find_get_entries(struct address_space 
> *mapping, pgoff_t start,
>   }
>  export:
>   indices[ret] = xas.xa_index;
> - entries[ret] = page;
> + pvec->pages[ret] = page;
>   if (++ret == nr_entries)
>   break;
>   continue;
> @@ -1816,6 +1812,8 @@ unsigned find_get_entries(struct address_space 
> *mapping, pgoff_t start,
>   xas_reset();
>   }
>   rcu_read_unlock();
> +
> + pvec->nr = ret;
>   return ret;
>  }
>  
> diff --git a/mm/shmem.c b/mm/shmem.c
> index abdbe61a1aa7..e73c0b2ba99c 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -905,11 +905,7 @@ static void shmem_undo_range(struct inode *inode, loff_t 
> lstart, loff_t lend,
>  
>   pagevec_init();
>   index = start;
> - while (index < end) {
> - pvec.nr = find_get_entries(mapping, index, end - 1,
> - PAGEVEC_SIZE, pvec.pages, indices);
> - if (!pvec.nr)
> - break;
> + while (find_get_entries(mapping, index, end - 1, , indices)) {
>   for (i = 0; i < pagevec_count(); i++) {
>   struct page *page = pvec.pages[i];
>  
> @@ -976,9 +972,8 @@ static void shmem_undo_range(struct inode *inode, loff_t 
> lstart, loff_t lend,
>   while (index < end) {
>   cond_resched();
>  
> - pvec.nr = find_get_entries(mapping, index, end - 1,
> - PAGEVEC_SIZE, pvec.pages, indices);
> - if (!pvec.nr) {
> + if (!find_get_entries(mapping, index, end - 1, ,
> + indices)) {
>   /* If all gone or hole-punch or unfalloc, we're done */
>   if (index == start || end != -1)
>

Re: [PATCH v2 05/10] fs/ntfs3: Add attrib operations

2020-08-24 Thread Mark Harmstone
Hi Konstantin,

I have an interest in this - I wrote the Btrfs driver for Windows, which also 
had to deal with the issue of how to map NTFS concept to Linux xattrs. Unless 
there's a good reason, I think it'd be in everyone's interests if we used the 
same conventions.

You have four(!) different ways of referring to the attributes value, which 
seems a bit excessive. I suggest you just use user.DOSATTRIB - this should be 
in the user namespace as users can set e.g. the hidden flag on files at will. 
This also matches what my driver does, and what Samba does.

I also think it's a mistake to only expose user.DOSATTRIB to Samba - there's 
patches in Wine staging which would also benefit from this.

Also, unless I'm missing something there's a bug in ntfs_setxattr - the user 
shouldn't be able to clear the FILE_ATTRIBUTE_DIRECTORY flag on directories nor 
set it on files.

Thanks

Mark




<    5   6   7   8   9   10   11   12   13   14   >