aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt6
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-imx-lpi2c.txt3
-rw-r--r--Documentation/process/changes.rst2
-rw-r--r--Documentation/scsi/scsi-parameters.txt5
-rw-r--r--MAINTAINERS1
-rw-r--r--Makefile2
-rw-r--r--arch/arc/Kconfig10
-rw-r--r--arch/arc/Makefile10
-rw-r--r--arch/arc/boot/dts/axc003.dtsi26
-rw-r--r--arch/arc/boot/dts/axc003_idu.dtsi26
-rw-r--r--arch/arc/boot/dts/axs10x_mb.dtsi7
-rw-r--r--arch/arc/boot/dts/hsdk.dts11
-rw-r--r--arch/arc/configs/axs101_defconfig3
-rw-r--r--arch/arc/configs/axs103_defconfig3
-rw-r--r--arch/arc/configs/axs103_smp_defconfig3
-rw-r--r--arch/arc/configs/haps_hs_defconfig2
-rw-r--r--arch/arc/configs/haps_hs_smp_defconfig2
-rw-r--r--arch/arc/configs/hsdk_defconfig1
-rw-r--r--arch/arc/configs/nps_defconfig1
-rw-r--r--arch/arc/configs/nsim_700_defconfig2
-rw-r--r--arch/arc/configs/nsim_hs_defconfig2
-rw-r--r--arch/arc/configs/nsim_hs_smp_defconfig2
-rw-r--r--arch/arc/configs/nsimosci_defconfig2
-rw-r--r--arch/arc/configs/nsimosci_hs_defconfig2
-rw-r--r--arch/arc/configs/nsimosci_hs_smp_defconfig2
-rw-r--r--arch/arc/configs/tb10x_defconfig1
-rw-r--r--arch/arc/configs/vdk_hs38_defconfig2
-rw-r--r--arch/arc/configs/vdk_hs38_smp_defconfig1
-rw-r--r--arch/arc/include/asm/atomic.h2
-rw-r--r--arch/arc/include/asm/dma-mapping.h13
-rw-r--r--arch/arc/kernel/troubleshoot.c13
-rw-r--r--arch/arc/mm/cache.c36
-rw-r--r--arch/arc/mm/dma.c82
-rw-r--r--arch/arm/include/asm/kvm_host.h1
-rw-r--r--arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts2
-rw-r--r--arch/arm64/include/asm/kvm_host.h4
-rw-r--r--arch/arm64/kvm/hyp/switch.c9
-rw-r--r--arch/arm64/mm/mmu.c10
-rw-r--r--arch/m68k/mm/mcfmmu.c2
-rw-r--r--arch/mips/include/asm/kvm_host.h1
-rw-r--r--arch/mips/include/asm/mach-lantiq/xway/xway_dma.h1
-rw-r--r--arch/mips/kernel/vdso.c20
-rw-r--r--arch/mips/kvm/mmu.c10
-rw-r--r--arch/mips/lantiq/xway/dma.c4
-rw-r--r--arch/nds32/Kconfig4
-rw-r--r--arch/nds32/Makefile4
-rw-r--r--arch/nds32/include/asm/elf.h4
-rw-r--r--arch/nds32/include/asm/ftrace.h46
-rw-r--r--arch/nds32/include/asm/nds32.h1
-rw-r--r--arch/nds32/include/asm/uaccess.h229
-rw-r--r--arch/nds32/kernel/Makefile6
-rw-r--r--arch/nds32/kernel/atl2c.c3
-rw-r--r--arch/nds32/kernel/ex-entry.S2
-rw-r--r--arch/nds32/kernel/ex-exit.S4
-rw-r--r--arch/nds32/kernel/ftrace.c309
-rw-r--r--arch/nds32/kernel/module.c4
-rw-r--r--arch/nds32/kernel/stacktrace.c6
-rw-r--r--arch/nds32/kernel/traps.c42
-rw-r--r--arch/nds32/kernel/vmlinux.lds.S12
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_hv.c2
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_radix.c6
-rw-r--r--arch/riscv/kernel/setup.c7
-rw-r--r--arch/s390/include/asm/mmu.h8
-rw-r--r--arch/s390/kvm/kvm-s390.c2
-rw-r--r--arch/s390/kvm/priv.c30
-rw-r--r--arch/s390/kvm/vsie.c3
-rw-r--r--arch/x86/include/asm/atomic.h12
-rw-r--r--arch/x86/include/asm/atomic64_32.h8
-rw-r--r--arch/x86/include/asm/atomic64_64.h12
-rw-r--r--arch/x86/include/asm/kdebug.h12
-rw-r--r--arch/x86/include/asm/kvm_host.h22
-rw-r--r--arch/x86/include/asm/pgtable.h2
-rw-r--r--arch/x86/include/asm/pgtable_64.h20
-rw-r--r--arch/x86/kernel/apic/vector.c2
-rw-r--r--arch/x86/kernel/cpu/microcode/amd.c24
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c17
-rw-r--r--arch/x86/kernel/dumpstack.c11
-rw-r--r--arch/x86/kernel/process_32.c4
-rw-r--r--arch/x86/kernel/process_64.c12
-rw-r--r--arch/x86/kernel/tsc.c2
-rw-r--r--arch/x86/kvm/lapic.c27
-rw-r--r--arch/x86/kvm/mmu.c26
-rw-r--r--arch/x86/kvm/svm.c19
-rw-r--r--arch/x86/kvm/vmx.c43
-rw-r--r--arch/x86/kvm/x86.c28
-rw-r--r--arch/x86/kvm/x86.h2
-rw-r--r--arch/x86/mm/pgtable.c8
-rw-r--r--block/bfq-cgroup.c4
-rw-r--r--block/bio.c3
-rw-r--r--block/blk-cgroup.c105
-rw-r--r--block/blk-core.c5
-rw-r--r--block/blk-throttle.c5
-rw-r--r--drivers/acpi/acpi_lpss.c2
-rw-r--r--drivers/acpi/bus.c13
-rw-r--r--drivers/ata/libata-core.c2
-rw-r--r--drivers/base/memory.c20
-rw-r--r--drivers/block/nbd.c3
-rw-r--r--drivers/block/rbd.c235
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/random.c11
-rw-r--r--drivers/dax/device.c3
-rw-r--r--drivers/firmware/arm_scmi/perf.c8
-rw-r--r--drivers/gpio/gpio-adp5588.c24
-rw-r--r--drivers/gpio/gpio-dwapb.c1
-rw-r--r--drivers/gpio/gpiolib-acpi.c86
-rw-r--r--drivers/gpio/gpiolib-of.c1
-rw-r--r--drivers/gpu/drm/i915/gvt/dmabuf.c33
-rw-r--r--drivers/gpu/drm/i915/gvt/fb_decoder.c5
-rw-r--r--drivers/gpu/drm/i915/gvt/fb_decoder.h2
-rw-r--r--drivers/gpu/drm/i915/gvt/handlers.c33
-rw-r--r--drivers/gpu/drm/i915/gvt/mmio_context.c2
-rw-r--r--drivers/gpu/drm/i915/gvt/sched_policy.c37
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h4
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c17
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c33
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv50/disp.c67
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c110
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c44
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.h2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c21
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c57
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.h5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_vga.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c14
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c54
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c18
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c2
-rw-r--r--drivers/hid/hid-apple.c9
-rw-r--r--drivers/hid/hid-core.c5
-rw-r--r--drivers/hid/hid-ids.h6
-rw-r--r--drivers/hid/hid-input.c5
-rw-r--r--drivers/hid/hid-multitouch.c19
-rw-r--r--drivers/hid/hid-saitek.c2
-rw-r--r--drivers/hid/hid-sensor-hub.c23
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c11
-rw-r--r--drivers/hid/intel-ish-hid/ipc/hw-ish.h1
-rw-r--r--drivers/hid/intel-ish-hid/ipc/pci-ish.c1
-rw-r--r--drivers/hwmon/raspberrypi-hwmon.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c7
-rw-r--r--drivers/i2c/busses/i2c-imx-lpi2c.c1
-rw-r--r--drivers/i2c/busses/i2c-uniphier-f.c7
-rw-r--r--drivers/i2c/busses/i2c-uniphier.c7
-rw-r--r--drivers/i2c/busses/i2c-xiic.c4
-rw-r--r--drivers/infiniband/core/cma.c12
-rw-r--r--drivers/infiniband/core/rdma_core.c2
-rw-r--r--drivers/infiniband/core/ucma.c6
-rw-r--r--drivers/infiniband/core/uverbs_main.c5
-rw-r--r--drivers/infiniband/hw/bnxt_re/ib_verbs.c2
-rw-r--r--drivers/infiniband/hw/bnxt_re/qplib_fp.c2
-rw-r--r--drivers/infiniband/hw/cxgb4/qp.c6
-rw-r--r--drivers/infiniband/hw/mlx4/main.c8
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c2
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c4
-rw-r--r--drivers/md/md-cluster.c10
-rw-r--r--drivers/md/raid10.c5
-rw-r--r--drivers/md/raid5-log.h5
-rw-r--r--drivers/md/raid5.c6
-rw-r--r--drivers/memory/ti-aemif.c2
-rw-r--r--drivers/net/appletalk/ipddp.c8
-rw-r--r--drivers/net/ethernet/lantiq_etop.c1
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/action.c6
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/main.h1
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/match.c2
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/offload.c11
-rw-r--r--drivers/net/ethernet/realtek/r8169.c9
-rw-r--r--drivers/net/hyperv/netvsc_drv.c9
-rw-r--r--drivers/net/xen-netfront.c8
-rw-r--r--drivers/s390/net/qeth_core_main.c11
-rw-r--r--drivers/s390/net/qeth_l2_main.c2
-rw-r--r--drivers/s390/net/qeth_l3_main.c2
-rw-r--r--drivers/scsi/Kconfig10
-rw-r--r--drivers/scsi/aacraid/aacraid.h2
-rw-r--r--drivers/scsi/csiostor/csio_hw.c71
-rw-r--r--drivers/scsi/csiostor/csio_hw.h1
-rw-r--r--drivers/scsi/csiostor/csio_mb.c6
-rw-r--r--drivers/scsi/hosts.c24
-rw-r--r--drivers/scsi/hpsa.c2
-rw-r--r--drivers/scsi/lpfc/lpfc.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c8
-rw-r--r--drivers/scsi/qedi/qedi.h7
-rw-r--r--drivers/scsi/qedi/qedi_main.c28
-rw-r--r--drivers/scsi/scsi_lib.c21
-rw-r--r--drivers/target/iscsi/cxgbit/cxgbit_ddp.c8
-rw-r--r--drivers/target/iscsi/iscsi_target.c9
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c149
-rw-r--r--drivers/target/iscsi/iscsi_target_login.h2
-rw-r--r--fs/afs/proc.c15
-rw-r--r--fs/btrfs/ctree.h12
-rw-r--r--fs/btrfs/disk-io.c1
-rw-r--r--fs/btrfs/extent-tree.c17
-rw-r--r--fs/btrfs/inode.c117
-rw-r--r--fs/btrfs/ioctl.c35
-rw-r--r--fs/btrfs/qgroup.c5
-rw-r--r--fs/btrfs/tree-log.c48
-rw-r--r--fs/btrfs/tree-log.h10
-rw-r--r--fs/btrfs/volumes.c7
-rw-r--r--fs/ceph/super.c16
-rw-r--r--fs/cifs/cifs_unicode.c3
-rw-r--r--fs/cifs/connect.c2
-rw-r--r--fs/cifs/inode.c2
-rw-r--r--fs/cifs/smb2misc.c14
-rw-r--r--fs/cifs/smb2ops.c35
-rw-r--r--fs/cifs/smb2pdu.c3
-rw-r--r--fs/nilfs2/alloc.c11
-rw-r--r--fs/nilfs2/alloc.h11
-rw-r--r--fs/nilfs2/bmap.c11
-rw-r--r--fs/nilfs2/bmap.h11
-rw-r--r--fs/nilfs2/btnode.c11
-rw-r--r--fs/nilfs2/btnode.h11
-rw-r--r--fs/nilfs2/btree.c11
-rw-r--r--fs/nilfs2/btree.h11
-rw-r--r--fs/nilfs2/cpfile.c11
-rw-r--r--fs/nilfs2/cpfile.h11
-rw-r--r--fs/nilfs2/dat.c11
-rw-r--r--fs/nilfs2/dat.h11
-rw-r--r--fs/nilfs2/dir.c11
-rw-r--r--fs/nilfs2/direct.c11
-rw-r--r--fs/nilfs2/direct.h11
-rw-r--r--fs/nilfs2/file.c11
-rw-r--r--fs/nilfs2/gcinode.c11
-rw-r--r--fs/nilfs2/ifile.c11
-rw-r--r--fs/nilfs2/ifile.h11
-rw-r--r--fs/nilfs2/inode.c11
-rw-r--r--fs/nilfs2/ioctl.c11
-rw-r--r--fs/nilfs2/mdt.c11
-rw-r--r--fs/nilfs2/mdt.h11
-rw-r--r--fs/nilfs2/namei.c11
-rw-r--r--fs/nilfs2/nilfs.h11
-rw-r--r--fs/nilfs2/page.c11
-rw-r--r--fs/nilfs2/page.h11
-rw-r--r--fs/nilfs2/recovery.c11
-rw-r--r--fs/nilfs2/segbuf.c11
-rw-r--r--fs/nilfs2/segbuf.h11
-rw-r--r--fs/nilfs2/segment.c11
-rw-r--r--fs/nilfs2/segment.h11
-rw-r--r--fs/nilfs2/sufile.c11
-rw-r--r--fs/nilfs2/sufile.h11
-rw-r--r--fs/nilfs2/super.c11
-rw-r--r--fs/nilfs2/sysfs.c11
-rw-r--r--fs/nilfs2/sysfs.h11
-rw-r--r--fs/nilfs2/the_nilfs.c11
-rw-r--r--fs/nilfs2/the_nilfs.h11
-rw-r--r--fs/notify/fsnotify.c13
-rw-r--r--include/linux/blk-cgroup.h45
-rw-r--r--include/linux/hid.h1
-rw-r--r--include/linux/timekeeping.h4
-rw-r--r--include/linux/tracepoint.h8
-rw-r--r--include/net/netfilter/nf_conntrack_timeout.h2
-rw-r--r--include/net/tls.h19
-rw-r--r--include/uapi/linux/keyctl.h2
-rw-r--r--ipc/shm.c1
-rw-r--r--kernel/cpu.c11
-rw-r--r--kernel/fork.c3
-rw-r--r--kernel/printk/printk_safe.c4
-rw-r--r--kernel/time/clocksource.c40
-rw-r--r--lib/Kconfig.debug4
-rw-r--r--mm/backing-dev.c5
-rw-r--r--mm/huge_memory.c4
-rw-r--r--mm/kmemleak.c9
-rw-r--r--mm/memcontrol.c2
-rw-r--r--mm/memory_hotplug.c3
-rw-r--r--mm/oom_kill.c14
-rw-r--r--mm/page_alloc.c4
-rw-r--r--mm/util.c11
-rw-r--r--net/core/neighbour.c13
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/ipv4/ip_gre.c5
-rw-r--r--net/ipv4/netfilter/Kconfig8
-rw-r--r--net/ipv4/tcp_input.c4
-rw-r--r--net/ipv6/route.c42
-rw-r--r--net/netfilter/Kconfig12
-rw-r--r--net/netfilter/nf_conntrack_proto.c26
-rw-r--r--net/netfilter/nf_conntrack_proto_dccp.c19
-rw-r--r--net/netfilter/nf_conntrack_proto_generic.c8
-rw-r--r--net/netfilter/nf_conntrack_proto_gre.c8
-rw-r--r--net/netfilter/nf_conntrack_proto_icmp.c8
-rw-r--r--net/netfilter/nf_conntrack_proto_icmpv6.c8
-rw-r--r--net/netfilter/nf_conntrack_proto_sctp.c21
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c19
-rw-r--r--net/netfilter/nf_conntrack_proto_udp.c21
-rw-r--r--net/netfilter/nf_tables_api.c1
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c6
-rw-r--r--net/netfilter/nfnetlink_queue.c1
-rw-r--r--net/netfilter/nft_ct.c59
-rw-r--r--net/netfilter/xt_CHECKSUM.c22
-rw-r--r--net/netfilter/xt_cluster.c14
-rw-r--r--net/netfilter/xt_hashlimit.c18
-rw-r--r--net/rds/bind.c5
-rw-r--r--net/sched/cls_api.c2
-rw-r--r--net/tipc/netlink_compat.c5
-rw-r--r--net/tls/tls_device.c6
-rw-r--r--net/tls/tls_device_fallback.c2
-rw-r--r--net/tls/tls_main.c22
-rw-r--r--net/tls/tls_sw.c13
-rwxr-xr-xscripts/checkpatch.pl3
-rwxr-xr-xscripts/depmod.sh5
-rw-r--r--scripts/kconfig/Makefile1
-rw-r--r--scripts/kconfig/check-pkgconfig.sh8
-rwxr-xr-xscripts/kconfig/gconf-cfg.sh7
-rwxr-xr-xscripts/kconfig/mconf-cfg.sh25
-rw-r--r--scripts/kconfig/mconf.c1
-rw-r--r--scripts/kconfig/nconf-cfg.sh25
-rwxr-xr-xscripts/kconfig/qconf-cfg.sh7
-rwxr-xr-xscripts/recordmcount.pl3
-rwxr-xr-xscripts/setlocalversion2
-rw-r--r--security/apparmor/secid.c1
-rw-r--r--security/keys/dh.c2
-rw-r--r--sound/core/rawmidi.c4
-rw-r--r--sound/hda/ext/hdac_ext_stream.c22
-rw-r--r--sound/pci/hda/hda_codec.c3
-rwxr-xr-xtools/kvm/kvm_stat/kvm_stat59
-rw-r--r--tools/vm/page-types.c6
-rw-r--r--tools/vm/slabinfo.c4
-rw-r--r--virt/kvm/arm/mmu.c21
-rw-r--r--virt/kvm/arm/trace.h15
320 files changed, 2917 insertions, 1806 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 9871e649ffef..64a3bf54b974 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3523,6 +3523,12 @@
3523 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes 3523 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
3524 See Documentation/blockdev/ramdisk.txt. 3524 See Documentation/blockdev/ramdisk.txt.
3525 3525
3526 random.trust_cpu={on,off}
3527 [KNL] Enable or disable trusting the use of the
3528 CPU's random number generator (if available) to
3529 fully seed the kernel's CRNG. Default is controlled
3530 by CONFIG_RANDOM_TRUST_CPU.
3531
3526 ras=option[,option,...] [KNL] RAS-specific options 3532 ras=option[,option,...] [KNL] RAS-specific options
3527 3533
3528 cec_disable [X86] 3534 cec_disable [X86]
diff --git a/Documentation/devicetree/bindings/i2c/i2c-imx-lpi2c.txt b/Documentation/devicetree/bindings/i2c/i2c-imx-lpi2c.txt
index 00e4365d7206..091c8dfd3229 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-imx-lpi2c.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-imx-lpi2c.txt
@@ -3,7 +3,6 @@
3Required properties: 3Required properties:
4- compatible : 4- compatible :
5 - "fsl,imx7ulp-lpi2c" for LPI2C compatible with the one integrated on i.MX7ULP soc 5 - "fsl,imx7ulp-lpi2c" for LPI2C compatible with the one integrated on i.MX7ULP soc
6 - "fsl,imx8dv-lpi2c" for LPI2C compatible with the one integrated on i.MX8DV soc
7- reg : address and length of the lpi2c master registers 6- reg : address and length of the lpi2c master registers
8- interrupts : lpi2c interrupt 7- interrupts : lpi2c interrupt
9- clocks : lpi2c clock specifier 8- clocks : lpi2c clock specifier
@@ -11,7 +10,7 @@ Required properties:
11Examples: 10Examples:
12 11
13lpi2c7: lpi2c7@40a50000 { 12lpi2c7: lpi2c7@40a50000 {
14 compatible = "fsl,imx8dv-lpi2c"; 13 compatible = "fsl,imx7ulp-lpi2c";
15 reg = <0x40A50000 0x10000>; 14 reg = <0x40A50000 0x10000>;
16 interrupt-parent = <&intc>; 15 interrupt-parent = <&intc>;
17 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; 16 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst
index 61f918b10a0c..d1bf143b446f 100644
--- a/Documentation/process/changes.rst
+++ b/Documentation/process/changes.rst
@@ -86,7 +86,7 @@ pkg-config
86 86
87The build system, as of 4.18, requires pkg-config to check for installed 87The build system, as of 4.18, requires pkg-config to check for installed
88kconfig tools and to determine flags settings for use in 88kconfig tools and to determine flags settings for use in
89'make {menu,n,g,x}config'. Previously pkg-config was being used but not 89'make {g,x}config'. Previously pkg-config was being used but not
90verified or documented. 90verified or documented.
91 91
92Flex 92Flex
diff --git a/Documentation/scsi/scsi-parameters.txt b/Documentation/scsi/scsi-parameters.txt
index 25a4b4cf04a6..92999d4e0cb8 100644
--- a/Documentation/scsi/scsi-parameters.txt
+++ b/Documentation/scsi/scsi-parameters.txt
@@ -97,6 +97,11 @@ parameters may be changed at runtime by the command
97 allowing boot to proceed. none ignores them, expecting 97 allowing boot to proceed. none ignores them, expecting
98 user space to do the scan. 98 user space to do the scan.
99 99
100 scsi_mod.use_blk_mq=
101 [SCSI] use blk-mq I/O path by default
102 See SCSI_MQ_DEFAULT in drivers/scsi/Kconfig.
103 Format: <y/n>
104
100 sim710= [SCSI,HW] 105 sim710= [SCSI,HW]
101 See header of drivers/scsi/sim710.c. 106 See header of drivers/scsi/sim710.c.
102 107
diff --git a/MAINTAINERS b/MAINTAINERS
index 9ad052aeac39..d870cb57c887 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2311,6 +2311,7 @@ F: drivers/clocksource/cadence_ttc_timer.c
2311F: drivers/i2c/busses/i2c-cadence.c 2311F: drivers/i2c/busses/i2c-cadence.c
2312F: drivers/mmc/host/sdhci-of-arasan.c 2312F: drivers/mmc/host/sdhci-of-arasan.c
2313F: drivers/edac/synopsys_edac.c 2313F: drivers/edac/synopsys_edac.c
2314F: drivers/i2c/busses/i2c-xiic.c
2314 2315
2315ARM64 PORT (AARCH64 ARCHITECTURE) 2316ARM64 PORT (AARCH64 ARCHITECTURE)
2316M: Catalin Marinas <catalin.marinas@arm.com> 2317M: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/Makefile b/Makefile
index 19948e556941..4d5c883a98e5 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
2VERSION = 4 2VERSION = 4
3PATCHLEVEL = 19 3PATCHLEVEL = 19
4SUBLEVEL = 0 4SUBLEVEL = 0
5EXTRAVERSION = -rc2 5EXTRAVERSION = -rc3
6NAME = Merciless Moray 6NAME = Merciless Moray
7 7
8# *DOCUMENTATION* 8# *DOCUMENTATION*
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 6d5eb8267e42..b4441b0764d7 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -9,6 +9,7 @@
9config ARC 9config ARC
10 def_bool y 10 def_bool y
11 select ARC_TIMERS 11 select ARC_TIMERS
12 select ARCH_HAS_PTE_SPECIAL
12 select ARCH_HAS_SYNC_DMA_FOR_CPU 13 select ARCH_HAS_SYNC_DMA_FOR_CPU
13 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 14 select ARCH_HAS_SYNC_DMA_FOR_DEVICE
14 select ARCH_HAS_SG_CHAIN 15 select ARCH_HAS_SG_CHAIN
@@ -28,8 +29,12 @@ config ARC
28 select GENERIC_SMP_IDLE_THREAD 29 select GENERIC_SMP_IDLE_THREAD
29 select HAVE_ARCH_KGDB 30 select HAVE_ARCH_KGDB
30 select HAVE_ARCH_TRACEHOOK 31 select HAVE_ARCH_TRACEHOOK
32 select HAVE_DEBUG_STACKOVERFLOW
31 select HAVE_FUTEX_CMPXCHG if FUTEX 33 select HAVE_FUTEX_CMPXCHG if FUTEX
34 select HAVE_GENERIC_DMA_COHERENT
32 select HAVE_IOREMAP_PROT 35 select HAVE_IOREMAP_PROT
36 select HAVE_KERNEL_GZIP
37 select HAVE_KERNEL_LZMA
33 select HAVE_KPROBES 38 select HAVE_KPROBES
34 select HAVE_KRETPROBES 39 select HAVE_KRETPROBES
35 select HAVE_MEMBLOCK 40 select HAVE_MEMBLOCK
@@ -44,11 +49,6 @@ config ARC
44 select OF_EARLY_FLATTREE 49 select OF_EARLY_FLATTREE
45 select OF_RESERVED_MEM 50 select OF_RESERVED_MEM
46 select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING 51 select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING
47 select HAVE_DEBUG_STACKOVERFLOW
48 select HAVE_GENERIC_DMA_COHERENT
49 select HAVE_KERNEL_GZIP
50 select HAVE_KERNEL_LZMA
51 select ARCH_HAS_PTE_SPECIAL
52 52
53config ARCH_HAS_CACHE_LINE_SIZE 53config ARCH_HAS_CACHE_LINE_SIZE
54 def_bool y 54 def_bool y
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index fb026196aaab..99cce77ab98f 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -43,10 +43,7 @@ ifdef CONFIG_ARC_CURR_IN_REG
43LINUXINCLUDE += -include ${src}/arch/arc/include/asm/current.h 43LINUXINCLUDE += -include ${src}/arch/arc/include/asm/current.h
44endif 44endif
45 45
46upto_gcc44 := $(call cc-ifversion, -le, 0404, y) 46cflags-y += -fsection-anchors
47atleast_gcc44 := $(call cc-ifversion, -ge, 0404, y)
48
49cflags-$(atleast_gcc44) += -fsection-anchors
50 47
51cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock 48cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
52cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape 49cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
@@ -82,11 +79,6 @@ cflags-$(disable_small_data) += -mno-sdata -fcall-used-gp
82cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mbig-endian 79cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mbig-endian
83ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB 80ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
84 81
85# STAR 9000518362: (fixed with binutils shipping with gcc 4.8)
86# arc-linux-uclibc-ld (buildroot) or arceb-elf32-ld (EZChip) don't accept
87# --build-id w/o "-marclinux". Default arc-elf32-ld is OK
88ldflags-$(upto_gcc44) += -marclinux
89
90LIBGCC := $(shell $(CC) $(cflags-y) --print-libgcc-file-name) 82LIBGCC := $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
91 83
92# Modules with short calls might break for calls into builtin-kernel 84# Modules with short calls might break for calls into builtin-kernel
diff --git a/arch/arc/boot/dts/axc003.dtsi b/arch/arc/boot/dts/axc003.dtsi
index dc91c663bcc0..d75d65ddf8e3 100644
--- a/arch/arc/boot/dts/axc003.dtsi
+++ b/arch/arc/boot/dts/axc003.dtsi
@@ -94,6 +94,32 @@
94 }; 94 };
95 95
96 /* 96 /*
97 * Mark DMA peripherals connected via IOC port as dma-coherent. We do
98 * it via overlay because peripherals defined in axs10x_mb.dtsi are
99 * used for both AXS101 and AXS103 boards and only AXS103 has IOC (so
100 * only AXS103 board has HW-coherent DMA peripherals)
101 * We don't need to mark pgu@17000 as dma-coherent because it uses
102 * external DMA buffer located outside of IOC aperture.
103 */
104 axs10x_mb {
105 ethernet@0x18000 {
106 dma-coherent;
107 };
108
109 ehci@0x40000 {
110 dma-coherent;
111 };
112
113 ohci@0x60000 {
114 dma-coherent;
115 };
116
117 mmc@0x15000 {
118 dma-coherent;
119 };
120 };
121
122 /*
97 * The DW APB ICTL intc on MB is connected to CPU intc via a 123 * The DW APB ICTL intc on MB is connected to CPU intc via a
98 * DT "invisible" DW APB GPIO block, configured to simply pass thru 124 * DT "invisible" DW APB GPIO block, configured to simply pass thru
99 * interrupts - setup accordinly in platform init (plat-axs10x/ax10x.c) 125 * interrupts - setup accordinly in platform init (plat-axs10x/ax10x.c)
diff --git a/arch/arc/boot/dts/axc003_idu.dtsi b/arch/arc/boot/dts/axc003_idu.dtsi
index 69ff4895f2ba..a05bb737ea63 100644
--- a/arch/arc/boot/dts/axc003_idu.dtsi
+++ b/arch/arc/boot/dts/axc003_idu.dtsi
@@ -101,6 +101,32 @@
101 }; 101 };
102 102
103 /* 103 /*
104 * Mark DMA peripherals connected via IOC port as dma-coherent. We do
105 * it via overlay because peripherals defined in axs10x_mb.dtsi are
106 * used for both AXS101 and AXS103 boards and only AXS103 has IOC (so
107 * only AXS103 board has HW-coherent DMA peripherals)
108 * We don't need to mark pgu@17000 as dma-coherent because it uses
109 * external DMA buffer located outside of IOC aperture.
110 */
111 axs10x_mb {
112 ethernet@0x18000 {
113 dma-coherent;
114 };
115
116 ehci@0x40000 {
117 dma-coherent;
118 };
119
120 ohci@0x60000 {
121 dma-coherent;
122 };
123
124 mmc@0x15000 {
125 dma-coherent;
126 };
127 };
128
129 /*
104 * This INTC is actually connected to DW APB GPIO 130 * This INTC is actually connected to DW APB GPIO
105 * which acts as a wire between MB INTC and CPU INTC. 131 * which acts as a wire between MB INTC and CPU INTC.
106 * GPIO INTC is configured in platform init code 132 * GPIO INTC is configured in platform init code
diff --git a/arch/arc/boot/dts/axs10x_mb.dtsi b/arch/arc/boot/dts/axs10x_mb.dtsi
index 47b74fbc403c..37bafd44e36d 100644
--- a/arch/arc/boot/dts/axs10x_mb.dtsi
+++ b/arch/arc/boot/dts/axs10x_mb.dtsi
@@ -9,6 +9,10 @@
9 */ 9 */
10 10
11/ { 11/ {
12 aliases {
13 ethernet = &gmac;
14 };
15
12 axs10x_mb { 16 axs10x_mb {
13 compatible = "simple-bus"; 17 compatible = "simple-bus";
14 #address-cells = <1>; 18 #address-cells = <1>;
@@ -68,7 +72,7 @@
68 }; 72 };
69 }; 73 };
70 74
71 ethernet@0x18000 { 75 gmac: ethernet@0x18000 {
72 #interrupt-cells = <1>; 76 #interrupt-cells = <1>;
73 compatible = "snps,dwmac"; 77 compatible = "snps,dwmac";
74 reg = < 0x18000 0x2000 >; 78 reg = < 0x18000 0x2000 >;
@@ -81,6 +85,7 @@
81 max-speed = <100>; 85 max-speed = <100>;
82 resets = <&creg_rst 5>; 86 resets = <&creg_rst 5>;
83 reset-names = "stmmaceth"; 87 reset-names = "stmmaceth";
88 mac-address = [00 00 00 00 00 00]; /* Filled in by U-Boot */
84 }; 89 };
85 90
86 ehci@0x40000 { 91 ehci@0x40000 {
diff --git a/arch/arc/boot/dts/hsdk.dts b/arch/arc/boot/dts/hsdk.dts
index 006aa3de5348..ef149f59929a 100644
--- a/arch/arc/boot/dts/hsdk.dts
+++ b/arch/arc/boot/dts/hsdk.dts
@@ -25,6 +25,10 @@
25 bootargs = "earlycon=uart8250,mmio32,0xf0005000,115200n8 console=ttyS0,115200n8 debug print-fatal-signals=1"; 25 bootargs = "earlycon=uart8250,mmio32,0xf0005000,115200n8 console=ttyS0,115200n8 debug print-fatal-signals=1";
26 }; 26 };
27 27
28 aliases {
29 ethernet = &gmac;
30 };
31
28 cpus { 32 cpus {
29 #address-cells = <1>; 33 #address-cells = <1>;
30 #size-cells = <0>; 34 #size-cells = <0>;
@@ -163,7 +167,7 @@
163 #clock-cells = <0>; 167 #clock-cells = <0>;
164 }; 168 };
165 169
166 ethernet@8000 { 170 gmac: ethernet@8000 {
167 #interrupt-cells = <1>; 171 #interrupt-cells = <1>;
168 compatible = "snps,dwmac"; 172 compatible = "snps,dwmac";
169 reg = <0x8000 0x2000>; 173 reg = <0x8000 0x2000>;
@@ -176,6 +180,8 @@
176 phy-handle = <&phy0>; 180 phy-handle = <&phy0>;
177 resets = <&cgu_rst HSDK_ETH_RESET>; 181 resets = <&cgu_rst HSDK_ETH_RESET>;
178 reset-names = "stmmaceth"; 182 reset-names = "stmmaceth";
183 mac-address = [00 00 00 00 00 00]; /* Filled in by U-Boot */
184 dma-coherent;
179 185
180 mdio { 186 mdio {
181 #address-cells = <1>; 187 #address-cells = <1>;
@@ -194,12 +200,14 @@
194 compatible = "snps,hsdk-v1.0-ohci", "generic-ohci"; 200 compatible = "snps,hsdk-v1.0-ohci", "generic-ohci";
195 reg = <0x60000 0x100>; 201 reg = <0x60000 0x100>;
196 interrupts = <15>; 202 interrupts = <15>;
203 dma-coherent;
197 }; 204 };
198 205
199 ehci@40000 { 206 ehci@40000 {
200 compatible = "snps,hsdk-v1.0-ehci", "generic-ehci"; 207 compatible = "snps,hsdk-v1.0-ehci", "generic-ehci";
201 reg = <0x40000 0x100>; 208 reg = <0x40000 0x100>;
202 interrupts = <15>; 209 interrupts = <15>;
210 dma-coherent;
203 }; 211 };
204 212
205 mmc@a000 { 213 mmc@a000 {
@@ -212,6 +220,7 @@
212 clock-names = "biu", "ciu"; 220 clock-names = "biu", "ciu";
213 interrupts = <12>; 221 interrupts = <12>;
214 bus-width = <4>; 222 bus-width = <4>;
223 dma-coherent;
215 }; 224 };
216 }; 225 };
217 226
diff --git a/arch/arc/configs/axs101_defconfig b/arch/arc/configs/axs101_defconfig
index a635ea972304..41bc08be6a3b 100644
--- a/arch/arc/configs/axs101_defconfig
+++ b/arch/arc/configs/axs101_defconfig
@@ -1,5 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
5# CONFIG_CROSS_MEMORY_ATTACH is not set 3# CONFIG_CROSS_MEMORY_ATTACH is not set
@@ -63,7 +61,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
63CONFIG_MOUSE_SERIAL=y 61CONFIG_MOUSE_SERIAL=y
64CONFIG_MOUSE_SYNAPTICS_USB=y 62CONFIG_MOUSE_SYNAPTICS_USB=y
65# CONFIG_LEGACY_PTYS is not set 63# CONFIG_LEGACY_PTYS is not set
66# CONFIG_DEVKMEM is not set
67CONFIG_SERIAL_8250=y 64CONFIG_SERIAL_8250=y
68CONFIG_SERIAL_8250_CONSOLE=y 65CONFIG_SERIAL_8250_CONSOLE=y
69CONFIG_SERIAL_8250_DW=y 66CONFIG_SERIAL_8250_DW=y
diff --git a/arch/arc/configs/axs103_defconfig b/arch/arc/configs/axs103_defconfig
index aa507e423075..1e1c4a8011b5 100644
--- a/arch/arc/configs/axs103_defconfig
+++ b/arch/arc/configs/axs103_defconfig
@@ -1,5 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
5# CONFIG_CROSS_MEMORY_ATTACH is not set 3# CONFIG_CROSS_MEMORY_ATTACH is not set
@@ -64,7 +62,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
64CONFIG_MOUSE_SERIAL=y 62CONFIG_MOUSE_SERIAL=y
65CONFIG_MOUSE_SYNAPTICS_USB=y 63CONFIG_MOUSE_SYNAPTICS_USB=y
66# CONFIG_LEGACY_PTYS is not set 64# CONFIG_LEGACY_PTYS is not set
67# CONFIG_DEVKMEM is not set
68CONFIG_SERIAL_8250=y 65CONFIG_SERIAL_8250=y
69CONFIG_SERIAL_8250_CONSOLE=y 66CONFIG_SERIAL_8250_CONSOLE=y
70CONFIG_SERIAL_8250_DW=y 67CONFIG_SERIAL_8250_DW=y
diff --git a/arch/arc/configs/axs103_smp_defconfig b/arch/arc/configs/axs103_smp_defconfig
index eba07f468654..6b0c0cfd5c30 100644
--- a/arch/arc/configs/axs103_smp_defconfig
+++ b/arch/arc/configs/axs103_smp_defconfig
@@ -1,5 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
5# CONFIG_CROSS_MEMORY_ATTACH is not set 3# CONFIG_CROSS_MEMORY_ATTACH is not set
@@ -65,7 +63,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
65CONFIG_MOUSE_SERIAL=y 63CONFIG_MOUSE_SERIAL=y
66CONFIG_MOUSE_SYNAPTICS_USB=y 64CONFIG_MOUSE_SYNAPTICS_USB=y
67# CONFIG_LEGACY_PTYS is not set 65# CONFIG_LEGACY_PTYS is not set
68# CONFIG_DEVKMEM is not set
69CONFIG_SERIAL_8250=y 66CONFIG_SERIAL_8250=y
70CONFIG_SERIAL_8250_CONSOLE=y 67CONFIG_SERIAL_8250_CONSOLE=y
71CONFIG_SERIAL_8250_DW=y 68CONFIG_SERIAL_8250_DW=y
diff --git a/arch/arc/configs/haps_hs_defconfig b/arch/arc/configs/haps_hs_defconfig
index 098b19fbaa51..240dd2cd5148 100644
--- a/arch/arc/configs/haps_hs_defconfig
+++ b/arch/arc/configs/haps_hs_defconfig
@@ -1,4 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -57,7 +56,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
57# CONFIG_SERIO_SERPORT is not set 56# CONFIG_SERIO_SERPORT is not set
58CONFIG_SERIO_ARC_PS2=y 57CONFIG_SERIO_ARC_PS2=y
59# CONFIG_LEGACY_PTYS is not set 58# CONFIG_LEGACY_PTYS is not set
60# CONFIG_DEVKMEM is not set
61CONFIG_SERIAL_8250=y 59CONFIG_SERIAL_8250=y
62CONFIG_SERIAL_8250_CONSOLE=y 60CONFIG_SERIAL_8250_CONSOLE=y
63CONFIG_SERIAL_8250_NR_UARTS=1 61CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/haps_hs_smp_defconfig b/arch/arc/configs/haps_hs_smp_defconfig
index 0104c404d897..14ae7e5acc7c 100644
--- a/arch/arc/configs/haps_hs_smp_defconfig
+++ b/arch/arc/configs/haps_hs_smp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
@@ -60,7 +59,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
60# CONFIG_SERIO_SERPORT is not set 59# CONFIG_SERIO_SERPORT is not set
61CONFIG_SERIO_ARC_PS2=y 60CONFIG_SERIO_ARC_PS2=y
62# CONFIG_LEGACY_PTYS is not set 61# CONFIG_LEGACY_PTYS is not set
63# CONFIG_DEVKMEM is not set
64CONFIG_SERIAL_8250=y 62CONFIG_SERIAL_8250=y
65CONFIG_SERIAL_8250_CONSOLE=y 63CONFIG_SERIAL_8250_CONSOLE=y
66CONFIG_SERIAL_8250_NR_UARTS=1 64CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
index 6491be0ddbc9..1dec2b4bc5e6 100644
--- a/arch/arc/configs/hsdk_defconfig
+++ b/arch/arc/configs/hsdk_defconfig
@@ -1,4 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
3# CONFIG_CROSS_MEMORY_ATTACH is not set 2# CONFIG_CROSS_MEMORY_ATTACH is not set
4CONFIG_NO_HZ_IDLE=y 3CONFIG_NO_HZ_IDLE=y
diff --git a/arch/arc/configs/nps_defconfig b/arch/arc/configs/nps_defconfig
index 7c9c706ae7f6..31ba224bbfb4 100644
--- a/arch/arc/configs/nps_defconfig
+++ b/arch/arc/configs/nps_defconfig
@@ -59,7 +59,6 @@ CONFIG_NETCONSOLE=y
59# CONFIG_INPUT_MOUSE is not set 59# CONFIG_INPUT_MOUSE is not set
60# CONFIG_SERIO is not set 60# CONFIG_SERIO is not set
61# CONFIG_LEGACY_PTYS is not set 61# CONFIG_LEGACY_PTYS is not set
62# CONFIG_DEVKMEM is not set
63CONFIG_SERIAL_8250=y 62CONFIG_SERIAL_8250=y
64CONFIG_SERIAL_8250_CONSOLE=y 63CONFIG_SERIAL_8250_CONSOLE=y
65CONFIG_SERIAL_8250_NR_UARTS=1 64CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig
index 99e05cf63fca..8e0b8b134cd9 100644
--- a/arch/arc/configs/nsim_700_defconfig
+++ b/arch/arc/configs/nsim_700_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
5CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
@@ -44,7 +43,6 @@ CONFIG_LXT_PHY=y
44# CONFIG_INPUT_MOUSE is not set 43# CONFIG_INPUT_MOUSE is not set
45# CONFIG_SERIO is not set 44# CONFIG_SERIO is not set
46# CONFIG_LEGACY_PTYS is not set 45# CONFIG_LEGACY_PTYS is not set
47# CONFIG_DEVKMEM is not set
48CONFIG_SERIAL_ARC=y 46CONFIG_SERIAL_ARC=y
49CONFIG_SERIAL_ARC_CONSOLE=y 47CONFIG_SERIAL_ARC_CONSOLE=y
50# CONFIG_HW_RANDOM is not set 48# CONFIG_HW_RANDOM is not set
diff --git a/arch/arc/configs/nsim_hs_defconfig b/arch/arc/configs/nsim_hs_defconfig
index 0dc4f9b737e7..739b90e5e893 100644
--- a/arch/arc/configs/nsim_hs_defconfig
+++ b/arch/arc/configs/nsim_hs_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
5CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
@@ -45,7 +44,6 @@ CONFIG_DEVTMPFS=y
45# CONFIG_INPUT_MOUSE is not set 44# CONFIG_INPUT_MOUSE is not set
46# CONFIG_SERIO is not set 45# CONFIG_SERIO is not set
47# CONFIG_LEGACY_PTYS is not set 46# CONFIG_LEGACY_PTYS is not set
48# CONFIG_DEVKMEM is not set
49CONFIG_SERIAL_ARC=y 47CONFIG_SERIAL_ARC=y
50CONFIG_SERIAL_ARC_CONSOLE=y 48CONFIG_SERIAL_ARC_CONSOLE=y
51# CONFIG_HW_RANDOM is not set 49# CONFIG_HW_RANDOM is not set
diff --git a/arch/arc/configs/nsim_hs_smp_defconfig b/arch/arc/configs/nsim_hs_smp_defconfig
index be3c30a15e54..b5895bdf3a93 100644
--- a/arch/arc/configs/nsim_hs_smp_defconfig
+++ b/arch/arc/configs/nsim_hs_smp_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4# CONFIG_CROSS_MEMORY_ATTACH is not set 3# CONFIG_CROSS_MEMORY_ATTACH is not set
5CONFIG_HIGH_RES_TIMERS=y 4CONFIG_HIGH_RES_TIMERS=y
@@ -44,7 +43,6 @@ CONFIG_DEVTMPFS=y
44# CONFIG_INPUT_MOUSE is not set 43# CONFIG_INPUT_MOUSE is not set
45# CONFIG_SERIO is not set 44# CONFIG_SERIO is not set
46# CONFIG_LEGACY_PTYS is not set 45# CONFIG_LEGACY_PTYS is not set
47# CONFIG_DEVKMEM is not set
48CONFIG_SERIAL_ARC=y 46CONFIG_SERIAL_ARC=y
49CONFIG_SERIAL_ARC_CONSOLE=y 47CONFIG_SERIAL_ARC_CONSOLE=y
50# CONFIG_HW_RANDOM is not set 48# CONFIG_HW_RANDOM is not set
diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig
index 3a74b9b21772..f14eeff7d308 100644
--- a/arch/arc/configs/nsimosci_defconfig
+++ b/arch/arc/configs/nsimosci_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
5# CONFIG_CROSS_MEMORY_ATTACH is not set 4# CONFIG_CROSS_MEMORY_ATTACH is not set
@@ -48,7 +47,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
48# CONFIG_SERIO_SERPORT is not set 47# CONFIG_SERIO_SERPORT is not set
49CONFIG_SERIO_ARC_PS2=y 48CONFIG_SERIO_ARC_PS2=y
50# CONFIG_LEGACY_PTYS is not set 49# CONFIG_LEGACY_PTYS is not set
51# CONFIG_DEVKMEM is not set
52CONFIG_SERIAL_8250=y 50CONFIG_SERIAL_8250=y
53CONFIG_SERIAL_8250_CONSOLE=y 51CONFIG_SERIAL_8250_CONSOLE=y
54CONFIG_SERIAL_8250_NR_UARTS=1 52CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig
index ea2834b4dc1d..025298a48305 100644
--- a/arch/arc/configs/nsimosci_hs_defconfig
+++ b/arch/arc/configs/nsimosci_hs_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
5# CONFIG_CROSS_MEMORY_ATTACH is not set 4# CONFIG_CROSS_MEMORY_ATTACH is not set
@@ -47,7 +46,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
47# CONFIG_SERIO_SERPORT is not set 46# CONFIG_SERIO_SERPORT is not set
48CONFIG_SERIO_ARC_PS2=y 47CONFIG_SERIO_ARC_PS2=y
49# CONFIG_LEGACY_PTYS is not set 48# CONFIG_LEGACY_PTYS is not set
50# CONFIG_DEVKMEM is not set
51CONFIG_SERIAL_8250=y 49CONFIG_SERIAL_8250=y
52CONFIG_SERIAL_8250_CONSOLE=y 50CONFIG_SERIAL_8250_CONSOLE=y
53CONFIG_SERIAL_8250_NR_UARTS=1 51CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig
index 80a5a1b4924b..df7b77b13b82 100644
--- a/arch/arc/configs/nsimosci_hs_smp_defconfig
+++ b/arch/arc/configs/nsimosci_hs_smp_defconfig
@@ -1,4 +1,3 @@
1CONFIG_DEFAULT_HOSTNAME="ARCLinux"
2# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
4# CONFIG_CROSS_MEMORY_ATTACH is not set 3# CONFIG_CROSS_MEMORY_ATTACH is not set
@@ -58,7 +57,6 @@ CONFIG_MOUSE_PS2_TOUCHKIT=y
58# CONFIG_SERIO_SERPORT is not set 57# CONFIG_SERIO_SERPORT is not set
59CONFIG_SERIO_ARC_PS2=y 58CONFIG_SERIO_ARC_PS2=y
60# CONFIG_LEGACY_PTYS is not set 59# CONFIG_LEGACY_PTYS is not set
61# CONFIG_DEVKMEM is not set
62CONFIG_SERIAL_8250=y 60CONFIG_SERIAL_8250=y
63CONFIG_SERIAL_8250_CONSOLE=y 61CONFIG_SERIAL_8250_CONSOLE=y
64CONFIG_SERIAL_8250_NR_UARTS=1 62CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig
index 2cc87f909747..a7f65313f84a 100644
--- a/arch/arc/configs/tb10x_defconfig
+++ b/arch/arc/configs/tb10x_defconfig
@@ -57,7 +57,6 @@ CONFIG_STMMAC_ETH=y
57# CONFIG_SERIO is not set 57# CONFIG_SERIO is not set
58# CONFIG_VT is not set 58# CONFIG_VT is not set
59# CONFIG_LEGACY_PTYS is not set 59# CONFIG_LEGACY_PTYS is not set
60# CONFIG_DEVKMEM is not set
61CONFIG_SERIAL_8250=y 60CONFIG_SERIAL_8250=y
62CONFIG_SERIAL_8250_CONSOLE=y 61CONFIG_SERIAL_8250_CONSOLE=y
63CONFIG_SERIAL_8250_NR_UARTS=1 62CONFIG_SERIAL_8250_NR_UARTS=1
diff --git a/arch/arc/configs/vdk_hs38_defconfig b/arch/arc/configs/vdk_hs38_defconfig
index f629493929ea..db47c3541f15 100644
--- a/arch/arc/configs/vdk_hs38_defconfig
+++ b/arch/arc/configs/vdk_hs38_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_CROSS_MEMORY_ATTACH is not set 2# CONFIG_CROSS_MEMORY_ATTACH is not set
4CONFIG_HIGH_RES_TIMERS=y 3CONFIG_HIGH_RES_TIMERS=y
5CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
@@ -53,7 +52,6 @@ CONFIG_NATIONAL_PHY=y
53CONFIG_MOUSE_PS2_TOUCHKIT=y 52CONFIG_MOUSE_PS2_TOUCHKIT=y
54CONFIG_SERIO_ARC_PS2=y 53CONFIG_SERIO_ARC_PS2=y
55# CONFIG_LEGACY_PTYS is not set 54# CONFIG_LEGACY_PTYS is not set
56# CONFIG_DEVKMEM is not set
57CONFIG_SERIAL_8250=y 55CONFIG_SERIAL_8250=y
58CONFIG_SERIAL_8250_CONSOLE=y 56CONFIG_SERIAL_8250_CONSOLE=y
59CONFIG_SERIAL_8250_DW=y 57CONFIG_SERIAL_8250_DW=y
diff --git a/arch/arc/configs/vdk_hs38_smp_defconfig b/arch/arc/configs/vdk_hs38_smp_defconfig
index 21f0ca26a05d..a8ac5e917d9a 100644
--- a/arch/arc/configs/vdk_hs38_smp_defconfig
+++ b/arch/arc/configs/vdk_hs38_smp_defconfig
@@ -1,5 +1,4 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_DEFAULT_HOSTNAME="ARCLinux"
3# CONFIG_CROSS_MEMORY_ATTACH is not set 2# CONFIG_CROSS_MEMORY_ATTACH is not set
4CONFIG_HIGH_RES_TIMERS=y 3CONFIG_HIGH_RES_TIMERS=y
5CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h
index 4e0072730241..158af079838d 100644
--- a/arch/arc/include/asm/atomic.h
+++ b/arch/arc/include/asm/atomic.h
@@ -84,7 +84,7 @@ static inline int atomic_fetch_##op(int i, atomic_t *v) \
84 "1: llock %[orig], [%[ctr]] \n" \ 84 "1: llock %[orig], [%[ctr]] \n" \
85 " " #asm_op " %[val], %[orig], %[i] \n" \ 85 " " #asm_op " %[val], %[orig], %[i] \n" \
86 " scond %[val], [%[ctr]] \n" \ 86 " scond %[val], [%[ctr]] \n" \
87 " \n" \ 87 " bnz 1b \n" \
88 : [val] "=&r" (val), \ 88 : [val] "=&r" (val), \
89 [orig] "=&r" (orig) \ 89 [orig] "=&r" (orig) \
90 : [ctr] "r" (&v->counter), \ 90 : [ctr] "r" (&v->counter), \
diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h
new file mode 100644
index 000000000000..c946c0a83e76
--- /dev/null
+++ b/arch/arc/include/asm/dma-mapping.h
@@ -0,0 +1,13 @@
1// SPDX-License-Identifier: GPL-2.0
2// (C) 2018 Synopsys, Inc. (www.synopsys.com)
3
4#ifndef ASM_ARC_DMA_MAPPING_H
5#define ASM_ARC_DMA_MAPPING_H
6
7#include <asm-generic/dma-mapping.h>
8
9void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
10 const struct iommu_ops *iommu, bool coherent);
11#define arch_setup_dma_ops arch_setup_dma_ops
12
13#endif
diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 783b20354f8b..e8d9fb452346 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -83,9 +83,6 @@ done:
83static void show_faulting_vma(unsigned long address, char *buf) 83static void show_faulting_vma(unsigned long address, char *buf)
84{ 84{
85 struct vm_area_struct *vma; 85 struct vm_area_struct *vma;
86 struct inode *inode;
87 unsigned long ino = 0;
88 dev_t dev = 0;
89 char *nm = buf; 86 char *nm = buf;
90 struct mm_struct *active_mm = current->active_mm; 87 struct mm_struct *active_mm = current->active_mm;
91 88
@@ -99,12 +96,10 @@ static void show_faulting_vma(unsigned long address, char *buf)
99 * if the container VMA is not found 96 * if the container VMA is not found
100 */ 97 */
101 if (vma && (vma->vm_start <= address)) { 98 if (vma && (vma->vm_start <= address)) {
102 struct file *file = vma->vm_file; 99 if (vma->vm_file) {
103 if (file) { 100 nm = file_path(vma->vm_file, buf, PAGE_SIZE - 1);
104 nm = file_path(file, buf, PAGE_SIZE - 1); 101 if (IS_ERR(nm))
105 inode = file_inode(vma->vm_file); 102 nm = "?";
106 dev = inode->i_sb->s_dev;
107 ino = inode->i_ino;
108 } 103 }
109 pr_info(" @off 0x%lx in [%s]\n" 104 pr_info(" @off 0x%lx in [%s]\n"
110 " VMA: 0x%08lx to 0x%08lx\n", 105 " VMA: 0x%08lx to 0x%08lx\n",
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index 25c631942500..f2701c13a66b 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -65,7 +65,7 @@ char *arc_cache_mumbojumbo(int c, char *buf, int len)
65 65
66 n += scnprintf(buf + n, len - n, "Peripherals\t: %#lx%s%s\n", 66 n += scnprintf(buf + n, len - n, "Peripherals\t: %#lx%s%s\n",
67 perip_base, 67 perip_base,
68 IS_AVAIL3(ioc_exists, ioc_enable, ", IO-Coherency ")); 68 IS_AVAIL3(ioc_exists, ioc_enable, ", IO-Coherency (per-device) "));
69 69
70 return buf; 70 return buf;
71} 71}
@@ -897,15 +897,6 @@ static void __dma_cache_wback_slc(phys_addr_t start, unsigned long sz)
897} 897}
898 898
899/* 899/*
900 * DMA ops for systems with IOC
901 * IOC hardware snoops all DMA traffic keeping the caches consistent with
902 * memory - eliding need for any explicit cache maintenance of DMA buffers
903 */
904static void __dma_cache_wback_inv_ioc(phys_addr_t start, unsigned long sz) {}
905static void __dma_cache_inv_ioc(phys_addr_t start, unsigned long sz) {}
906static void __dma_cache_wback_ioc(phys_addr_t start, unsigned long sz) {}
907
908/*
909 * Exported DMA API 900 * Exported DMA API
910 */ 901 */
911void dma_cache_wback_inv(phys_addr_t start, unsigned long sz) 902void dma_cache_wback_inv(phys_addr_t start, unsigned long sz)
@@ -1153,6 +1144,19 @@ noinline void __init arc_ioc_setup(void)
1153{ 1144{
1154 unsigned int ioc_base, mem_sz; 1145 unsigned int ioc_base, mem_sz;
1155 1146
1147 /*
1148 * As for today we don't support both IOC and ZONE_HIGHMEM enabled
1149 * simultaneously. This happens because as of today IOC aperture covers
1150 * only ZONE_NORMAL (low mem) and any dma transactions outside this
1151 * region won't be HW coherent.
1152 * If we want to use both IOC and ZONE_HIGHMEM we can use
1153 * bounce_buffer to handle dma transactions to HIGHMEM.
1154 * Also it is possible to modify dma_direct cache ops or increase IOC
1155 * aperture size if we are planning to use HIGHMEM without PAE.
1156 */
1157 if (IS_ENABLED(CONFIG_HIGHMEM))
1158 panic("IOC and HIGHMEM can't be used simultaneously");
1159
1156 /* Flush + invalidate + disable L1 dcache */ 1160 /* Flush + invalidate + disable L1 dcache */
1157 __dc_disable(); 1161 __dc_disable();
1158 1162
@@ -1264,11 +1268,7 @@ void __init arc_cache_init_master(void)
1264 if (is_isa_arcv2() && ioc_enable) 1268 if (is_isa_arcv2() && ioc_enable)
1265 arc_ioc_setup(); 1269 arc_ioc_setup();
1266 1270
1267 if (is_isa_arcv2() && ioc_enable) { 1271 if (is_isa_arcv2() && l2_line_sz && slc_enable) {
1268 __dma_cache_wback_inv = __dma_cache_wback_inv_ioc;
1269 __dma_cache_inv = __dma_cache_inv_ioc;
1270 __dma_cache_wback = __dma_cache_wback_ioc;
1271 } else if (is_isa_arcv2() && l2_line_sz && slc_enable) {
1272 __dma_cache_wback_inv = __dma_cache_wback_inv_slc; 1272 __dma_cache_wback_inv = __dma_cache_wback_inv_slc;
1273 __dma_cache_inv = __dma_cache_inv_slc; 1273 __dma_cache_inv = __dma_cache_inv_slc;
1274 __dma_cache_wback = __dma_cache_wback_slc; 1274 __dma_cache_wback = __dma_cache_wback_slc;
@@ -1277,6 +1277,12 @@ void __init arc_cache_init_master(void)
1277 __dma_cache_inv = __dma_cache_inv_l1; 1277 __dma_cache_inv = __dma_cache_inv_l1;
1278 __dma_cache_wback = __dma_cache_wback_l1; 1278 __dma_cache_wback = __dma_cache_wback_l1;
1279 } 1279 }
1280 /*
1281 * In case of IOC (say IOC+SLC case), pointers above could still be set
1282 * but end up not being relevant as the first function in chain is not
1283 * called at all for @dma_direct_ops
1284 * arch_sync_dma_for_cpu() -> dma_cache_*() -> __dma_cache_*()
1285 */
1280} 1286}
1281 1287
1282void __ref arc_cache_init(void) 1288void __ref arc_cache_init(void)
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index ec47e6079f5d..c75d5c3470e3 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -6,20 +6,17 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9/*
10 * DMA Coherent API Notes
11 *
12 * I/O is inherently non-coherent on ARC. So a coherent DMA buffer is
13 * implemented by accessing it using a kernel virtual address, with
14 * Cache bit off in the TLB entry.
15 *
16 * The default DMA address == Phy address which is 0x8000_0000 based.
17 */
18
19#include <linux/dma-noncoherent.h> 9#include <linux/dma-noncoherent.h>
20#include <asm/cache.h> 10#include <asm/cache.h>
21#include <asm/cacheflush.h> 11#include <asm/cacheflush.h>
22 12
13/*
14 * ARCH specific callbacks for generic noncoherent DMA ops (dma/noncoherent.c)
15 * - hardware IOC not available (or "dma-coherent" not set for device in DT)
16 * - But still handle both coherent and non-coherent requests from caller
17 *
18 * For DMA coherent hardware (IOC) generic code suffices
19 */
23void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, 20void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
24 gfp_t gfp, unsigned long attrs) 21 gfp_t gfp, unsigned long attrs)
25{ 22{
@@ -27,42 +24,29 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
27 struct page *page; 24 struct page *page;
28 phys_addr_t paddr; 25 phys_addr_t paddr;
29 void *kvaddr; 26 void *kvaddr;
30 int need_coh = 1, need_kvaddr = 0; 27 bool need_coh = !(attrs & DMA_ATTR_NON_CONSISTENT);
31
32 page = alloc_pages(gfp, order);
33 if (!page)
34 return NULL;
35 28
36 /* 29 /*
37 * IOC relies on all data (even coherent DMA data) being in cache 30 * __GFP_HIGHMEM flag is cleared by upper layer functions
38 * Thus allocate normal cached memory 31 * (in include/linux/dma-mapping.h) so we should never get a
39 * 32 * __GFP_HIGHMEM here.
40 * The gains with IOC are two pronged:
41 * -For streaming data, elides need for cache maintenance, saving
42 * cycles in flush code, and bus bandwidth as all the lines of a
43 * buffer need to be flushed out to memory
44 * -For coherent data, Read/Write to buffers terminate early in cache
45 * (vs. always going to memory - thus are faster)
46 */ 33 */
47 if ((is_isa_arcv2() && ioc_enable) || 34 BUG_ON(gfp & __GFP_HIGHMEM);
48 (attrs & DMA_ATTR_NON_CONSISTENT))
49 need_coh = 0;
50 35
51 /* 36 page = alloc_pages(gfp, order);
52 * - A coherent buffer needs MMU mapping to enforce non-cachability 37 if (!page)
53 * - A highmem page needs a virtual handle (hence MMU mapping) 38 return NULL;
54 * independent of cachability
55 */
56 if (PageHighMem(page) || need_coh)
57 need_kvaddr = 1;
58 39
59 /* This is linear addr (0x8000_0000 based) */ 40 /* This is linear addr (0x8000_0000 based) */
60 paddr = page_to_phys(page); 41 paddr = page_to_phys(page);
61 42
62 *dma_handle = paddr; 43 *dma_handle = paddr;
63 44
64 /* This is kernel Virtual address (0x7000_0000 based) */ 45 /*
65 if (need_kvaddr) { 46 * A coherent buffer needs MMU mapping to enforce non-cachability.
47 * kvaddr is kernel Virtual address (0x7000_0000 based).
48 */
49 if (need_coh) {
66 kvaddr = ioremap_nocache(paddr, size); 50 kvaddr = ioremap_nocache(paddr, size);
67 if (kvaddr == NULL) { 51 if (kvaddr == NULL) {
68 __free_pages(page, order); 52 __free_pages(page, order);
@@ -93,12 +77,8 @@ void arch_dma_free(struct device *dev, size_t size, void *vaddr,
93{ 77{
94 phys_addr_t paddr = dma_handle; 78 phys_addr_t paddr = dma_handle;
95 struct page *page = virt_to_page(paddr); 79 struct page *page = virt_to_page(paddr);
96 int is_non_coh = 1;
97
98 is_non_coh = (attrs & DMA_ATTR_NON_CONSISTENT) ||
99 (is_isa_arcv2() && ioc_enable);
100 80
101 if (PageHighMem(page) || !is_non_coh) 81 if (!(attrs & DMA_ATTR_NON_CONSISTENT))
102 iounmap((void __force __iomem *)vaddr); 82 iounmap((void __force __iomem *)vaddr);
103 83
104 __free_pages(page, get_order(size)); 84 __free_pages(page, get_order(size));
@@ -185,3 +165,23 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
185 break; 165 break;
186 } 166 }
187} 167}
168
169/*
170 * Plug in coherent or noncoherent dma ops
171 */
172void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
173 const struct iommu_ops *iommu, bool coherent)
174{
175 /*
176 * IOC hardware snoops all DMA traffic keeping the caches consistent
177 * with memory - eliding need for any explicit cache maintenance of
178 * DMA buffers - so we can use dma_direct cache ops.
179 */
180 if (is_isa_arcv2() && ioc_enable && coherent) {
181 set_dma_ops(dev, &dma_direct_ops);
182 dev_info(dev, "use dma_direct_ops cache ops\n");
183 } else {
184 set_dma_ops(dev, &dma_noncoherent_ops);
185 dev_info(dev, "use dma_noncoherent_ops cache ops\n");
186 }
187}
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 79906cecb091..3ad482d2f1eb 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -223,7 +223,6 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
223 struct kvm_vcpu_events *events); 223 struct kvm_vcpu_events *events);
224 224
225#define KVM_ARCH_WANT_MMU_NOTIFIER 225#define KVM_ARCH_WANT_MMU_NOTIFIER
226int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
227int kvm_unmap_hva_range(struct kvm *kvm, 226int kvm_unmap_hva_range(struct kvm *kvm,
228 unsigned long start, unsigned long end); 227 unsigned long start, unsigned long end);
229void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); 228void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts
index ceffc40810ee..48daec7f78ba 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts
@@ -46,6 +46,7 @@
46 pinctrl-0 = <&mmc0_pins>; 46 pinctrl-0 = <&mmc0_pins>;
47 vmmc-supply = <&reg_cldo1>; 47 vmmc-supply = <&reg_cldo1>;
48 cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; 48 cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
49 bus-width = <4>;
49 status = "okay"; 50 status = "okay";
50}; 51};
51 52
@@ -56,6 +57,7 @@
56 vqmmc-supply = <&reg_bldo2>; 57 vqmmc-supply = <&reg_bldo2>;
57 non-removable; 58 non-removable;
58 cap-mmc-hw-reset; 59 cap-mmc-hw-reset;
60 bus-width = <8>;
59 status = "okay"; 61 status = "okay";
60}; 62};
61 63
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index f26055f2306e..3d6d7336f871 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -61,8 +61,7 @@ struct kvm_arch {
61 u64 vmid_gen; 61 u64 vmid_gen;
62 u32 vmid; 62 u32 vmid;
63 63
64 /* 1-level 2nd stage table and lock */ 64 /* 1-level 2nd stage table, protected by kvm->mmu_lock */
65 spinlock_t pgd_lock;
66 pgd_t *pgd; 65 pgd_t *pgd;
67 66
68 /* VTTBR value associated with above pgd and vmid */ 67 /* VTTBR value associated with above pgd and vmid */
@@ -357,7 +356,6 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
357 struct kvm_vcpu_events *events); 356 struct kvm_vcpu_events *events);
358 357
359#define KVM_ARCH_WANT_MMU_NOTIFIER 358#define KVM_ARCH_WANT_MMU_NOTIFIER
360int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
361int kvm_unmap_hva_range(struct kvm *kvm, 359int kvm_unmap_hva_range(struct kvm *kvm,
362 unsigned long start, unsigned long end); 360 unsigned long start, unsigned long end);
363void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); 361void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
index d496ef579859..ca46153d7915 100644
--- a/arch/arm64/kvm/hyp/switch.c
+++ b/arch/arm64/kvm/hyp/switch.c
@@ -98,8 +98,10 @@ static void activate_traps_vhe(struct kvm_vcpu *vcpu)
98 val = read_sysreg(cpacr_el1); 98 val = read_sysreg(cpacr_el1);
99 val |= CPACR_EL1_TTA; 99 val |= CPACR_EL1_TTA;
100 val &= ~CPACR_EL1_ZEN; 100 val &= ~CPACR_EL1_ZEN;
101 if (!update_fp_enabled(vcpu)) 101 if (!update_fp_enabled(vcpu)) {
102 val &= ~CPACR_EL1_FPEN; 102 val &= ~CPACR_EL1_FPEN;
103 __activate_traps_fpsimd32(vcpu);
104 }
103 105
104 write_sysreg(val, cpacr_el1); 106 write_sysreg(val, cpacr_el1);
105 107
@@ -114,8 +116,10 @@ static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu)
114 116
115 val = CPTR_EL2_DEFAULT; 117 val = CPTR_EL2_DEFAULT;
116 val |= CPTR_EL2_TTA | CPTR_EL2_TZ; 118 val |= CPTR_EL2_TTA | CPTR_EL2_TZ;
117 if (!update_fp_enabled(vcpu)) 119 if (!update_fp_enabled(vcpu)) {
118 val |= CPTR_EL2_TFP; 120 val |= CPTR_EL2_TFP;
121 __activate_traps_fpsimd32(vcpu);
122 }
119 123
120 write_sysreg(val, cptr_el2); 124 write_sysreg(val, cptr_el2);
121} 125}
@@ -129,7 +133,6 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
129 if (cpus_have_const_cap(ARM64_HAS_RAS_EXTN) && (hcr & HCR_VSE)) 133 if (cpus_have_const_cap(ARM64_HAS_RAS_EXTN) && (hcr & HCR_VSE))
130 write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2); 134 write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2);
131 135
132 __activate_traps_fpsimd32(vcpu);
133 if (has_vhe()) 136 if (has_vhe())
134 activate_traps_vhe(vcpu); 137 activate_traps_vhe(vcpu);
135 else 138 else
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 65f86271f02b..8080c9f489c3 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -985,8 +985,9 @@ int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr)
985 985
986 pmd = READ_ONCE(*pmdp); 986 pmd = READ_ONCE(*pmdp);
987 987
988 /* No-op for empty entry and WARN_ON for valid entry */ 988 if (!pmd_present(pmd))
989 if (!pmd_present(pmd) || !pmd_table(pmd)) { 989 return 1;
990 if (!pmd_table(pmd)) {
990 VM_WARN_ON(!pmd_table(pmd)); 991 VM_WARN_ON(!pmd_table(pmd));
991 return 1; 992 return 1;
992 } 993 }
@@ -1007,8 +1008,9 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
1007 1008
1008 pud = READ_ONCE(*pudp); 1009 pud = READ_ONCE(*pudp);
1009 1010
1010 /* No-op for empty entry and WARN_ON for valid entry */ 1011 if (!pud_present(pud))
1011 if (!pud_present(pud) || !pud_table(pud)) { 1012 return 1;
1013 if (!pud_table(pud)) {
1012 VM_WARN_ON(!pud_table(pud)); 1014 VM_WARN_ON(!pud_table(pud));
1013 return 1; 1015 return 1;
1014 } 1016 }
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index 70dde040779b..f5453d944ff5 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -172,7 +172,7 @@ void __init cf_bootmem_alloc(void)
172 high_memory = (void *)_ramend; 172 high_memory = (void *)_ramend;
173 173
174 /* Reserve kernel text/data/bss */ 174 /* Reserve kernel text/data/bss */
175 memblock_reserve(memstart, memstart - _rambase); 175 memblock_reserve(_rambase, memstart - _rambase);
176 176
177 m68k_virt_to_node_shift = fls(_ramend - 1) - 6; 177 m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
178 module_fixup(NULL, __start_fixup, __stop_fixup); 178 module_fixup(NULL, __start_fixup, __stop_fixup);
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index a9af1d2dcd69..2c1c53d12179 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -931,7 +931,6 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu,
931 bool write); 931 bool write);
932 932
933#define KVM_ARCH_WANT_MMU_NOTIFIER 933#define KVM_ARCH_WANT_MMU_NOTIFIER
934int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
935int kvm_unmap_hva_range(struct kvm *kvm, 934int kvm_unmap_hva_range(struct kvm *kvm,
936 unsigned long start, unsigned long end); 935 unsigned long start, unsigned long end);
937void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); 936void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
diff --git a/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h b/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h
index 4901833498f7..8441b2698e64 100644
--- a/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h
+++ b/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h
@@ -40,6 +40,7 @@ struct ltq_dma_channel {
40 int desc; /* the current descriptor */ 40 int desc; /* the current descriptor */
41 struct ltq_dma_desc *desc_base; /* the descriptor base */ 41 struct ltq_dma_desc *desc_base; /* the descriptor base */
42 int phys; /* physical addr */ 42 int phys; /* physical addr */
43 struct device *dev;
43}; 44};
44 45
45enum { 46enum {
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index 019035d7225c..8f845f6e5f42 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -13,6 +13,7 @@
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16#include <linux/kernel.h>
16#include <linux/mm.h> 17#include <linux/mm.h>
17#include <linux/sched.h> 18#include <linux/sched.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
@@ -20,6 +21,7 @@
20 21
21#include <asm/abi.h> 22#include <asm/abi.h>
22#include <asm/mips-cps.h> 23#include <asm/mips-cps.h>
24#include <asm/page.h>
23#include <asm/vdso.h> 25#include <asm/vdso.h>
24 26
25/* Kernel-provided data used by the VDSO. */ 27/* Kernel-provided data used by the VDSO. */
@@ -128,12 +130,30 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
128 vvar_size = gic_size + PAGE_SIZE; 130 vvar_size = gic_size + PAGE_SIZE;
129 size = vvar_size + image->size; 131 size = vvar_size + image->size;
130 132
133 /*
134 * Find a region that's large enough for us to perform the
135 * colour-matching alignment below.
136 */
137 if (cpu_has_dc_aliases)
138 size += shm_align_mask + 1;
139
131 base = get_unmapped_area(NULL, 0, size, 0, 0); 140 base = get_unmapped_area(NULL, 0, size, 0, 0);
132 if (IS_ERR_VALUE(base)) { 141 if (IS_ERR_VALUE(base)) {
133 ret = base; 142 ret = base;
134 goto out; 143 goto out;
135 } 144 }
136 145
146 /*
147 * If we suffer from dcache aliasing, ensure that the VDSO data page
148 * mapping is coloured the same as the kernel's mapping of that memory.
149 * This ensures that when the kernel updates the VDSO data userland
150 * will observe it without requiring cache invalidations.
151 */
152 if (cpu_has_dc_aliases) {
153 base = __ALIGN_MASK(base, shm_align_mask);
154 base += ((unsigned long)&vdso_data - gic_size) & shm_align_mask;
155 }
156
137 data_addr = base + gic_size; 157 data_addr = base + gic_size;
138 vdso_addr = data_addr + PAGE_SIZE; 158 vdso_addr = data_addr + PAGE_SIZE;
139 159
diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
index ee64db032793..d8dcdb350405 100644
--- a/arch/mips/kvm/mmu.c
+++ b/arch/mips/kvm/mmu.c
@@ -512,16 +512,6 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gfn_t gfn, gfn_t gfn_end,
512 return 1; 512 return 1;
513} 513}
514 514
515int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
516{
517 unsigned long end = hva + PAGE_SIZE;
518
519 handle_hva_to_gpa(kvm, hva, end, &kvm_unmap_hva_handler, NULL);
520
521 kvm_mips_callbacks->flush_shadow_all(kvm);
522 return 0;
523}
524
525int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) 515int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
526{ 516{
527 handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL); 517 handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
diff --git a/arch/mips/lantiq/xway/dma.c b/arch/mips/lantiq/xway/dma.c
index 4b9fbb6744ad..664f2f7f55c1 100644
--- a/arch/mips/lantiq/xway/dma.c
+++ b/arch/mips/lantiq/xway/dma.c
@@ -130,7 +130,7 @@ ltq_dma_alloc(struct ltq_dma_channel *ch)
130 unsigned long flags; 130 unsigned long flags;
131 131
132 ch->desc = 0; 132 ch->desc = 0;
133 ch->desc_base = dma_zalloc_coherent(NULL, 133 ch->desc_base = dma_zalloc_coherent(ch->dev,
134 LTQ_DESC_NUM * LTQ_DESC_SIZE, 134 LTQ_DESC_NUM * LTQ_DESC_SIZE,
135 &ch->phys, GFP_ATOMIC); 135 &ch->phys, GFP_ATOMIC);
136 136
@@ -182,7 +182,7 @@ ltq_dma_free(struct ltq_dma_channel *ch)
182 if (!ch->desc_base) 182 if (!ch->desc_base)
183 return; 183 return;
184 ltq_dma_close(ch); 184 ltq_dma_close(ch);
185 dma_free_coherent(NULL, LTQ_DESC_NUM * LTQ_DESC_SIZE, 185 dma_free_coherent(ch->dev, LTQ_DESC_NUM * LTQ_DESC_SIZE,
186 ch->desc_base, ch->phys); 186 ch->desc_base, ch->phys);
187} 187}
188EXPORT_SYMBOL_GPL(ltq_dma_free); 188EXPORT_SYMBOL_GPL(ltq_dma_free);
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 1d4248fa55e9..7068f341133d 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -40,6 +40,10 @@ config NDS32
40 select NO_IOPORT_MAP 40 select NO_IOPORT_MAP
41 select RTC_LIB 41 select RTC_LIB
42 select THREAD_INFO_IN_TASK 42 select THREAD_INFO_IN_TASK
43 select HAVE_FUNCTION_TRACER
44 select HAVE_FUNCTION_GRAPH_TRACER
45 select HAVE_FTRACE_MCOUNT_RECORD
46 select HAVE_DYNAMIC_FTRACE
43 help 47 help
44 Andes(nds32) Linux support. 48 Andes(nds32) Linux support.
45 49
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile
index 63f4f173e5f4..3509fac10491 100644
--- a/arch/nds32/Makefile
+++ b/arch/nds32/Makefile
@@ -5,6 +5,10 @@ KBUILD_DEFCONFIG := defconfig
5 5
6comma = , 6comma = ,
7 7
8ifdef CONFIG_FUNCTION_TRACER
9arch-y += -malways-save-lp -mno-relax
10endif
11
8KBUILD_CFLAGS += $(call cc-option, -mno-sched-prolog-epilog) 12KBUILD_CFLAGS += $(call cc-option, -mno-sched-prolog-epilog)
9KBUILD_CFLAGS += -mcmodel=large 13KBUILD_CFLAGS += -mcmodel=large
10 14
diff --git a/arch/nds32/include/asm/elf.h b/arch/nds32/include/asm/elf.h
index 56c479058802..f5f9cf7e0544 100644
--- a/arch/nds32/include/asm/elf.h
+++ b/arch/nds32/include/asm/elf.h
@@ -121,9 +121,9 @@ struct elf32_hdr;
121 */ 121 */
122#define ELF_CLASS ELFCLASS32 122#define ELF_CLASS ELFCLASS32
123#ifdef __NDS32_EB__ 123#ifdef __NDS32_EB__
124#define ELF_DATA ELFDATA2MSB; 124#define ELF_DATA ELFDATA2MSB
125#else 125#else
126#define ELF_DATA ELFDATA2LSB; 126#define ELF_DATA ELFDATA2LSB
127#endif 127#endif
128#define ELF_ARCH EM_NDS32 128#define ELF_ARCH EM_NDS32
129#define USE_ELF_CORE_DUMP 129#define USE_ELF_CORE_DUMP
diff --git a/arch/nds32/include/asm/ftrace.h b/arch/nds32/include/asm/ftrace.h
new file mode 100644
index 000000000000..2f96cc96aa35
--- /dev/null
+++ b/arch/nds32/include/asm/ftrace.h
@@ -0,0 +1,46 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef __ASM_NDS32_FTRACE_H
4#define __ASM_NDS32_FTRACE_H
5
6#ifdef CONFIG_FUNCTION_TRACER
7
8#define HAVE_FUNCTION_GRAPH_FP_TEST
9
10#define MCOUNT_ADDR ((unsigned long)(_mcount))
11/* mcount call is composed of three instructions:
12 * sethi + ori + jral
13 */
14#define MCOUNT_INSN_SIZE 12
15
16extern void _mcount(unsigned long parent_ip);
17
18#ifdef CONFIG_DYNAMIC_FTRACE
19
20#define FTRACE_ADDR ((unsigned long)_ftrace_caller)
21
22#ifdef __NDS32_EL__
23#define INSN_NOP 0x09000040
24#define INSN_SIZE(insn) (((insn & 0x00000080) == 0) ? 4 : 2)
25#define IS_SETHI(insn) ((insn & 0x000000fe) == 0x00000046)
26#define ENDIAN_CONVERT(insn) be32_to_cpu(insn)
27#else /* __NDS32_EB__ */
28#define INSN_NOP 0x40000009
29#define INSN_SIZE(insn) (((insn & 0x80000000) == 0) ? 4 : 2)
30#define IS_SETHI(insn) ((insn & 0xfe000000) == 0x46000000)
31#define ENDIAN_CONVERT(insn) (insn)
32#endif
33
34extern void _ftrace_caller(unsigned long parent_ip);
35static inline unsigned long ftrace_call_adjust(unsigned long addr)
36{
37 return addr;
38}
39struct dyn_arch_ftrace {
40};
41
42#endif /* CONFIG_DYNAMIC_FTRACE */
43
44#endif /* CONFIG_FUNCTION_TRACER */
45
46#endif /* __ASM_NDS32_FTRACE_H */
diff --git a/arch/nds32/include/asm/nds32.h b/arch/nds32/include/asm/nds32.h
index 19b19394a936..68c38151c3e4 100644
--- a/arch/nds32/include/asm/nds32.h
+++ b/arch/nds32/include/asm/nds32.h
@@ -17,6 +17,7 @@
17#else 17#else
18#define FP_OFFSET (-2) 18#define FP_OFFSET (-2)
19#endif 19#endif
20#define LP_OFFSET (-1)
20 21
21extern void __init early_trap_init(void); 22extern void __init early_trap_init(void);
22static inline void GIE_ENABLE(void) 23static inline void GIE_ENABLE(void)
diff --git a/arch/nds32/include/asm/uaccess.h b/arch/nds32/include/asm/uaccess.h
index 18a009f3804d..362a32d9bd16 100644
--- a/arch/nds32/include/asm/uaccess.h
+++ b/arch/nds32/include/asm/uaccess.h
@@ -38,7 +38,7 @@ struct exception_table_entry {
38extern int fixup_exception(struct pt_regs *regs); 38extern int fixup_exception(struct pt_regs *regs);
39 39
40#define KERNEL_DS ((mm_segment_t) { ~0UL }) 40#define KERNEL_DS ((mm_segment_t) { ~0UL })
41#define USER_DS ((mm_segment_t) {TASK_SIZE - 1}) 41#define USER_DS ((mm_segment_t) {TASK_SIZE - 1})
42 42
43#define get_ds() (KERNEL_DS) 43#define get_ds() (KERNEL_DS)
44#define get_fs() (current_thread_info()->addr_limit) 44#define get_fs() (current_thread_info()->addr_limit)
@@ -49,11 +49,11 @@ static inline void set_fs(mm_segment_t fs)
49 current_thread_info()->addr_limit = fs; 49 current_thread_info()->addr_limit = fs;
50} 50}
51 51
52#define segment_eq(a, b) ((a) == (b)) 52#define segment_eq(a, b) ((a) == (b))
53 53
54#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size)) 54#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size))
55 55
56#define access_ok(type, addr, size) \ 56#define access_ok(type, addr, size) \
57 __range_ok((unsigned long)addr, (unsigned long)size) 57 __range_ok((unsigned long)addr, (unsigned long)size)
58/* 58/*
59 * Single-value transfer routines. They automatically use the right 59 * Single-value transfer routines. They automatically use the right
@@ -75,70 +75,73 @@ static inline void set_fs(mm_segment_t fs)
75 * versions are void (ie, don't return a value as such). 75 * versions are void (ie, don't return a value as such).
76 */ 76 */
77 77
78#define get_user(x,p) \ 78#define get_user __get_user \
79({ \ 79
80 long __e = -EFAULT; \ 80#define __get_user(x, ptr) \
81 if(likely(access_ok(VERIFY_READ, p, sizeof(*p)))) { \
82 __e = __get_user(x,p); \
83 } else \
84 x = 0; \
85 __e; \
86})
87#define __get_user(x,ptr) \
88({ \ 81({ \
89 long __gu_err = 0; \ 82 long __gu_err = 0; \
90 __get_user_err((x),(ptr),__gu_err); \ 83 __get_user_check((x), (ptr), __gu_err); \
91 __gu_err; \ 84 __gu_err; \
92}) 85})
93 86
94#define __get_user_error(x,ptr,err) \ 87#define __get_user_error(x, ptr, err) \
95({ \ 88({ \
96 __get_user_err((x),(ptr),err); \ 89 __get_user_check((x), (ptr), (err)); \
97 (void) 0; \ 90 (void)0; \
98}) 91})
99 92
100#define __get_user_err(x,ptr,err) \ 93#define __get_user_check(x, ptr, err) \
94({ \
95 const __typeof__(*(ptr)) __user *__p = (ptr); \
96 might_fault(); \
97 if (access_ok(VERIFY_READ, __p, sizeof(*__p))) { \
98 __get_user_err((x), __p, (err)); \
99 } else { \
100 (x) = 0; (err) = -EFAULT; \
101 } \
102})
103
104#define __get_user_err(x, ptr, err) \
101do { \ 105do { \
102 unsigned long __gu_addr = (unsigned long)(ptr); \
103 unsigned long __gu_val; \ 106 unsigned long __gu_val; \
104 __chk_user_ptr(ptr); \ 107 __chk_user_ptr(ptr); \
105 switch (sizeof(*(ptr))) { \ 108 switch (sizeof(*(ptr))) { \
106 case 1: \ 109 case 1: \
107 __get_user_asm("lbi",__gu_val,__gu_addr,err); \ 110 __get_user_asm("lbi", __gu_val, (ptr), (err)); \
108 break; \ 111 break; \
109 case 2: \ 112 case 2: \
110 __get_user_asm("lhi",__gu_val,__gu_addr,err); \ 113 __get_user_asm("lhi", __gu_val, (ptr), (err)); \
111 break; \ 114 break; \
112 case 4: \ 115 case 4: \
113 __get_user_asm("lwi",__gu_val,__gu_addr,err); \ 116 __get_user_asm("lwi", __gu_val, (ptr), (err)); \
114 break; \ 117 break; \
115 case 8: \ 118 case 8: \
116 __get_user_asm_dword(__gu_val,__gu_addr,err); \ 119 __get_user_asm_dword(__gu_val, (ptr), (err)); \
117 break; \ 120 break; \
118 default: \ 121 default: \
119 BUILD_BUG(); \ 122 BUILD_BUG(); \
120 break; \ 123 break; \
121 } \ 124 } \
122 (x) = (__typeof__(*(ptr)))__gu_val; \ 125 (x) = (__force __typeof__(*(ptr)))__gu_val; \
123} while (0) 126} while (0)
124 127
125#define __get_user_asm(inst,x,addr,err) \ 128#define __get_user_asm(inst, x, addr, err) \
126 asm volatile( \ 129 __asm__ __volatile__ ( \
127 "1: "inst" %1,[%2]\n" \ 130 "1: "inst" %1,[%2]\n" \
128 "2:\n" \ 131 "2:\n" \
129 " .section .fixup,\"ax\"\n" \ 132 " .section .fixup,\"ax\"\n" \
130 " .align 2\n" \ 133 " .align 2\n" \
131 "3: move %0, %3\n" \ 134 "3: move %0, %3\n" \
132 " move %1, #0\n" \ 135 " move %1, #0\n" \
133 " b 2b\n" \ 136 " b 2b\n" \
134 " .previous\n" \ 137 " .previous\n" \
135 " .section __ex_table,\"a\"\n" \ 138 " .section __ex_table,\"a\"\n" \
136 " .align 3\n" \ 139 " .align 3\n" \
137 " .long 1b, 3b\n" \ 140 " .long 1b, 3b\n" \
138 " .previous" \ 141 " .previous" \
139 : "+r" (err), "=&r" (x) \ 142 : "+r" (err), "=&r" (x) \
140 : "r" (addr), "i" (-EFAULT) \ 143 : "r" (addr), "i" (-EFAULT) \
141 : "cc") 144 : "cc")
142 145
143#ifdef __NDS32_EB__ 146#ifdef __NDS32_EB__
144#define __gu_reg_oper0 "%H1" 147#define __gu_reg_oper0 "%H1"
@@ -149,61 +152,66 @@ do { \
149#endif 152#endif
150 153
151#define __get_user_asm_dword(x, addr, err) \ 154#define __get_user_asm_dword(x, addr, err) \
152 asm volatile( \ 155 __asm__ __volatile__ ( \
153 "\n1:\tlwi " __gu_reg_oper0 ",[%2]\n" \ 156 "\n1:\tlwi " __gu_reg_oper0 ",[%2]\n" \
154 "\n2:\tlwi " __gu_reg_oper1 ",[%2+4]\n" \ 157 "\n2:\tlwi " __gu_reg_oper1 ",[%2+4]\n" \
155 "3:\n" \ 158 "3:\n" \
156 " .section .fixup,\"ax\"\n" \ 159 " .section .fixup,\"ax\"\n" \
157 " .align 2\n" \ 160 " .align 2\n" \
158 "4: move %0, %3\n" \ 161 "4: move %0, %3\n" \
159 " b 3b\n" \ 162 " b 3b\n" \
160 " .previous\n" \ 163 " .previous\n" \
161 " .section __ex_table,\"a\"\n" \ 164 " .section __ex_table,\"a\"\n" \
162 " .align 3\n" \ 165 " .align 3\n" \
163 " .long 1b, 4b\n" \ 166 " .long 1b, 4b\n" \
164 " .long 2b, 4b\n" \ 167 " .long 2b, 4b\n" \
165 " .previous" \ 168 " .previous" \
166 : "+r"(err), "=&r"(x) \ 169 : "+r"(err), "=&r"(x) \
167 : "r"(addr), "i"(-EFAULT) \ 170 : "r"(addr), "i"(-EFAULT) \
168 : "cc") 171 : "cc")
169#define put_user(x,p) \ 172
170({ \ 173#define put_user __put_user \
171 long __e = -EFAULT; \ 174
172 if(likely(access_ok(VERIFY_WRITE, p, sizeof(*p)))) { \ 175#define __put_user(x, ptr) \
173 __e = __put_user(x,p); \
174 } \
175 __e; \
176})
177#define __put_user(x,ptr) \
178({ \ 176({ \
179 long __pu_err = 0; \ 177 long __pu_err = 0; \
180 __put_user_err((x),(ptr),__pu_err); \ 178 __put_user_err((x), (ptr), __pu_err); \
181 __pu_err; \ 179 __pu_err; \
182}) 180})
183 181
184#define __put_user_error(x,ptr,err) \ 182#define __put_user_error(x, ptr, err) \
183({ \
184 __put_user_err((x), (ptr), (err)); \
185 (void)0; \
186})
187
188#define __put_user_check(x, ptr, err) \
185({ \ 189({ \
186 __put_user_err((x),(ptr),err); \ 190 __typeof__(*(ptr)) __user *__p = (ptr); \
187 (void) 0; \ 191 might_fault(); \
192 if (access_ok(VERIFY_WRITE, __p, sizeof(*__p))) { \
193 __put_user_err((x), __p, (err)); \
194 } else { \
195 (err) = -EFAULT; \
196 } \
188}) 197})
189 198
190#define __put_user_err(x,ptr,err) \ 199#define __put_user_err(x, ptr, err) \
191do { \ 200do { \
192 unsigned long __pu_addr = (unsigned long)(ptr); \
193 __typeof__(*(ptr)) __pu_val = (x); \ 201 __typeof__(*(ptr)) __pu_val = (x); \
194 __chk_user_ptr(ptr); \ 202 __chk_user_ptr(ptr); \
195 switch (sizeof(*(ptr))) { \ 203 switch (sizeof(*(ptr))) { \
196 case 1: \ 204 case 1: \
197 __put_user_asm("sbi",__pu_val,__pu_addr,err); \ 205 __put_user_asm("sbi", __pu_val, (ptr), (err)); \
198 break; \ 206 break; \
199 case 2: \ 207 case 2: \
200 __put_user_asm("shi",__pu_val,__pu_addr,err); \ 208 __put_user_asm("shi", __pu_val, (ptr), (err)); \
201 break; \ 209 break; \
202 case 4: \ 210 case 4: \
203 __put_user_asm("swi",__pu_val,__pu_addr,err); \ 211 __put_user_asm("swi", __pu_val, (ptr), (err)); \
204 break; \ 212 break; \
205 case 8: \ 213 case 8: \
206 __put_user_asm_dword(__pu_val,__pu_addr,err); \ 214 __put_user_asm_dword(__pu_val, (ptr), (err)); \
207 break; \ 215 break; \
208 default: \ 216 default: \
209 BUILD_BUG(); \ 217 BUILD_BUG(); \
@@ -211,22 +219,22 @@ do { \
211 } \ 219 } \
212} while (0) 220} while (0)
213 221
214#define __put_user_asm(inst,x,addr,err) \ 222#define __put_user_asm(inst, x, addr, err) \
215 asm volatile( \ 223 __asm__ __volatile__ ( \
216 "1: "inst" %1,[%2]\n" \ 224 "1: "inst" %1,[%2]\n" \
217 "2:\n" \ 225 "2:\n" \
218 " .section .fixup,\"ax\"\n" \ 226 " .section .fixup,\"ax\"\n" \
219 " .align 2\n" \ 227 " .align 2\n" \
220 "3: move %0, %3\n" \ 228 "3: move %0, %3\n" \
221 " b 2b\n" \ 229 " b 2b\n" \
222 " .previous\n" \ 230 " .previous\n" \
223 " .section __ex_table,\"a\"\n" \ 231 " .section __ex_table,\"a\"\n" \
224 " .align 3\n" \ 232 " .align 3\n" \
225 " .long 1b, 3b\n" \ 233 " .long 1b, 3b\n" \
226 " .previous" \ 234 " .previous" \
227 : "+r" (err) \ 235 : "+r" (err) \
228 : "r" (x), "r" (addr), "i" (-EFAULT) \ 236 : "r" (x), "r" (addr), "i" (-EFAULT) \
229 : "cc") 237 : "cc")
230 238
231#ifdef __NDS32_EB__ 239#ifdef __NDS32_EB__
232#define __pu_reg_oper0 "%H2" 240#define __pu_reg_oper0 "%H2"
@@ -237,23 +245,24 @@ do { \
237#endif 245#endif
238 246
239#define __put_user_asm_dword(x, addr, err) \ 247#define __put_user_asm_dword(x, addr, err) \
240 asm volatile( \ 248 __asm__ __volatile__ ( \
241 "\n1:\tswi " __pu_reg_oper0 ",[%1]\n" \ 249 "\n1:\tswi " __pu_reg_oper0 ",[%1]\n" \
242 "\n2:\tswi " __pu_reg_oper1 ",[%1+4]\n" \ 250 "\n2:\tswi " __pu_reg_oper1 ",[%1+4]\n" \
243 "3:\n" \ 251 "3:\n" \
244 " .section .fixup,\"ax\"\n" \ 252 " .section .fixup,\"ax\"\n" \
245 " .align 2\n" \ 253 " .align 2\n" \
246 "4: move %0, %3\n" \ 254 "4: move %0, %3\n" \
247 " b 3b\n" \ 255 " b 3b\n" \
248 " .previous\n" \ 256 " .previous\n" \
249 " .section __ex_table,\"a\"\n" \ 257 " .section __ex_table,\"a\"\n" \
250 " .align 3\n" \ 258 " .align 3\n" \
251 " .long 1b, 4b\n" \ 259 " .long 1b, 4b\n" \
252 " .long 2b, 4b\n" \ 260 " .long 2b, 4b\n" \
253 " .previous" \ 261 " .previous" \
254 : "+r"(err) \ 262 : "+r"(err) \
255 : "r"(addr), "r"(x), "i"(-EFAULT) \ 263 : "r"(addr), "r"(x), "i"(-EFAULT) \
256 : "cc") 264 : "cc")
265
257extern unsigned long __arch_clear_user(void __user * addr, unsigned long n); 266extern unsigned long __arch_clear_user(void __user * addr, unsigned long n);
258extern long strncpy_from_user(char *dest, const char __user * src, long count); 267extern long strncpy_from_user(char *dest, const char __user * src, long count);
259extern __must_check long strlen_user(const char __user * str); 268extern __must_check long strlen_user(const char __user * str);
diff --git a/arch/nds32/kernel/Makefile b/arch/nds32/kernel/Makefile
index 42792743e8b9..27cded39fa66 100644
--- a/arch/nds32/kernel/Makefile
+++ b/arch/nds32/kernel/Makefile
@@ -21,3 +21,9 @@ extra-y := head.o vmlinux.lds
21 21
22 22
23obj-y += vdso/ 23obj-y += vdso/
24
25obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o
26
27ifdef CONFIG_FUNCTION_TRACER
28CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
29endif
diff --git a/arch/nds32/kernel/atl2c.c b/arch/nds32/kernel/atl2c.c
index 0c6d031a1c4a..0c5386e72098 100644
--- a/arch/nds32/kernel/atl2c.c
+++ b/arch/nds32/kernel/atl2c.c
@@ -9,7 +9,8 @@
9 9
10void __iomem *atl2c_base; 10void __iomem *atl2c_base;
11static const struct of_device_id atl2c_ids[] __initconst = { 11static const struct of_device_id atl2c_ids[] __initconst = {
12 {.compatible = "andestech,atl2c",} 12 {.compatible = "andestech,atl2c",},
13 {}
13}; 14};
14 15
15static int __init atl2c_of_init(void) 16static int __init atl2c_of_init(void)
diff --git a/arch/nds32/kernel/ex-entry.S b/arch/nds32/kernel/ex-entry.S
index b8ae4e9a6b93..21a144071566 100644
--- a/arch/nds32/kernel/ex-entry.S
+++ b/arch/nds32/kernel/ex-entry.S
@@ -118,7 +118,7 @@ common_exception_handler:
118 /* interrupt */ 118 /* interrupt */
1192: 1192:
120#ifdef CONFIG_TRACE_IRQFLAGS 120#ifdef CONFIG_TRACE_IRQFLAGS
121 jal trace_hardirqs_off 121 jal __trace_hardirqs_off
122#endif 122#endif
123 move $r0, $sp 123 move $r0, $sp
124 sethi $lp, hi20(ret_from_intr) 124 sethi $lp, hi20(ret_from_intr)
diff --git a/arch/nds32/kernel/ex-exit.S b/arch/nds32/kernel/ex-exit.S
index 03e4f7788a18..f00af92f7e22 100644
--- a/arch/nds32/kernel/ex-exit.S
+++ b/arch/nds32/kernel/ex-exit.S
@@ -138,8 +138,8 @@ no_work_pending:
138#ifdef CONFIG_TRACE_IRQFLAGS 138#ifdef CONFIG_TRACE_IRQFLAGS
139 lwi $p0, [$sp+(#IPSW_OFFSET)] 139 lwi $p0, [$sp+(#IPSW_OFFSET)]
140 andi $p0, $p0, #0x1 140 andi $p0, $p0, #0x1
141 la $r10, trace_hardirqs_off 141 la $r10, __trace_hardirqs_off
142 la $r9, trace_hardirqs_on 142 la $r9, __trace_hardirqs_on
143 cmovz $r9, $p0, $r10 143 cmovz $r9, $p0, $r10
144 jral $r9 144 jral $r9
145#endif 145#endif
diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
new file mode 100644
index 000000000000..a0a9679ad5de
--- /dev/null
+++ b/arch/nds32/kernel/ftrace.c
@@ -0,0 +1,309 @@
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/ftrace.h>
4#include <linux/uaccess.h>
5#include <asm/cacheflush.h>
6
7#ifndef CONFIG_DYNAMIC_FTRACE
8extern void (*ftrace_trace_function)(unsigned long, unsigned long,
9 struct ftrace_ops*, struct pt_regs*);
10extern int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace);
11extern void ftrace_graph_caller(void);
12
13noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,
14 struct ftrace_ops *op, struct pt_regs *regs)
15{
16 __asm__ (""); /* avoid to optimize as pure function */
17}
18
19noinline void _mcount(unsigned long parent_ip)
20{
21 /* save all state by the compiler prologue */
22
23 unsigned long ip = (unsigned long)__builtin_return_address(0);
24
25 if (ftrace_trace_function != ftrace_stub)
26 ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip,
27 NULL, NULL);
28
29#ifdef CONFIG_FUNCTION_GRAPH_TRACER
30 if (ftrace_graph_return != (trace_func_graph_ret_t)ftrace_stub
31 || ftrace_graph_entry != ftrace_graph_entry_stub)
32 ftrace_graph_caller();
33#endif
34
35 /* restore all state by the compiler epilogue */
36}
37EXPORT_SYMBOL(_mcount);
38
39#else /* CONFIG_DYNAMIC_FTRACE */
40
41noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,
42 struct ftrace_ops *op, struct pt_regs *regs)
43{
44 __asm__ (""); /* avoid to optimize as pure function */
45}
46
47noinline void __naked _mcount(unsigned long parent_ip)
48{
49 __asm__ (""); /* avoid to optimize as pure function */
50}
51EXPORT_SYMBOL(_mcount);
52
53#define XSTR(s) STR(s)
54#define STR(s) #s
55void _ftrace_caller(unsigned long parent_ip)
56{
57 /* save all state needed by the compiler prologue */
58
59 /*
60 * prepare arguments for real tracing function
61 * first arg : __builtin_return_address(0) - MCOUNT_INSN_SIZE
62 * second arg : parent_ip
63 */
64 __asm__ __volatile__ (
65 "move $r1, %0 \n\t"
66 "addi $r0, %1, #-" XSTR(MCOUNT_INSN_SIZE) "\n\t"
67 :
68 : "r" (parent_ip), "r" (__builtin_return_address(0)));
69
70 /* a placeholder for the call to a real tracing function */
71 __asm__ __volatile__ (
72 "ftrace_call: \n\t"
73 "nop \n\t"
74 "nop \n\t"
75 "nop \n\t");
76
77#ifdef CONFIG_FUNCTION_GRAPH_TRACER
78 /* a placeholder for the call to ftrace_graph_caller */
79 __asm__ __volatile__ (
80 "ftrace_graph_call: \n\t"
81 "nop \n\t"
82 "nop \n\t"
83 "nop \n\t");
84#endif
85 /* restore all state needed by the compiler epilogue */
86}
87
88int __init ftrace_dyn_arch_init(void)
89{
90 return 0;
91}
92
93int ftrace_arch_code_modify_prepare(void)
94{
95 set_all_modules_text_rw();
96 return 0;
97}
98
99int ftrace_arch_code_modify_post_process(void)
100{
101 set_all_modules_text_ro();
102 return 0;
103}
104
105static unsigned long gen_sethi_insn(unsigned long addr)
106{
107 unsigned long opcode = 0x46000000;
108 unsigned long imm = addr >> 12;
109 unsigned long rt_num = 0xf << 20;
110
111 return ENDIAN_CONVERT(opcode | rt_num | imm);
112}
113
114static unsigned long gen_ori_insn(unsigned long addr)
115{
116 unsigned long opcode = 0x58000000;
117 unsigned long imm = addr & 0x0000fff;
118 unsigned long rt_num = 0xf << 20;
119 unsigned long ra_num = 0xf << 15;
120
121 return ENDIAN_CONVERT(opcode | rt_num | ra_num | imm);
122}
123
124static unsigned long gen_jral_insn(unsigned long addr)
125{
126 unsigned long opcode = 0x4a000001;
127 unsigned long rt_num = 0x1e << 20;
128 unsigned long rb_num = 0xf << 10;
129
130 return ENDIAN_CONVERT(opcode | rt_num | rb_num);
131}
132
133static void ftrace_gen_call_insn(unsigned long *call_insns,
134 unsigned long addr)
135{
136 call_insns[0] = gen_sethi_insn(addr); /* sethi $r15, imm20u */
137 call_insns[1] = gen_ori_insn(addr); /* ori $r15, $r15, imm15u */
138 call_insns[2] = gen_jral_insn(addr); /* jral $lp, $r15 */
139}
140
141static int __ftrace_modify_code(unsigned long pc, unsigned long *old_insn,
142 unsigned long *new_insn, bool validate)
143{
144 unsigned long orig_insn[3];
145
146 if (validate) {
147 if (probe_kernel_read(orig_insn, (void *)pc, MCOUNT_INSN_SIZE))
148 return -EFAULT;
149 if (memcmp(orig_insn, old_insn, MCOUNT_INSN_SIZE))
150 return -EINVAL;
151 }
152
153 if (probe_kernel_write((void *)pc, new_insn, MCOUNT_INSN_SIZE))
154 return -EPERM;
155
156 return 0;
157}
158
159static int ftrace_modify_code(unsigned long pc, unsigned long *old_insn,
160 unsigned long *new_insn, bool validate)
161{
162 int ret;
163
164 ret = __ftrace_modify_code(pc, old_insn, new_insn, validate);
165 if (ret)
166 return ret;
167
168 flush_icache_range(pc, pc + MCOUNT_INSN_SIZE);
169
170 return ret;
171}
172
173int ftrace_update_ftrace_func(ftrace_func_t func)
174{
175 unsigned long pc = (unsigned long)&ftrace_call;
176 unsigned long old_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
177 unsigned long new_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
178
179 if (func != ftrace_stub)
180 ftrace_gen_call_insn(new_insn, (unsigned long)func);
181
182 return ftrace_modify_code(pc, old_insn, new_insn, false);
183}
184
185int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
186{
187 unsigned long pc = rec->ip;
188 unsigned long nop_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
189 unsigned long call_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
190
191 ftrace_gen_call_insn(call_insn, addr);
192
193 return ftrace_modify_code(pc, nop_insn, call_insn, true);
194}
195
196int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
197 unsigned long addr)
198{
199 unsigned long pc = rec->ip;
200 unsigned long nop_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
201 unsigned long call_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
202
203 ftrace_gen_call_insn(call_insn, addr);
204
205 return ftrace_modify_code(pc, call_insn, nop_insn, true);
206}
207#endif /* CONFIG_DYNAMIC_FTRACE */
208
209#ifdef CONFIG_FUNCTION_GRAPH_TRACER
210void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
211 unsigned long frame_pointer)
212{
213 unsigned long return_hooker = (unsigned long)&return_to_handler;
214 struct ftrace_graph_ent trace;
215 unsigned long old;
216 int err;
217
218 if (unlikely(atomic_read(&current->tracing_graph_pause)))
219 return;
220
221 old = *parent;
222
223 trace.func = self_addr;
224 trace.depth = current->curr_ret_stack + 1;
225
226 /* Only trace if the calling function expects to */
227 if (!ftrace_graph_entry(&trace))
228 return;
229
230 err = ftrace_push_return_trace(old, self_addr, &trace.depth,
231 frame_pointer, NULL);
232
233 if (err == -EBUSY)
234 return;
235
236 *parent = return_hooker;
237}
238
239noinline void ftrace_graph_caller(void)
240{
241 unsigned long *parent_ip =
242 (unsigned long *)(__builtin_frame_address(2) - 4);
243
244 unsigned long selfpc =
245 (unsigned long)(__builtin_return_address(1) - MCOUNT_INSN_SIZE);
246
247 unsigned long frame_pointer =
248 (unsigned long)__builtin_frame_address(3);
249
250 prepare_ftrace_return(parent_ip, selfpc, frame_pointer);
251}
252
253extern unsigned long ftrace_return_to_handler(unsigned long frame_pointer);
254void __naked return_to_handler(void)
255{
256 __asm__ __volatile__ (
257 /* save state needed by the ABI */
258 "smw.adm $r0,[$sp],$r1,#0x0 \n\t"
259
260 /* get original return address */
261 "move $r0, $fp \n\t"
262 "bal ftrace_return_to_handler\n\t"
263 "move $lp, $r0 \n\t"
264
265 /* restore state nedded by the ABI */
266 "lmw.bim $r0,[$sp],$r1,#0x0 \n\t");
267}
268
269#ifdef CONFIG_DYNAMIC_FTRACE
270extern unsigned long ftrace_graph_call;
271
272static int ftrace_modify_graph_caller(bool enable)
273{
274 unsigned long pc = (unsigned long)&ftrace_graph_call;
275 unsigned long nop_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
276 unsigned long call_insn[3] = {INSN_NOP, INSN_NOP, INSN_NOP};
277
278 ftrace_gen_call_insn(call_insn, (unsigned long)ftrace_graph_caller);
279
280 if (enable)
281 return ftrace_modify_code(pc, nop_insn, call_insn, true);
282 else
283 return ftrace_modify_code(pc, call_insn, nop_insn, true);
284}
285
286int ftrace_enable_ftrace_graph_caller(void)
287{
288 return ftrace_modify_graph_caller(true);
289}
290
291int ftrace_disable_ftrace_graph_caller(void)
292{
293 return ftrace_modify_graph_caller(false);
294}
295#endif /* CONFIG_DYNAMIC_FTRACE */
296
297#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
298
299
300#ifdef CONFIG_TRACE_IRQFLAGS
301noinline void __trace_hardirqs_off(void)
302{
303 trace_hardirqs_off();
304}
305noinline void __trace_hardirqs_on(void)
306{
307 trace_hardirqs_on();
308}
309#endif /* CONFIG_TRACE_IRQFLAGS */
diff --git a/arch/nds32/kernel/module.c b/arch/nds32/kernel/module.c
index 4167283d8293..1e31829cbc2a 100644
--- a/arch/nds32/kernel/module.c
+++ b/arch/nds32/kernel/module.c
@@ -40,7 +40,7 @@ void do_reloc16(unsigned int val, unsigned int *loc, unsigned int val_mask,
40 40
41 tmp2 = tmp & loc_mask; 41 tmp2 = tmp & loc_mask;
42 if (partial_in_place) { 42 if (partial_in_place) {
43 tmp &= (!loc_mask); 43 tmp &= (~loc_mask);
44 tmp = 44 tmp =
45 tmp2 | ((tmp + ((val & val_mask) >> val_shift)) & val_mask); 45 tmp2 | ((tmp + ((val & val_mask) >> val_shift)) & val_mask);
46 } else { 46 } else {
@@ -70,7 +70,7 @@ void do_reloc32(unsigned int val, unsigned int *loc, unsigned int val_mask,
70 70
71 tmp2 = tmp & loc_mask; 71 tmp2 = tmp & loc_mask;
72 if (partial_in_place) { 72 if (partial_in_place) {
73 tmp &= (!loc_mask); 73 tmp &= (~loc_mask);
74 tmp = 74 tmp =
75 tmp2 | ((tmp + ((val & val_mask) >> val_shift)) & val_mask); 75 tmp2 | ((tmp + ((val & val_mask) >> val_shift)) & val_mask);
76 } else { 76 } else {
diff --git a/arch/nds32/kernel/stacktrace.c b/arch/nds32/kernel/stacktrace.c
index 8b231e910ea6..d974c0c1c65f 100644
--- a/arch/nds32/kernel/stacktrace.c
+++ b/arch/nds32/kernel/stacktrace.c
@@ -4,6 +4,7 @@
4#include <linux/sched/debug.h> 4#include <linux/sched/debug.h>
5#include <linux/sched/task_stack.h> 5#include <linux/sched/task_stack.h>
6#include <linux/stacktrace.h> 6#include <linux/stacktrace.h>
7#include <linux/ftrace.h>
7 8
8void save_stack_trace(struct stack_trace *trace) 9void save_stack_trace(struct stack_trace *trace)
9{ 10{
@@ -16,6 +17,7 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
16 unsigned long *fpn; 17 unsigned long *fpn;
17 int skip = trace->skip; 18 int skip = trace->skip;
18 int savesched; 19 int savesched;
20 int graph_idx = 0;
19 21
20 if (tsk == current) { 22 if (tsk == current) {
21 __asm__ __volatile__("\tori\t%0, $fp, #0\n":"=r"(fpn)); 23 __asm__ __volatile__("\tori\t%0, $fp, #0\n":"=r"(fpn));
@@ -29,10 +31,12 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
29 && (fpn >= (unsigned long *)TASK_SIZE)) { 31 && (fpn >= (unsigned long *)TASK_SIZE)) {
30 unsigned long lpp, fpp; 32 unsigned long lpp, fpp;
31 33
32 lpp = fpn[-1]; 34 lpp = fpn[LP_OFFSET];
33 fpp = fpn[FP_OFFSET]; 35 fpp = fpn[FP_OFFSET];
34 if (!__kernel_text_address(lpp)) 36 if (!__kernel_text_address(lpp))
35 break; 37 break;
38 else
39 lpp = ftrace_graph_ret_addr(tsk, &graph_idx, lpp, NULL);
36 40
37 if (savesched || !in_sched_functions(lpp)) { 41 if (savesched || !in_sched_functions(lpp)) {
38 if (skip) { 42 if (skip) {
diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c
index a6205fd4db52..1496aab48998 100644
--- a/arch/nds32/kernel/traps.c
+++ b/arch/nds32/kernel/traps.c
@@ -8,6 +8,7 @@
8#include <linux/kdebug.h> 8#include <linux/kdebug.h>
9#include <linux/sched/task_stack.h> 9#include <linux/sched/task_stack.h>
10#include <linux/uaccess.h> 10#include <linux/uaccess.h>
11#include <linux/ftrace.h>
11 12
12#include <asm/proc-fns.h> 13#include <asm/proc-fns.h>
13#include <asm/unistd.h> 14#include <asm/unistd.h>
@@ -94,28 +95,6 @@ static void dump_instr(struct pt_regs *regs)
94 set_fs(fs); 95 set_fs(fs);
95} 96}
96 97
97#ifdef CONFIG_FUNCTION_GRAPH_TRACER
98#include <linux/ftrace.h>
99static void
100get_real_ret_addr(unsigned long *addr, struct task_struct *tsk, int *graph)
101{
102 if (*addr == (unsigned long)return_to_handler) {
103 int index = tsk->curr_ret_stack;
104
105 if (tsk->ret_stack && index >= *graph) {
106 index -= *graph;
107 *addr = tsk->ret_stack[index].ret;
108 (*graph)++;
109 }
110 }
111}
112#else
113static inline void
114get_real_ret_addr(unsigned long *addr, struct task_struct *tsk, int *graph)
115{
116}
117#endif
118
119#define LOOP_TIMES (100) 98#define LOOP_TIMES (100)
120static void __dump(struct task_struct *tsk, unsigned long *base_reg) 99static void __dump(struct task_struct *tsk, unsigned long *base_reg)
121{ 100{
@@ -126,7 +105,8 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg)
126 while (!kstack_end(base_reg)) { 105 while (!kstack_end(base_reg)) {
127 ret_addr = *base_reg++; 106 ret_addr = *base_reg++;
128 if (__kernel_text_address(ret_addr)) { 107 if (__kernel_text_address(ret_addr)) {
129 get_real_ret_addr(&ret_addr, tsk, &graph); 108 ret_addr = ftrace_graph_ret_addr(
109 tsk, &graph, ret_addr, NULL);
130 print_ip_sym(ret_addr); 110 print_ip_sym(ret_addr);
131 } 111 }
132 if (--cnt < 0) 112 if (--cnt < 0)
@@ -137,15 +117,12 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg)
137 !((unsigned long)base_reg & 0x3) && 117 !((unsigned long)base_reg & 0x3) &&
138 ((unsigned long)base_reg >= TASK_SIZE)) { 118 ((unsigned long)base_reg >= TASK_SIZE)) {
139 unsigned long next_fp; 119 unsigned long next_fp;
140#if !defined(NDS32_ABI_2) 120 ret_addr = base_reg[LP_OFFSET];
141 ret_addr = base_reg[0];
142 next_fp = base_reg[1];
143#else
144 ret_addr = base_reg[-1];
145 next_fp = base_reg[FP_OFFSET]; 121 next_fp = base_reg[FP_OFFSET];
146#endif
147 if (__kernel_text_address(ret_addr)) { 122 if (__kernel_text_address(ret_addr)) {
148 get_real_ret_addr(&ret_addr, tsk, &graph); 123
124 ret_addr = ftrace_graph_ret_addr(
125 tsk, &graph, ret_addr, NULL);
149 print_ip_sym(ret_addr); 126 print_ip_sym(ret_addr);
150 } 127 }
151 if (--cnt < 0) 128 if (--cnt < 0)
@@ -196,11 +173,10 @@ void die(const char *str, struct pt_regs *regs, int err)
196 pr_emerg("CPU: %i\n", smp_processor_id()); 173 pr_emerg("CPU: %i\n", smp_processor_id());
197 show_regs(regs); 174 show_regs(regs);
198 pr_emerg("Process %s (pid: %d, stack limit = 0x%p)\n", 175 pr_emerg("Process %s (pid: %d, stack limit = 0x%p)\n",
199 tsk->comm, tsk->pid, task_thread_info(tsk) + 1); 176 tsk->comm, tsk->pid, end_of_stack(tsk));
200 177
201 if (!user_mode(regs) || in_interrupt()) { 178 if (!user_mode(regs) || in_interrupt()) {
202 dump_mem("Stack: ", regs->sp, 179 dump_mem("Stack: ", regs->sp, (regs->sp + PAGE_SIZE) & PAGE_MASK);
203 THREAD_SIZE + (unsigned long)task_thread_info(tsk));
204 dump_instr(regs); 180 dump_instr(regs);
205 dump_stack(); 181 dump_stack();
206 } 182 }
diff --git a/arch/nds32/kernel/vmlinux.lds.S b/arch/nds32/kernel/vmlinux.lds.S
index 288313b886ef..9e90f30a181d 100644
--- a/arch/nds32/kernel/vmlinux.lds.S
+++ b/arch/nds32/kernel/vmlinux.lds.S
@@ -13,14 +13,26 @@ OUTPUT_ARCH(nds32)
13ENTRY(_stext_lma) 13ENTRY(_stext_lma)
14jiffies = jiffies_64; 14jiffies = jiffies_64;
15 15
16#if defined(CONFIG_GCOV_KERNEL)
17#define NDS32_EXIT_KEEP(x) x
18#else
19#define NDS32_EXIT_KEEP(x)
20#endif
21
16SECTIONS 22SECTIONS
17{ 23{
18 _stext_lma = TEXTADDR - LOAD_OFFSET; 24 _stext_lma = TEXTADDR - LOAD_OFFSET;
19 . = TEXTADDR; 25 . = TEXTADDR;
20 __init_begin = .; 26 __init_begin = .;
21 HEAD_TEXT_SECTION 27 HEAD_TEXT_SECTION
28 .exit.text : {
29 NDS32_EXIT_KEEP(EXIT_TEXT)
30 }
22 INIT_TEXT_SECTION(PAGE_SIZE) 31 INIT_TEXT_SECTION(PAGE_SIZE)
23 INIT_DATA_SECTION(16) 32 INIT_DATA_SECTION(16)
33 .exit.data : {
34 NDS32_EXIT_KEEP(EXIT_DATA)
35 }
24 PERCPU_SECTION(L1_CACHE_BYTES) 36 PERCPU_SECTION(L1_CACHE_BYTES)
25 __init_end = .; 37 __init_end = .;
26 38
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 3c0e8fb2b773..68e14afecac8 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -358,7 +358,7 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
358 unsigned long pp, key; 358 unsigned long pp, key;
359 unsigned long v, orig_v, gr; 359 unsigned long v, orig_v, gr;
360 __be64 *hptep; 360 __be64 *hptep;
361 int index; 361 long int index;
362 int virtmode = vcpu->arch.shregs.msr & (data ? MSR_DR : MSR_IR); 362 int virtmode = vcpu->arch.shregs.msr & (data ? MSR_DR : MSR_IR);
363 363
364 if (kvm_is_radix(vcpu->kvm)) 364 if (kvm_is_radix(vcpu->kvm))
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index 0af1c0aea1fe..fd6e8c13685f 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -725,10 +725,10 @@ int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
725 gpa, shift); 725 gpa, shift);
726 kvmppc_radix_tlbie_page(kvm, gpa, shift); 726 kvmppc_radix_tlbie_page(kvm, gpa, shift);
727 if ((old & _PAGE_DIRTY) && memslot->dirty_bitmap) { 727 if ((old & _PAGE_DIRTY) && memslot->dirty_bitmap) {
728 unsigned long npages = 1; 728 unsigned long psize = PAGE_SIZE;
729 if (shift) 729 if (shift)
730 npages = 1ul << (shift - PAGE_SHIFT); 730 psize = 1ul << shift;
731 kvmppc_update_dirty_map(memslot, gfn, npages); 731 kvmppc_update_dirty_map(memslot, gfn, psize);
732 } 732 }
733 } 733 }
734 return 0; 734 return 0;
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index db20dc630e7e..aee603123030 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -85,15 +85,8 @@ atomic_t hart_lottery;
85#ifdef CONFIG_BLK_DEV_INITRD 85#ifdef CONFIG_BLK_DEV_INITRD
86static void __init setup_initrd(void) 86static void __init setup_initrd(void)
87{ 87{
88 extern char __initramfs_start[];
89 extern unsigned long __initramfs_size;
90 unsigned long size; 88 unsigned long size;
91 89
92 if (__initramfs_size > 0) {
93 initrd_start = (unsigned long)(&__initramfs_start);
94 initrd_end = initrd_start + __initramfs_size;
95 }
96
97 if (initrd_start >= initrd_end) { 90 if (initrd_start >= initrd_end) {
98 printk(KERN_INFO "initrd not found or empty"); 91 printk(KERN_INFO "initrd not found or empty");
99 goto disable; 92 goto disable;
diff --git a/arch/s390/include/asm/mmu.h b/arch/s390/include/asm/mmu.h
index f31a15044c24..a8418e1379eb 100644
--- a/arch/s390/include/asm/mmu.h
+++ b/arch/s390/include/asm/mmu.h
@@ -16,7 +16,13 @@ typedef struct {
16 unsigned long asce; 16 unsigned long asce;
17 unsigned long asce_limit; 17 unsigned long asce_limit;
18 unsigned long vdso_base; 18 unsigned long vdso_base;
19 /* The mmu context allocates 4K page tables. */ 19 /*
20 * The following bitfields need a down_write on the mm
21 * semaphore when they are written to. As they are only
22 * written once, they can be read without a lock.
23 *
24 * The mmu context allocates 4K page tables.
25 */
20 unsigned int alloc_pgste:1; 26 unsigned int alloc_pgste:1;
21 /* The mmu context uses extended page tables. */ 27 /* The mmu context uses extended page tables. */
22 unsigned int has_pgste:1; 28 unsigned int has_pgste:1;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 91ad4a9425c0..f69333fd2fa3 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -695,7 +695,9 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
695 r = -EINVAL; 695 r = -EINVAL;
696 else { 696 else {
697 r = 0; 697 r = 0;
698 down_write(&kvm->mm->mmap_sem);
698 kvm->mm->context.allow_gmap_hpage_1m = 1; 699 kvm->mm->context.allow_gmap_hpage_1m = 1;
700 up_write(&kvm->mm->mmap_sem);
699 /* 701 /*
700 * We might have to create fake 4k page 702 * We might have to create fake 4k page
701 * tables. To avoid that the hardware works on 703 * tables. To avoid that the hardware works on
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index d68f10441a16..8679bd74d337 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -280,9 +280,11 @@ retry:
280 goto retry; 280 goto retry;
281 } 281 }
282 } 282 }
283 if (rc)
284 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
285 up_read(&current->mm->mmap_sem); 283 up_read(&current->mm->mmap_sem);
284 if (rc == -EFAULT)
285 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
286 if (rc < 0)
287 return rc;
286 vcpu->run->s.regs.gprs[reg1] &= ~0xff; 288 vcpu->run->s.regs.gprs[reg1] &= ~0xff;
287 vcpu->run->s.regs.gprs[reg1] |= key; 289 vcpu->run->s.regs.gprs[reg1] |= key;
288 return 0; 290 return 0;
@@ -324,9 +326,11 @@ retry:
324 goto retry; 326 goto retry;
325 } 327 }
326 } 328 }
327 if (rc < 0)
328 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
329 up_read(&current->mm->mmap_sem); 329 up_read(&current->mm->mmap_sem);
330 if (rc == -EFAULT)
331 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
332 if (rc < 0)
333 return rc;
330 kvm_s390_set_psw_cc(vcpu, rc); 334 kvm_s390_set_psw_cc(vcpu, rc);
331 return 0; 335 return 0;
332} 336}
@@ -390,12 +394,12 @@ static int handle_sske(struct kvm_vcpu *vcpu)
390 FAULT_FLAG_WRITE, &unlocked); 394 FAULT_FLAG_WRITE, &unlocked);
391 rc = !rc ? -EAGAIN : rc; 395 rc = !rc ? -EAGAIN : rc;
392 } 396 }
397 up_read(&current->mm->mmap_sem);
393 if (rc == -EFAULT) 398 if (rc == -EFAULT)
394 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 399 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
395 400 if (rc < 0)
396 up_read(&current->mm->mmap_sem); 401 return rc;
397 if (rc >= 0) 402 start += PAGE_SIZE;
398 start += PAGE_SIZE;
399 } 403 }
400 404
401 if (m3 & (SSKE_MC | SSKE_MR)) { 405 if (m3 & (SSKE_MC | SSKE_MR)) {
@@ -1002,13 +1006,15 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
1002 FAULT_FLAG_WRITE, &unlocked); 1006 FAULT_FLAG_WRITE, &unlocked);
1003 rc = !rc ? -EAGAIN : rc; 1007 rc = !rc ? -EAGAIN : rc;
1004 } 1008 }
1009 up_read(&current->mm->mmap_sem);
1005 if (rc == -EFAULT) 1010 if (rc == -EFAULT)
1006 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 1011 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
1007 1012 if (rc == -EAGAIN)
1008 up_read(&current->mm->mmap_sem); 1013 continue;
1009 if (rc >= 0) 1014 if (rc < 0)
1010 start += PAGE_SIZE; 1015 return rc;
1011 } 1016 }
1017 start += PAGE_SIZE;
1012 } 1018 }
1013 if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { 1019 if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) {
1014 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) { 1020 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) {
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 63844b95c22c..a2b28cd1e3fe 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -173,7 +173,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
173 return set_validity_icpt(scb_s, 0x0039U); 173 return set_validity_icpt(scb_s, 0x0039U);
174 174
175 /* copy only the wrapping keys */ 175 /* copy only the wrapping keys */
176 if (read_guest_real(vcpu, crycb_addr + 72, &vsie_page->crycb, 56)) 176 if (read_guest_real(vcpu, crycb_addr + 72,
177 vsie_page->crycb.dea_wrapping_key_mask, 56))
177 return set_validity_icpt(scb_s, 0x0035U); 178 return set_validity_icpt(scb_s, 0x0035U);
178 179
179 scb_s->ecb3 |= ecb3_flags; 180 scb_s->ecb3 |= ecb3_flags;
diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
index b143717b92b3..ce84388e540c 100644
--- a/arch/x86/include/asm/atomic.h
+++ b/arch/x86/include/asm/atomic.h
@@ -80,11 +80,11 @@ static __always_inline void arch_atomic_sub(int i, atomic_t *v)
80 * true if the result is zero, or false for all 80 * true if the result is zero, or false for all
81 * other cases. 81 * other cases.
82 */ 82 */
83#define arch_atomic_sub_and_test arch_atomic_sub_and_test
84static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v) 83static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v)
85{ 84{
86 GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", e); 85 GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", e);
87} 86}
87#define arch_atomic_sub_and_test arch_atomic_sub_and_test
88 88
89/** 89/**
90 * arch_atomic_inc - increment atomic variable 90 * arch_atomic_inc - increment atomic variable
@@ -92,12 +92,12 @@ static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v)
92 * 92 *
93 * Atomically increments @v by 1. 93 * Atomically increments @v by 1.
94 */ 94 */
95#define arch_atomic_inc arch_atomic_inc
96static __always_inline void arch_atomic_inc(atomic_t *v) 95static __always_inline void arch_atomic_inc(atomic_t *v)
97{ 96{
98 asm volatile(LOCK_PREFIX "incl %0" 97 asm volatile(LOCK_PREFIX "incl %0"
99 : "+m" (v->counter)); 98 : "+m" (v->counter));
100} 99}
100#define arch_atomic_inc arch_atomic_inc
101 101
102/** 102/**
103 * arch_atomic_dec - decrement atomic variable 103 * arch_atomic_dec - decrement atomic variable
@@ -105,12 +105,12 @@ static __always_inline void arch_atomic_inc(atomic_t *v)
105 * 105 *
106 * Atomically decrements @v by 1. 106 * Atomically decrements @v by 1.
107 */ 107 */
108#define arch_atomic_dec arch_atomic_dec
109static __always_inline void arch_atomic_dec(atomic_t *v) 108static __always_inline void arch_atomic_dec(atomic_t *v)
110{ 109{
111 asm volatile(LOCK_PREFIX "decl %0" 110 asm volatile(LOCK_PREFIX "decl %0"
112 : "+m" (v->counter)); 111 : "+m" (v->counter));
113} 112}
113#define arch_atomic_dec arch_atomic_dec
114 114
115/** 115/**
116 * arch_atomic_dec_and_test - decrement and test 116 * arch_atomic_dec_and_test - decrement and test
@@ -120,11 +120,11 @@ static __always_inline void arch_atomic_dec(atomic_t *v)
120 * returns true if the result is 0, or false for all other 120 * returns true if the result is 0, or false for all other
121 * cases. 121 * cases.
122 */ 122 */
123#define arch_atomic_dec_and_test arch_atomic_dec_and_test
124static __always_inline bool arch_atomic_dec_and_test(atomic_t *v) 123static __always_inline bool arch_atomic_dec_and_test(atomic_t *v)
125{ 124{
126 GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", e); 125 GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", e);
127} 126}
127#define arch_atomic_dec_and_test arch_atomic_dec_and_test
128 128
129/** 129/**
130 * arch_atomic_inc_and_test - increment and test 130 * arch_atomic_inc_and_test - increment and test
@@ -134,11 +134,11 @@ static __always_inline bool arch_atomic_dec_and_test(atomic_t *v)
134 * and returns true if the result is zero, or false for all 134 * and returns true if the result is zero, or false for all
135 * other cases. 135 * other cases.
136 */ 136 */
137#define arch_atomic_inc_and_test arch_atomic_inc_and_test
138static __always_inline bool arch_atomic_inc_and_test(atomic_t *v) 137static __always_inline bool arch_atomic_inc_and_test(atomic_t *v)
139{ 138{
140 GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", e); 139 GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", e);
141} 140}
141#define arch_atomic_inc_and_test arch_atomic_inc_and_test
142 142
143/** 143/**
144 * arch_atomic_add_negative - add and test if negative 144 * arch_atomic_add_negative - add and test if negative
@@ -149,11 +149,11 @@ static __always_inline bool arch_atomic_inc_and_test(atomic_t *v)
149 * if the result is negative, or false when 149 * if the result is negative, or false when
150 * result is greater than or equal to zero. 150 * result is greater than or equal to zero.
151 */ 151 */
152#define arch_atomic_add_negative arch_atomic_add_negative
153static __always_inline bool arch_atomic_add_negative(int i, atomic_t *v) 152static __always_inline bool arch_atomic_add_negative(int i, atomic_t *v)
154{ 153{
155 GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", s); 154 GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", s);
156} 155}
156#define arch_atomic_add_negative arch_atomic_add_negative
157 157
158/** 158/**
159 * arch_atomic_add_return - add integer and return 159 * arch_atomic_add_return - add integer and return
diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
index ef959f02d070..6a5b0ec460da 100644
--- a/arch/x86/include/asm/atomic64_32.h
+++ b/arch/x86/include/asm/atomic64_32.h
@@ -205,12 +205,12 @@ static inline long long arch_atomic64_sub(long long i, atomic64_t *v)
205 * 205 *
206 * Atomically increments @v by 1. 206 * Atomically increments @v by 1.
207 */ 207 */
208#define arch_atomic64_inc arch_atomic64_inc
209static inline void arch_atomic64_inc(atomic64_t *v) 208static inline void arch_atomic64_inc(atomic64_t *v)
210{ 209{
211 __alternative_atomic64(inc, inc_return, /* no output */, 210 __alternative_atomic64(inc, inc_return, /* no output */,
212 "S" (v) : "memory", "eax", "ecx", "edx"); 211 "S" (v) : "memory", "eax", "ecx", "edx");
213} 212}
213#define arch_atomic64_inc arch_atomic64_inc
214 214
215/** 215/**
216 * arch_atomic64_dec - decrement atomic64 variable 216 * arch_atomic64_dec - decrement atomic64 variable
@@ -218,12 +218,12 @@ static inline void arch_atomic64_inc(atomic64_t *v)
218 * 218 *
219 * Atomically decrements @v by 1. 219 * Atomically decrements @v by 1.
220 */ 220 */
221#define arch_atomic64_dec arch_atomic64_dec
222static inline void arch_atomic64_dec(atomic64_t *v) 221static inline void arch_atomic64_dec(atomic64_t *v)
223{ 222{
224 __alternative_atomic64(dec, dec_return, /* no output */, 223 __alternative_atomic64(dec, dec_return, /* no output */,
225 "S" (v) : "memory", "eax", "ecx", "edx"); 224 "S" (v) : "memory", "eax", "ecx", "edx");
226} 225}
226#define arch_atomic64_dec arch_atomic64_dec
227 227
228/** 228/**
229 * arch_atomic64_add_unless - add unless the number is a given value 229 * arch_atomic64_add_unless - add unless the number is a given value
@@ -245,7 +245,6 @@ static inline int arch_atomic64_add_unless(atomic64_t *v, long long a,
245 return (int)a; 245 return (int)a;
246} 246}
247 247
248#define arch_atomic64_inc_not_zero arch_atomic64_inc_not_zero
249static inline int arch_atomic64_inc_not_zero(atomic64_t *v) 248static inline int arch_atomic64_inc_not_zero(atomic64_t *v)
250{ 249{
251 int r; 250 int r;
@@ -253,8 +252,8 @@ static inline int arch_atomic64_inc_not_zero(atomic64_t *v)
253 "S" (v) : "ecx", "edx", "memory"); 252 "S" (v) : "ecx", "edx", "memory");
254 return r; 253 return r;
255} 254}
255#define arch_atomic64_inc_not_zero arch_atomic64_inc_not_zero
256 256
257#define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
258static inline long long arch_atomic64_dec_if_positive(atomic64_t *v) 257static inline long long arch_atomic64_dec_if_positive(atomic64_t *v)
259{ 258{
260 long long r; 259 long long r;
@@ -262,6 +261,7 @@ static inline long long arch_atomic64_dec_if_positive(atomic64_t *v)
262 "S" (v) : "ecx", "memory"); 261 "S" (v) : "ecx", "memory");
263 return r; 262 return r;
264} 263}
264#define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive
265 265
266#undef alternative_atomic64 266#undef alternative_atomic64
267#undef __alternative_atomic64 267#undef __alternative_atomic64
diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
index 4343d9b4f30e..5f851d92eecd 100644
--- a/arch/x86/include/asm/atomic64_64.h
+++ b/arch/x86/include/asm/atomic64_64.h
@@ -71,11 +71,11 @@ static inline void arch_atomic64_sub(long i, atomic64_t *v)
71 * true if the result is zero, or false for all 71 * true if the result is zero, or false for all
72 * other cases. 72 * other cases.
73 */ 73 */
74#define arch_atomic64_sub_and_test arch_atomic64_sub_and_test
75static inline bool arch_atomic64_sub_and_test(long i, atomic64_t *v) 74static inline bool arch_atomic64_sub_and_test(long i, atomic64_t *v)
76{ 75{
77 GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", e); 76 GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", e);
78} 77}
78#define arch_atomic64_sub_and_test arch_atomic64_sub_and_test
79 79
80/** 80/**
81 * arch_atomic64_inc - increment atomic64 variable 81 * arch_atomic64_inc - increment atomic64 variable
@@ -83,13 +83,13 @@ static inline bool arch_atomic64_sub_and_test(long i, atomic64_t *v)
83 * 83 *
84 * Atomically increments @v by 1. 84 * Atomically increments @v by 1.
85 */ 85 */
86#define arch_atomic64_inc arch_atomic64_inc
87static __always_inline void arch_atomic64_inc(atomic64_t *v) 86static __always_inline void arch_atomic64_inc(atomic64_t *v)
88{ 87{
89 asm volatile(LOCK_PREFIX "incq %0" 88 asm volatile(LOCK_PREFIX "incq %0"
90 : "=m" (v->counter) 89 : "=m" (v->counter)
91 : "m" (v->counter)); 90 : "m" (v->counter));
92} 91}
92#define arch_atomic64_inc arch_atomic64_inc
93 93
94/** 94/**
95 * arch_atomic64_dec - decrement atomic64 variable 95 * arch_atomic64_dec - decrement atomic64 variable
@@ -97,13 +97,13 @@ static __always_inline void arch_atomic64_inc(atomic64_t *v)
97 * 97 *
98 * Atomically decrements @v by 1. 98 * Atomically decrements @v by 1.
99 */ 99 */
100#define arch_atomic64_dec arch_atomic64_dec
101static __always_inline void arch_atomic64_dec(atomic64_t *v) 100static __always_inline void arch_atomic64_dec(atomic64_t *v)
102{ 101{
103 asm volatile(LOCK_PREFIX "decq %0" 102 asm volatile(LOCK_PREFIX "decq %0"
104 : "=m" (v->counter) 103 : "=m" (v->counter)
105 : "m" (v->counter)); 104 : "m" (v->counter));
106} 105}
106#define arch_atomic64_dec arch_atomic64_dec
107 107
108/** 108/**
109 * arch_atomic64_dec_and_test - decrement and test 109 * arch_atomic64_dec_and_test - decrement and test
@@ -113,11 +113,11 @@ static __always_inline void arch_atomic64_dec(atomic64_t *v)
113 * returns true if the result is 0, or false for all other 113 * returns true if the result is 0, or false for all other
114 * cases. 114 * cases.
115 */ 115 */
116#define arch_atomic64_dec_and_test arch_atomic64_dec_and_test
117static inline bool arch_atomic64_dec_and_test(atomic64_t *v) 116static inline bool arch_atomic64_dec_and_test(atomic64_t *v)
118{ 117{
119 GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", e); 118 GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", e);
120} 119}
120#define arch_atomic64_dec_and_test arch_atomic64_dec_and_test
121 121
122/** 122/**
123 * arch_atomic64_inc_and_test - increment and test 123 * arch_atomic64_inc_and_test - increment and test
@@ -127,11 +127,11 @@ static inline bool arch_atomic64_dec_and_test(atomic64_t *v)
127 * and returns true if the result is zero, or false for all 127 * and returns true if the result is zero, or false for all
128 * other cases. 128 * other cases.
129 */ 129 */
130#define arch_atomic64_inc_and_test arch_atomic64_inc_and_test
131static inline bool arch_atomic64_inc_and_test(atomic64_t *v) 130static inline bool arch_atomic64_inc_and_test(atomic64_t *v)
132{ 131{
133 GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", e); 132 GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", e);
134} 133}
134#define arch_atomic64_inc_and_test arch_atomic64_inc_and_test
135 135
136/** 136/**
137 * arch_atomic64_add_negative - add and test if negative 137 * arch_atomic64_add_negative - add and test if negative
@@ -142,11 +142,11 @@ static inline bool arch_atomic64_inc_and_test(atomic64_t *v)
142 * if the result is negative, or false when 142 * if the result is negative, or false when
143 * result is greater than or equal to zero. 143 * result is greater than or equal to zero.
144 */ 144 */
145#define arch_atomic64_add_negative arch_atomic64_add_negative
146static inline bool arch_atomic64_add_negative(long i, atomic64_t *v) 145static inline bool arch_atomic64_add_negative(long i, atomic64_t *v)
147{ 146{
148 GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", s); 147 GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", s);
149} 148}
149#define arch_atomic64_add_negative arch_atomic64_add_negative
150 150
151/** 151/**
152 * arch_atomic64_add_return - add and return 152 * arch_atomic64_add_return - add and return
diff --git a/arch/x86/include/asm/kdebug.h b/arch/x86/include/asm/kdebug.h
index 395c9631e000..75f1e35e7c15 100644
--- a/arch/x86/include/asm/kdebug.h
+++ b/arch/x86/include/asm/kdebug.h
@@ -22,10 +22,20 @@ enum die_val {
22 DIE_NMIUNKNOWN, 22 DIE_NMIUNKNOWN,
23}; 23};
24 24
25enum show_regs_mode {
26 SHOW_REGS_SHORT,
27 /*
28 * For when userspace crashed, but we don't think it's our fault, and
29 * therefore don't print kernel registers.
30 */
31 SHOW_REGS_USER,
32 SHOW_REGS_ALL
33};
34
25extern void die(const char *, struct pt_regs *,long); 35extern void die(const char *, struct pt_regs *,long);
26extern int __must_check __die(const char *, struct pt_regs *, long); 36extern int __must_check __die(const char *, struct pt_regs *, long);
27extern void show_stack_regs(struct pt_regs *regs); 37extern void show_stack_regs(struct pt_regs *regs);
28extern void __show_regs(struct pt_regs *regs, int all); 38extern void __show_regs(struct pt_regs *regs, enum show_regs_mode);
29extern void show_iret_regs(struct pt_regs *regs); 39extern void show_iret_regs(struct pt_regs *regs);
30extern unsigned long oops_begin(void); 40extern unsigned long oops_begin(void);
31extern void oops_end(unsigned long, struct pt_regs *, int signr); 41extern void oops_end(unsigned long, struct pt_regs *, int signr);
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 00ddb0c9e612..8e90488c3d56 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1237,19 +1237,12 @@ enum emulation_result {
1237#define EMULTYPE_NO_DECODE (1 << 0) 1237#define EMULTYPE_NO_DECODE (1 << 0)
1238#define EMULTYPE_TRAP_UD (1 << 1) 1238#define EMULTYPE_TRAP_UD (1 << 1)
1239#define EMULTYPE_SKIP (1 << 2) 1239#define EMULTYPE_SKIP (1 << 2)
1240#define EMULTYPE_RETRY (1 << 3) 1240#define EMULTYPE_ALLOW_RETRY (1 << 3)
1241#define EMULTYPE_NO_REEXECUTE (1 << 4) 1241#define EMULTYPE_NO_UD_ON_FAIL (1 << 4)
1242#define EMULTYPE_NO_UD_ON_FAIL (1 << 5) 1242#define EMULTYPE_VMWARE (1 << 5)
1243#define EMULTYPE_VMWARE (1 << 6) 1243int kvm_emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type);
1244int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, 1244int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
1245 int emulation_type, void *insn, int insn_len); 1245 void *insn, int insn_len);
1246
1247static inline int emulate_instruction(struct kvm_vcpu *vcpu,
1248 int emulation_type)
1249{
1250 return x86_emulate_instruction(vcpu, 0,
1251 emulation_type | EMULTYPE_NO_REEXECUTE, NULL, 0);
1252}
1253 1246
1254void kvm_enable_efer_bits(u64); 1247void kvm_enable_efer_bits(u64);
1255bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer); 1248bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer);
@@ -1450,7 +1443,6 @@ asmlinkage void kvm_spurious_fault(void);
1450 ____kvm_handle_fault_on_reboot(insn, "") 1443 ____kvm_handle_fault_on_reboot(insn, "")
1451 1444
1452#define KVM_ARCH_WANT_MMU_NOTIFIER 1445#define KVM_ARCH_WANT_MMU_NOTIFIER
1453int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
1454int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end); 1446int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end);
1455int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end); 1447int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
1456int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); 1448int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
@@ -1463,7 +1455,7 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event);
1463void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu); 1455void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu);
1464 1456
1465int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low, 1457int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low,
1466 unsigned long ipi_bitmap_high, int min, 1458 unsigned long ipi_bitmap_high, u32 min,
1467 unsigned long icr, int op_64_bit); 1459 unsigned long icr, int op_64_bit);
1468 1460
1469u64 kvm_get_arch_capabilities(void); 1461u64 kvm_get_arch_capabilities(void);
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index e4ffa565a69f..690c0307afed 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1195,7 +1195,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
1195 return xchg(pmdp, pmd); 1195 return xchg(pmdp, pmd);
1196 } else { 1196 } else {
1197 pmd_t old = *pmdp; 1197 pmd_t old = *pmdp;
1198 *pmdp = pmd; 1198 WRITE_ONCE(*pmdp, pmd);
1199 return old; 1199 return old;
1200 } 1200 }
1201} 1201}
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index f773d5e6c8cc..ce2b59047cb8 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -55,15 +55,15 @@ struct mm_struct;
55void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte); 55void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte);
56void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte); 56void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte);
57 57
58static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, 58static inline void native_set_pte(pte_t *ptep, pte_t pte)
59 pte_t *ptep)
60{ 59{
61 *ptep = native_make_pte(0); 60 WRITE_ONCE(*ptep, pte);
62} 61}
63 62
64static inline void native_set_pte(pte_t *ptep, pte_t pte) 63static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
64 pte_t *ptep)
65{ 65{
66 *ptep = pte; 66 native_set_pte(ptep, native_make_pte(0));
67} 67}
68 68
69static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) 69static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
@@ -73,7 +73,7 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
73 73
74static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) 74static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
75{ 75{
76 *pmdp = pmd; 76 WRITE_ONCE(*pmdp, pmd);
77} 77}
78 78
79static inline void native_pmd_clear(pmd_t *pmd) 79static inline void native_pmd_clear(pmd_t *pmd)
@@ -109,7 +109,7 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
109 109
110static inline void native_set_pud(pud_t *pudp, pud_t pud) 110static inline void native_set_pud(pud_t *pudp, pud_t pud)
111{ 111{
112 *pudp = pud; 112 WRITE_ONCE(*pudp, pud);
113} 113}
114 114
115static inline void native_pud_clear(pud_t *pud) 115static inline void native_pud_clear(pud_t *pud)
@@ -137,13 +137,13 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
137 pgd_t pgd; 137 pgd_t pgd;
138 138
139 if (pgtable_l5_enabled() || !IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION)) { 139 if (pgtable_l5_enabled() || !IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION)) {
140 *p4dp = p4d; 140 WRITE_ONCE(*p4dp, p4d);
141 return; 141 return;
142 } 142 }
143 143
144 pgd = native_make_pgd(native_p4d_val(p4d)); 144 pgd = native_make_pgd(native_p4d_val(p4d));
145 pgd = pti_set_user_pgtbl((pgd_t *)p4dp, pgd); 145 pgd = pti_set_user_pgtbl((pgd_t *)p4dp, pgd);
146 *p4dp = native_make_p4d(native_pgd_val(pgd)); 146 WRITE_ONCE(*p4dp, native_make_p4d(native_pgd_val(pgd)));
147} 147}
148 148
149static inline void native_p4d_clear(p4d_t *p4d) 149static inline void native_p4d_clear(p4d_t *p4d)
@@ -153,7 +153,7 @@ static inline void native_p4d_clear(p4d_t *p4d)
153 153
154static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd) 154static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
155{ 155{
156 *pgdp = pti_set_user_pgtbl(pgdp, pgd); 156 WRITE_ONCE(*pgdp, pti_set_user_pgtbl(pgdp, pgd));
157} 157}
158 158
159static inline void native_pgd_clear(pgd_t *pgd) 159static inline void native_pgd_clear(pgd_t *pgd)
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 9f148e3d45b4..7654febd5102 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -413,7 +413,7 @@ static int activate_managed(struct irq_data *irqd)
413 if (WARN_ON_ONCE(cpumask_empty(vector_searchmask))) { 413 if (WARN_ON_ONCE(cpumask_empty(vector_searchmask))) {
414 /* Something in the core code broke! Survive gracefully */ 414 /* Something in the core code broke! Survive gracefully */
415 pr_err("Managed startup for irq %u, but no CPU\n", irqd->irq); 415 pr_err("Managed startup for irq %u, but no CPU\n", irqd->irq);
416 return EINVAL; 416 return -EINVAL;
417 } 417 }
418 418
419 ret = assign_managed_vector(irqd, vector_searchmask); 419 ret = assign_managed_vector(irqd, vector_searchmask);
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 0624957aa068..07b5fc00b188 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -504,6 +504,7 @@ static enum ucode_state apply_microcode_amd(int cpu)
504 struct microcode_amd *mc_amd; 504 struct microcode_amd *mc_amd;
505 struct ucode_cpu_info *uci; 505 struct ucode_cpu_info *uci;
506 struct ucode_patch *p; 506 struct ucode_patch *p;
507 enum ucode_state ret;
507 u32 rev, dummy; 508 u32 rev, dummy;
508 509
509 BUG_ON(raw_smp_processor_id() != cpu); 510 BUG_ON(raw_smp_processor_id() != cpu);
@@ -521,9 +522,8 @@ static enum ucode_state apply_microcode_amd(int cpu)
521 522
522 /* need to apply patch? */ 523 /* need to apply patch? */
523 if (rev >= mc_amd->hdr.patch_id) { 524 if (rev >= mc_amd->hdr.patch_id) {
524 c->microcode = rev; 525 ret = UCODE_OK;
525 uci->cpu_sig.rev = rev; 526 goto out;
526 return UCODE_OK;
527 } 527 }
528 528
529 if (__apply_microcode_amd(mc_amd)) { 529 if (__apply_microcode_amd(mc_amd)) {
@@ -531,13 +531,21 @@ static enum ucode_state apply_microcode_amd(int cpu)
531 cpu, mc_amd->hdr.patch_id); 531 cpu, mc_amd->hdr.patch_id);
532 return UCODE_ERROR; 532 return UCODE_ERROR;
533 } 533 }
534 pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
535 mc_amd->hdr.patch_id);
536 534
537 uci->cpu_sig.rev = mc_amd->hdr.patch_id; 535 rev = mc_amd->hdr.patch_id;
538 c->microcode = mc_amd->hdr.patch_id; 536 ret = UCODE_UPDATED;
537
538 pr_info("CPU%d: new patch_level=0x%08x\n", cpu, rev);
539 539
540 return UCODE_UPDATED; 540out:
541 uci->cpu_sig.rev = rev;
542 c->microcode = rev;
543
544 /* Update boot_cpu_data's revision too, if we're on the BSP: */
545 if (c->cpu_index == boot_cpu_data.cpu_index)
546 boot_cpu_data.microcode = rev;
547
548 return ret;
541} 549}
542 550
543static int install_equiv_cpu_table(const u8 *buf) 551static int install_equiv_cpu_table(const u8 *buf)
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 97ccf4c3b45b..16936a24795c 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -795,6 +795,7 @@ static enum ucode_state apply_microcode_intel(int cpu)
795 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 795 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
796 struct cpuinfo_x86 *c = &cpu_data(cpu); 796 struct cpuinfo_x86 *c = &cpu_data(cpu);
797 struct microcode_intel *mc; 797 struct microcode_intel *mc;
798 enum ucode_state ret;
798 static int prev_rev; 799 static int prev_rev;
799 u32 rev; 800 u32 rev;
800 801
@@ -817,9 +818,8 @@ static enum ucode_state apply_microcode_intel(int cpu)
817 */ 818 */
818 rev = intel_get_microcode_revision(); 819 rev = intel_get_microcode_revision();
819 if (rev >= mc->hdr.rev) { 820 if (rev >= mc->hdr.rev) {
820 uci->cpu_sig.rev = rev; 821 ret = UCODE_OK;
821 c->microcode = rev; 822 goto out;
822 return UCODE_OK;
823 } 823 }
824 824
825 /* 825 /*
@@ -848,10 +848,17 @@ static enum ucode_state apply_microcode_intel(int cpu)
848 prev_rev = rev; 848 prev_rev = rev;
849 } 849 }
850 850
851 ret = UCODE_UPDATED;
852
853out:
851 uci->cpu_sig.rev = rev; 854 uci->cpu_sig.rev = rev;
852 c->microcode = rev; 855 c->microcode = rev;
856
857 /* Update boot_cpu_data's revision too, if we're on the BSP: */
858 if (c->cpu_index == boot_cpu_data.cpu_index)
859 boot_cpu_data.microcode = rev;
853 860
854 return UCODE_UPDATED; 861 return ret;
855} 862}
856 863
857static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, 864static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index f56895106ccf..2b5886401e5f 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -146,7 +146,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
146 * they can be printed in the right context. 146 * they can be printed in the right context.
147 */ 147 */
148 if (!partial && on_stack(info, regs, sizeof(*regs))) { 148 if (!partial && on_stack(info, regs, sizeof(*regs))) {
149 __show_regs(regs, 0); 149 __show_regs(regs, SHOW_REGS_SHORT);
150 150
151 } else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET, 151 } else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET,
152 IRET_FRAME_SIZE)) { 152 IRET_FRAME_SIZE)) {
@@ -344,7 +344,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
344 oops_exit(); 344 oops_exit();
345 345
346 /* Executive summary in case the oops scrolled away */ 346 /* Executive summary in case the oops scrolled away */
347 __show_regs(&exec_summary_regs, true); 347 __show_regs(&exec_summary_regs, SHOW_REGS_ALL);
348 348
349 if (!signr) 349 if (!signr)
350 return; 350 return;
@@ -407,14 +407,9 @@ void die(const char *str, struct pt_regs *regs, long err)
407 407
408void show_regs(struct pt_regs *regs) 408void show_regs(struct pt_regs *regs)
409{ 409{
410 bool all = true;
411
412 show_regs_print_info(KERN_DEFAULT); 410 show_regs_print_info(KERN_DEFAULT);
413 411
414 if (IS_ENABLED(CONFIG_X86_32)) 412 __show_regs(regs, user_mode(regs) ? SHOW_REGS_USER : SHOW_REGS_ALL);
415 all = !user_mode(regs);
416
417 __show_regs(regs, all);
418 413
419 /* 414 /*
420 * When in-kernel, we also print out the stack at the time of the fault.. 415 * When in-kernel, we also print out the stack at the time of the fault..
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 2924fd447e61..5046a3c9dec2 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -59,7 +59,7 @@
59#include <asm/intel_rdt_sched.h> 59#include <asm/intel_rdt_sched.h>
60#include <asm/proto.h> 60#include <asm/proto.h>
61 61
62void __show_regs(struct pt_regs *regs, int all) 62void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
63{ 63{
64 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; 64 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
65 unsigned long d0, d1, d2, d3, d6, d7; 65 unsigned long d0, d1, d2, d3, d6, d7;
@@ -85,7 +85,7 @@ void __show_regs(struct pt_regs *regs, int all)
85 printk(KERN_DEFAULT "DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x EFLAGS: %08lx\n", 85 printk(KERN_DEFAULT "DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x EFLAGS: %08lx\n",
86 (u16)regs->ds, (u16)regs->es, (u16)regs->fs, gs, ss, regs->flags); 86 (u16)regs->ds, (u16)regs->es, (u16)regs->fs, gs, ss, regs->flags);
87 87
88 if (!all) 88 if (mode != SHOW_REGS_ALL)
89 return; 89 return;
90 90
91 cr0 = read_cr0(); 91 cr0 = read_cr0();
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index a451bc374b9b..ea5ea850348d 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -62,7 +62,7 @@
62__visible DEFINE_PER_CPU(unsigned long, rsp_scratch); 62__visible DEFINE_PER_CPU(unsigned long, rsp_scratch);
63 63
64/* Prints also some state that isn't saved in the pt_regs */ 64/* Prints also some state that isn't saved in the pt_regs */
65void __show_regs(struct pt_regs *regs, int all) 65void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
66{ 66{
67 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs; 67 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
68 unsigned long d0, d1, d2, d3, d6, d7; 68 unsigned long d0, d1, d2, d3, d6, d7;
@@ -87,9 +87,17 @@ void __show_regs(struct pt_regs *regs, int all)
87 printk(KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n", 87 printk(KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n",
88 regs->r13, regs->r14, regs->r15); 88 regs->r13, regs->r14, regs->r15);
89 89
90 if (!all) 90 if (mode == SHOW_REGS_SHORT)
91 return; 91 return;
92 92
93 if (mode == SHOW_REGS_USER) {
94 rdmsrl(MSR_FS_BASE, fs);
95 rdmsrl(MSR_KERNEL_GS_BASE, shadowgs);
96 printk(KERN_DEFAULT "FS: %016lx GS: %016lx\n",
97 fs, shadowgs);
98 return;
99 }
100
93 asm("movl %%ds,%0" : "=r" (ds)); 101 asm("movl %%ds,%0" : "=r" (ds));
94 asm("movl %%cs,%0" : "=r" (cs)); 102 asm("movl %%cs,%0" : "=r" (cs));
95 asm("movl %%es,%0" : "=r" (es)); 103 asm("movl %%es,%0" : "=r" (es));
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 1463468ba9a0..6490f618e096 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1415,7 +1415,7 @@ static bool __init determine_cpu_tsc_frequencies(bool early)
1415 1415
1416static unsigned long __init get_loops_per_jiffy(void) 1416static unsigned long __init get_loops_per_jiffy(void)
1417{ 1417{
1418 unsigned long lpj = tsc_khz * KHZ; 1418 u64 lpj = (u64)tsc_khz * KHZ;
1419 1419
1420 do_div(lpj, HZ); 1420 do_div(lpj, HZ);
1421 return lpj; 1421 return lpj;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 0cefba28c864..17c0472c5b34 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -548,7 +548,7 @@ int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
548} 548}
549 549
550int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low, 550int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low,
551 unsigned long ipi_bitmap_high, int min, 551 unsigned long ipi_bitmap_high, u32 min,
552 unsigned long icr, int op_64_bit) 552 unsigned long icr, int op_64_bit)
553{ 553{
554 int i; 554 int i;
@@ -571,18 +571,31 @@ int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low,
571 rcu_read_lock(); 571 rcu_read_lock();
572 map = rcu_dereference(kvm->arch.apic_map); 572 map = rcu_dereference(kvm->arch.apic_map);
573 573
574 if (min > map->max_apic_id)
575 goto out;
574 /* Bits above cluster_size are masked in the caller. */ 576 /* Bits above cluster_size are masked in the caller. */
575 for_each_set_bit(i, &ipi_bitmap_low, BITS_PER_LONG) { 577 for_each_set_bit(i, &ipi_bitmap_low,
576 vcpu = map->phys_map[min + i]->vcpu; 578 min((u32)BITS_PER_LONG, (map->max_apic_id - min + 1))) {
577 count += kvm_apic_set_irq(vcpu, &irq, NULL); 579 if (map->phys_map[min + i]) {
580 vcpu = map->phys_map[min + i]->vcpu;
581 count += kvm_apic_set_irq(vcpu, &irq, NULL);
582 }
578 } 583 }
579 584
580 min += cluster_size; 585 min += cluster_size;
581 for_each_set_bit(i, &ipi_bitmap_high, BITS_PER_LONG) { 586
582 vcpu = map->phys_map[min + i]->vcpu; 587 if (min > map->max_apic_id)
583 count += kvm_apic_set_irq(vcpu, &irq, NULL); 588 goto out;
589
590 for_each_set_bit(i, &ipi_bitmap_high,
591 min((u32)BITS_PER_LONG, (map->max_apic_id - min + 1))) {
592 if (map->phys_map[min + i]) {
593 vcpu = map->phys_map[min + i]->vcpu;
594 count += kvm_apic_set_irq(vcpu, &irq, NULL);
595 }
584 } 596 }
585 597
598out:
586 rcu_read_unlock(); 599 rcu_read_unlock();
587 return count; 600 return count;
588} 601}
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a282321329b5..e24ea7067373 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1853,11 +1853,6 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
1853 return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler); 1853 return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler);
1854} 1854}
1855 1855
1856int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
1857{
1858 return kvm_handle_hva(kvm, hva, 0, kvm_unmap_rmapp);
1859}
1860
1861int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) 1856int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
1862{ 1857{
1863 return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp); 1858 return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp);
@@ -5217,7 +5212,7 @@ static int make_mmu_pages_available(struct kvm_vcpu *vcpu)
5217int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code, 5212int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
5218 void *insn, int insn_len) 5213 void *insn, int insn_len)
5219{ 5214{
5220 int r, emulation_type = EMULTYPE_RETRY; 5215 int r, emulation_type = 0;
5221 enum emulation_result er; 5216 enum emulation_result er;
5222 bool direct = vcpu->arch.mmu.direct_map; 5217 bool direct = vcpu->arch.mmu.direct_map;
5223 5218
@@ -5230,10 +5225,8 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
5230 r = RET_PF_INVALID; 5225 r = RET_PF_INVALID;
5231 if (unlikely(error_code & PFERR_RSVD_MASK)) { 5226 if (unlikely(error_code & PFERR_RSVD_MASK)) {
5232 r = handle_mmio_page_fault(vcpu, cr2, direct); 5227 r = handle_mmio_page_fault(vcpu, cr2, direct);
5233 if (r == RET_PF_EMULATE) { 5228 if (r == RET_PF_EMULATE)
5234 emulation_type = 0;
5235 goto emulate; 5229 goto emulate;
5236 }
5237 } 5230 }
5238 5231
5239 if (r == RET_PF_INVALID) { 5232 if (r == RET_PF_INVALID) {
@@ -5260,8 +5253,19 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
5260 return 1; 5253 return 1;
5261 } 5254 }
5262 5255
5263 if (mmio_info_in_cache(vcpu, cr2, direct)) 5256 /*
5264 emulation_type = 0; 5257 * vcpu->arch.mmu.page_fault returned RET_PF_EMULATE, but we can still
5258 * optimistically try to just unprotect the page and let the processor
5259 * re-execute the instruction that caused the page fault. Do not allow
5260 * retrying MMIO emulation, as it's not only pointless but could also
5261 * cause us to enter an infinite loop because the processor will keep
5262 * faulting on the non-existent MMIO address. Retrying an instruction
5263 * from a nested guest is also pointless and dangerous as we are only
5264 * explicitly shadowing L1's page tables, i.e. unprotecting something
5265 * for L1 isn't going to magically fix whatever issue cause L2 to fail.
5266 */
5267 if (!mmio_info_in_cache(vcpu, cr2, direct) && !is_guest_mode(vcpu))
5268 emulation_type = EMULTYPE_ALLOW_RETRY;
5265emulate: 5269emulate:
5266 /* 5270 /*
5267 * On AMD platforms, under certain conditions insn_len may be zero on #NPF. 5271 * On AMD platforms, under certain conditions insn_len may be zero on #NPF.
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 6276140044d0..89c4c5aa15f1 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -776,7 +776,7 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
776 } 776 }
777 777
778 if (!svm->next_rip) { 778 if (!svm->next_rip) {
779 if (emulate_instruction(vcpu, EMULTYPE_SKIP) != 779 if (kvm_emulate_instruction(vcpu, EMULTYPE_SKIP) !=
780 EMULATE_DONE) 780 EMULATE_DONE)
781 printk(KERN_DEBUG "%s: NOP\n", __func__); 781 printk(KERN_DEBUG "%s: NOP\n", __func__);
782 return; 782 return;
@@ -2715,7 +2715,7 @@ static int gp_interception(struct vcpu_svm *svm)
2715 2715
2716 WARN_ON_ONCE(!enable_vmware_backdoor); 2716 WARN_ON_ONCE(!enable_vmware_backdoor);
2717 2717
2718 er = emulate_instruction(vcpu, 2718 er = kvm_emulate_instruction(vcpu,
2719 EMULTYPE_VMWARE | EMULTYPE_NO_UD_ON_FAIL); 2719 EMULTYPE_VMWARE | EMULTYPE_NO_UD_ON_FAIL);
2720 if (er == EMULATE_USER_EXIT) 2720 if (er == EMULATE_USER_EXIT)
2721 return 0; 2721 return 0;
@@ -2819,7 +2819,7 @@ static int io_interception(struct vcpu_svm *svm)
2819 string = (io_info & SVM_IOIO_STR_MASK) != 0; 2819 string = (io_info & SVM_IOIO_STR_MASK) != 0;
2820 in = (io_info & SVM_IOIO_TYPE_MASK) != 0; 2820 in = (io_info & SVM_IOIO_TYPE_MASK) != 0;
2821 if (string) 2821 if (string)
2822 return emulate_instruction(vcpu, 0) == EMULATE_DONE; 2822 return kvm_emulate_instruction(vcpu, 0) == EMULATE_DONE;
2823 2823
2824 port = io_info >> 16; 2824 port = io_info >> 16;
2825 size = (io_info & SVM_IOIO_SIZE_MASK) >> SVM_IOIO_SIZE_SHIFT; 2825 size = (io_info & SVM_IOIO_SIZE_MASK) >> SVM_IOIO_SIZE_SHIFT;
@@ -3861,7 +3861,7 @@ static int iret_interception(struct vcpu_svm *svm)
3861static int invlpg_interception(struct vcpu_svm *svm) 3861static int invlpg_interception(struct vcpu_svm *svm)
3862{ 3862{
3863 if (!static_cpu_has(X86_FEATURE_DECODEASSISTS)) 3863 if (!static_cpu_has(X86_FEATURE_DECODEASSISTS))
3864 return emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE; 3864 return kvm_emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE;
3865 3865
3866 kvm_mmu_invlpg(&svm->vcpu, svm->vmcb->control.exit_info_1); 3866 kvm_mmu_invlpg(&svm->vcpu, svm->vmcb->control.exit_info_1);
3867 return kvm_skip_emulated_instruction(&svm->vcpu); 3867 return kvm_skip_emulated_instruction(&svm->vcpu);
@@ -3869,13 +3869,13 @@ static int invlpg_interception(struct vcpu_svm *svm)
3869 3869
3870static int emulate_on_interception(struct vcpu_svm *svm) 3870static int emulate_on_interception(struct vcpu_svm *svm)
3871{ 3871{
3872 return emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE; 3872 return kvm_emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE;
3873} 3873}
3874 3874
3875static int rsm_interception(struct vcpu_svm *svm) 3875static int rsm_interception(struct vcpu_svm *svm)
3876{ 3876{
3877 return x86_emulate_instruction(&svm->vcpu, 0, 0, 3877 return kvm_emulate_instruction_from_buffer(&svm->vcpu,
3878 rsm_ins_bytes, 2) == EMULATE_DONE; 3878 rsm_ins_bytes, 2) == EMULATE_DONE;
3879} 3879}
3880 3880
3881static int rdpmc_interception(struct vcpu_svm *svm) 3881static int rdpmc_interception(struct vcpu_svm *svm)
@@ -4700,7 +4700,7 @@ static int avic_unaccelerated_access_interception(struct vcpu_svm *svm)
4700 ret = avic_unaccel_trap_write(svm); 4700 ret = avic_unaccel_trap_write(svm);
4701 } else { 4701 } else {
4702 /* Handling Fault */ 4702 /* Handling Fault */
4703 ret = (emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE); 4703 ret = (kvm_emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE);
4704 } 4704 }
4705 4705
4706 return ret; 4706 return ret;
@@ -6747,7 +6747,7 @@ e_free:
6747static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec) 6747static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec)
6748{ 6748{
6749 unsigned long vaddr, vaddr_end, next_vaddr; 6749 unsigned long vaddr, vaddr_end, next_vaddr;
6750 unsigned long dst_vaddr, dst_vaddr_end; 6750 unsigned long dst_vaddr;
6751 struct page **src_p, **dst_p; 6751 struct page **src_p, **dst_p;
6752 struct kvm_sev_dbg debug; 6752 struct kvm_sev_dbg debug;
6753 unsigned long n; 6753 unsigned long n;
@@ -6763,7 +6763,6 @@ static int sev_dbg_crypt(struct kvm *kvm, struct kvm_sev_cmd *argp, bool dec)
6763 size = debug.len; 6763 size = debug.len;
6764 vaddr_end = vaddr + size; 6764 vaddr_end = vaddr + size;
6765 dst_vaddr = debug.dst_uaddr; 6765 dst_vaddr = debug.dst_uaddr;
6766 dst_vaddr_end = dst_vaddr + size;
6767 6766
6768 for (; vaddr < vaddr_end; vaddr = next_vaddr) { 6767 for (; vaddr < vaddr_end; vaddr = next_vaddr) {
6769 int len, s_off, d_off; 6768 int len, s_off, d_off;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1d26f3c4985b..533a327372c8 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6983,7 +6983,7 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu,
6983 * Cause the #SS fault with 0 error code in VM86 mode. 6983 * Cause the #SS fault with 0 error code in VM86 mode.
6984 */ 6984 */
6985 if (((vec == GP_VECTOR) || (vec == SS_VECTOR)) && err_code == 0) { 6985 if (((vec == GP_VECTOR) || (vec == SS_VECTOR)) && err_code == 0) {
6986 if (emulate_instruction(vcpu, 0) == EMULATE_DONE) { 6986 if (kvm_emulate_instruction(vcpu, 0) == EMULATE_DONE) {
6987 if (vcpu->arch.halt_request) { 6987 if (vcpu->arch.halt_request) {
6988 vcpu->arch.halt_request = 0; 6988 vcpu->arch.halt_request = 0;
6989 return kvm_vcpu_halt(vcpu); 6989 return kvm_vcpu_halt(vcpu);
@@ -7054,7 +7054,7 @@ static int handle_exception(struct kvm_vcpu *vcpu)
7054 7054
7055 if (!vmx->rmode.vm86_active && is_gp_fault(intr_info)) { 7055 if (!vmx->rmode.vm86_active && is_gp_fault(intr_info)) {
7056 WARN_ON_ONCE(!enable_vmware_backdoor); 7056 WARN_ON_ONCE(!enable_vmware_backdoor);
7057 er = emulate_instruction(vcpu, 7057 er = kvm_emulate_instruction(vcpu,
7058 EMULTYPE_VMWARE | EMULTYPE_NO_UD_ON_FAIL); 7058 EMULTYPE_VMWARE | EMULTYPE_NO_UD_ON_FAIL);
7059 if (er == EMULATE_USER_EXIT) 7059 if (er == EMULATE_USER_EXIT)
7060 return 0; 7060 return 0;
@@ -7157,7 +7157,7 @@ static int handle_io(struct kvm_vcpu *vcpu)
7157 ++vcpu->stat.io_exits; 7157 ++vcpu->stat.io_exits;
7158 7158
7159 if (string) 7159 if (string)
7160 return emulate_instruction(vcpu, 0) == EMULATE_DONE; 7160 return kvm_emulate_instruction(vcpu, 0) == EMULATE_DONE;
7161 7161
7162 port = exit_qualification >> 16; 7162 port = exit_qualification >> 16;
7163 size = (exit_qualification & 7) + 1; 7163 size = (exit_qualification & 7) + 1;
@@ -7231,7 +7231,7 @@ static int handle_set_cr4(struct kvm_vcpu *vcpu, unsigned long val)
7231static int handle_desc(struct kvm_vcpu *vcpu) 7231static int handle_desc(struct kvm_vcpu *vcpu)
7232{ 7232{
7233 WARN_ON(!(vcpu->arch.cr4 & X86_CR4_UMIP)); 7233 WARN_ON(!(vcpu->arch.cr4 & X86_CR4_UMIP));
7234 return emulate_instruction(vcpu, 0) == EMULATE_DONE; 7234 return kvm_emulate_instruction(vcpu, 0) == EMULATE_DONE;
7235} 7235}
7236 7236
7237static int handle_cr(struct kvm_vcpu *vcpu) 7237static int handle_cr(struct kvm_vcpu *vcpu)
@@ -7480,7 +7480,7 @@ static int handle_vmcall(struct kvm_vcpu *vcpu)
7480 7480
7481static int handle_invd(struct kvm_vcpu *vcpu) 7481static int handle_invd(struct kvm_vcpu *vcpu)
7482{ 7482{
7483 return emulate_instruction(vcpu, 0) == EMULATE_DONE; 7483 return kvm_emulate_instruction(vcpu, 0) == EMULATE_DONE;
7484} 7484}
7485 7485
7486static int handle_invlpg(struct kvm_vcpu *vcpu) 7486static int handle_invlpg(struct kvm_vcpu *vcpu)
@@ -7547,7 +7547,7 @@ static int handle_apic_access(struct kvm_vcpu *vcpu)
7547 return kvm_skip_emulated_instruction(vcpu); 7547 return kvm_skip_emulated_instruction(vcpu);
7548 } 7548 }
7549 } 7549 }
7550 return emulate_instruction(vcpu, 0) == EMULATE_DONE; 7550 return kvm_emulate_instruction(vcpu, 0) == EMULATE_DONE;
7551} 7551}
7552 7552
7553static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu) 7553static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu)
@@ -7704,8 +7704,8 @@ static int handle_ept_misconfig(struct kvm_vcpu *vcpu)
7704 if (!static_cpu_has(X86_FEATURE_HYPERVISOR)) 7704 if (!static_cpu_has(X86_FEATURE_HYPERVISOR))
7705 return kvm_skip_emulated_instruction(vcpu); 7705 return kvm_skip_emulated_instruction(vcpu);
7706 else 7706 else
7707 return x86_emulate_instruction(vcpu, gpa, EMULTYPE_SKIP, 7707 return kvm_emulate_instruction(vcpu, EMULTYPE_SKIP) ==
7708 NULL, 0) == EMULATE_DONE; 7708 EMULATE_DONE;
7709 } 7709 }
7710 7710
7711 return kvm_mmu_page_fault(vcpu, gpa, PFERR_RSVD_MASK, NULL, 0); 7711 return kvm_mmu_page_fault(vcpu, gpa, PFERR_RSVD_MASK, NULL, 0);
@@ -7748,7 +7748,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
7748 if (kvm_test_request(KVM_REQ_EVENT, vcpu)) 7748 if (kvm_test_request(KVM_REQ_EVENT, vcpu))
7749 return 1; 7749 return 1;
7750 7750
7751 err = emulate_instruction(vcpu, 0); 7751 err = kvm_emulate_instruction(vcpu, 0);
7752 7752
7753 if (err == EMULATE_USER_EXIT) { 7753 if (err == EMULATE_USER_EXIT) {
7754 ++vcpu->stat.mmio_exits; 7754 ++vcpu->stat.mmio_exits;
@@ -12537,8 +12537,11 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual)
12537 struct vmcs12 *vmcs12 = get_vmcs12(vcpu); 12537 struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
12538 bool from_vmentry = !!exit_qual; 12538 bool from_vmentry = !!exit_qual;
12539 u32 dummy_exit_qual; 12539 u32 dummy_exit_qual;
12540 u32 vmcs01_cpu_exec_ctrl;
12540 int r = 0; 12541 int r = 0;
12541 12542
12543 vmcs01_cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
12544
12542 enter_guest_mode(vcpu); 12545 enter_guest_mode(vcpu);
12543 12546
12544 if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) 12547 if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
@@ -12575,6 +12578,25 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual)
12575 } 12578 }
12576 12579
12577 /* 12580 /*
12581 * If L1 had a pending IRQ/NMI until it executed
12582 * VMLAUNCH/VMRESUME which wasn't delivered because it was
12583 * disallowed (e.g. interrupts disabled), L0 needs to
12584 * evaluate if this pending event should cause an exit from L2
12585 * to L1 or delivered directly to L2 (e.g. In case L1 don't
12586 * intercept EXTERNAL_INTERRUPT).
12587 *
12588 * Usually this would be handled by L0 requesting a
12589 * IRQ/NMI window by setting VMCS accordingly. However,
12590 * this setting was done on VMCS01 and now VMCS02 is active
12591 * instead. Thus, we force L0 to perform pending event
12592 * evaluation by requesting a KVM_REQ_EVENT.
12593 */
12594 if (vmcs01_cpu_exec_ctrl &
12595 (CPU_BASED_VIRTUAL_INTR_PENDING | CPU_BASED_VIRTUAL_NMI_PENDING)) {
12596 kvm_make_request(KVM_REQ_EVENT, vcpu);
12597 }
12598
12599 /*
12578 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point 12600 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point
12579 * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet 12601 * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet
12580 * returned as far as L1 is concerned. It will only return (and set 12602 * returned as far as L1 is concerned. It will only return (and set
@@ -13988,9 +14010,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
13988 check_vmentry_postreqs(vcpu, vmcs12, &exit_qual)) 14010 check_vmentry_postreqs(vcpu, vmcs12, &exit_qual))
13989 return -EINVAL; 14011 return -EINVAL;
13990 14012
13991 if (kvm_state->flags & KVM_STATE_NESTED_RUN_PENDING)
13992 vmx->nested.nested_run_pending = 1;
13993
13994 vmx->nested.dirty_vmcs12 = true; 14013 vmx->nested.dirty_vmcs12 = true;
13995 ret = enter_vmx_non_root_mode(vcpu, NULL); 14014 ret = enter_vmx_non_root_mode(vcpu, NULL);
13996 if (ret) 14015 if (ret)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 506bd2b4b8bb..542f6315444d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4987,7 +4987,7 @@ int handle_ud(struct kvm_vcpu *vcpu)
4987 emul_type = 0; 4987 emul_type = 0;
4988 } 4988 }
4989 4989
4990 er = emulate_instruction(vcpu, emul_type); 4990 er = kvm_emulate_instruction(vcpu, emul_type);
4991 if (er == EMULATE_USER_EXIT) 4991 if (er == EMULATE_USER_EXIT)
4992 return 0; 4992 return 0;
4993 if (er != EMULATE_DONE) 4993 if (er != EMULATE_DONE)
@@ -5870,7 +5870,10 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2,
5870 gpa_t gpa = cr2; 5870 gpa_t gpa = cr2;
5871 kvm_pfn_t pfn; 5871 kvm_pfn_t pfn;
5872 5872
5873 if (emulation_type & EMULTYPE_NO_REEXECUTE) 5873 if (!(emulation_type & EMULTYPE_ALLOW_RETRY))
5874 return false;
5875
5876 if (WARN_ON_ONCE(is_guest_mode(vcpu)))
5874 return false; 5877 return false;
5875 5878
5876 if (!vcpu->arch.mmu.direct_map) { 5879 if (!vcpu->arch.mmu.direct_map) {
@@ -5958,7 +5961,10 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt,
5958 */ 5961 */
5959 vcpu->arch.last_retry_eip = vcpu->arch.last_retry_addr = 0; 5962 vcpu->arch.last_retry_eip = vcpu->arch.last_retry_addr = 0;
5960 5963
5961 if (!(emulation_type & EMULTYPE_RETRY)) 5964 if (!(emulation_type & EMULTYPE_ALLOW_RETRY))
5965 return false;
5966
5967 if (WARN_ON_ONCE(is_guest_mode(vcpu)))
5962 return false; 5968 return false;
5963 5969
5964 if (x86_page_table_writing_insn(ctxt)) 5970 if (x86_page_table_writing_insn(ctxt))
@@ -6276,7 +6282,19 @@ restart:
6276 6282
6277 return r; 6283 return r;
6278} 6284}
6279EXPORT_SYMBOL_GPL(x86_emulate_instruction); 6285
6286int kvm_emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type)
6287{
6288 return x86_emulate_instruction(vcpu, 0, emulation_type, NULL, 0);
6289}
6290EXPORT_SYMBOL_GPL(kvm_emulate_instruction);
6291
6292int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
6293 void *insn, int insn_len)
6294{
6295 return x86_emulate_instruction(vcpu, 0, 0, insn, insn_len);
6296}
6297EXPORT_SYMBOL_GPL(kvm_emulate_instruction_from_buffer);
6280 6298
6281static int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, 6299static int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size,
6282 unsigned short port) 6300 unsigned short port)
@@ -7734,7 +7752,7 @@ static inline int complete_emulated_io(struct kvm_vcpu *vcpu)
7734{ 7752{
7735 int r; 7753 int r;
7736 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); 7754 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
7737 r = emulate_instruction(vcpu, EMULTYPE_NO_DECODE); 7755 r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE);
7738 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); 7756 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
7739 if (r != EMULATE_DONE) 7757 if (r != EMULATE_DONE)
7740 return 0; 7758 return 0;
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 257f27620bc2..67b9568613f3 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -274,6 +274,8 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata);
274bool kvm_mtrr_check_gfn_range_consistency(struct kvm_vcpu *vcpu, gfn_t gfn, 274bool kvm_mtrr_check_gfn_range_consistency(struct kvm_vcpu *vcpu, gfn_t gfn,
275 int page_num); 275 int page_num);
276bool kvm_vector_hashing_enabled(void); 276bool kvm_vector_hashing_enabled(void);
277int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,
278 int emulation_type, void *insn, int insn_len);
277 279
278#define KVM_SUPPORTED_XCR0 (XFEATURE_MASK_FP | XFEATURE_MASK_SSE \ 280#define KVM_SUPPORTED_XCR0 (XFEATURE_MASK_FP | XFEATURE_MASK_SSE \
279 | XFEATURE_MASK_YMM | XFEATURE_MASK_BNDREGS \ 281 | XFEATURE_MASK_YMM | XFEATURE_MASK_BNDREGS \
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index e848a4811785..ae394552fb94 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -269,7 +269,7 @@ static void mop_up_one_pmd(struct mm_struct *mm, pgd_t *pgdp)
269 if (pgd_val(pgd) != 0) { 269 if (pgd_val(pgd) != 0) {
270 pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd); 270 pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
271 271
272 *pgdp = native_make_pgd(0); 272 pgd_clear(pgdp);
273 273
274 paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT); 274 paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
275 pmd_free(mm, pmd); 275 pmd_free(mm, pmd);
@@ -494,7 +494,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma,
494 int changed = !pte_same(*ptep, entry); 494 int changed = !pte_same(*ptep, entry);
495 495
496 if (changed && dirty) 496 if (changed && dirty)
497 *ptep = entry; 497 set_pte(ptep, entry);
498 498
499 return changed; 499 return changed;
500} 500}
@@ -509,7 +509,7 @@ int pmdp_set_access_flags(struct vm_area_struct *vma,
509 VM_BUG_ON(address & ~HPAGE_PMD_MASK); 509 VM_BUG_ON(address & ~HPAGE_PMD_MASK);
510 510
511 if (changed && dirty) { 511 if (changed && dirty) {
512 *pmdp = entry; 512 set_pmd(pmdp, entry);
513 /* 513 /*
514 * We had a write-protection fault here and changed the pmd 514 * We had a write-protection fault here and changed the pmd
515 * to to more permissive. No need to flush the TLB for that, 515 * to to more permissive. No need to flush the TLB for that,
@@ -529,7 +529,7 @@ int pudp_set_access_flags(struct vm_area_struct *vma, unsigned long address,
529 VM_BUG_ON(address & ~HPAGE_PUD_MASK); 529 VM_BUG_ON(address & ~HPAGE_PUD_MASK);
530 530
531 if (changed && dirty) { 531 if (changed && dirty) {
532 *pudp = entry; 532 set_pud(pudp, entry);
533 /* 533 /*
534 * We had a write-protection fault here and changed the pud 534 * We had a write-protection fault here and changed the pud
535 * to to more permissive. No need to flush the TLB for that, 535 * to to more permissive. No need to flush the TLB for that,
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index 58c6efa9f9a9..9fe5952d117d 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -275,9 +275,9 @@ static void bfqg_and_blkg_get(struct bfq_group *bfqg)
275 275
276void bfqg_and_blkg_put(struct bfq_group *bfqg) 276void bfqg_and_blkg_put(struct bfq_group *bfqg)
277{ 277{
278 bfqg_put(bfqg);
279
280 blkg_put(bfqg_to_blkg(bfqg)); 278 blkg_put(bfqg_to_blkg(bfqg));
279
280 bfqg_put(bfqg);
281} 281}
282 282
283/* @stats = 0 */ 283/* @stats = 0 */
diff --git a/block/bio.c b/block/bio.c
index b12966e415d3..8c680a776171 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2015,7 +2015,8 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg)
2015{ 2015{
2016 if (unlikely(bio->bi_blkg)) 2016 if (unlikely(bio->bi_blkg))
2017 return -EBUSY; 2017 return -EBUSY;
2018 blkg_get(blkg); 2018 if (!blkg_try_get(blkg))
2019 return -ENODEV;
2019 bio->bi_blkg = blkg; 2020 bio->bi_blkg = blkg;
2020 return 0; 2021 return 0;
2021} 2022}
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 694595b29b8f..c19f9078da1e 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -310,28 +310,11 @@ struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
310 } 310 }
311} 311}
312 312
313static void blkg_pd_offline(struct blkcg_gq *blkg)
314{
315 int i;
316
317 lockdep_assert_held(blkg->q->queue_lock);
318 lockdep_assert_held(&blkg->blkcg->lock);
319
320 for (i = 0; i < BLKCG_MAX_POLS; i++) {
321 struct blkcg_policy *pol = blkcg_policy[i];
322
323 if (blkg->pd[i] && !blkg->pd[i]->offline &&
324 pol->pd_offline_fn) {
325 pol->pd_offline_fn(blkg->pd[i]);
326 blkg->pd[i]->offline = true;
327 }
328 }
329}
330
331static void blkg_destroy(struct blkcg_gq *blkg) 313static void blkg_destroy(struct blkcg_gq *blkg)
332{ 314{
333 struct blkcg *blkcg = blkg->blkcg; 315 struct blkcg *blkcg = blkg->blkcg;
334 struct blkcg_gq *parent = blkg->parent; 316 struct blkcg_gq *parent = blkg->parent;
317 int i;
335 318
336 lockdep_assert_held(blkg->q->queue_lock); 319 lockdep_assert_held(blkg->q->queue_lock);
337 lockdep_assert_held(&blkcg->lock); 320 lockdep_assert_held(&blkcg->lock);
@@ -340,6 +323,13 @@ static void blkg_destroy(struct blkcg_gq *blkg)
340 WARN_ON_ONCE(list_empty(&blkg->q_node)); 323 WARN_ON_ONCE(list_empty(&blkg->q_node));
341 WARN_ON_ONCE(hlist_unhashed(&blkg->blkcg_node)); 324 WARN_ON_ONCE(hlist_unhashed(&blkg->blkcg_node));
342 325
326 for (i = 0; i < BLKCG_MAX_POLS; i++) {
327 struct blkcg_policy *pol = blkcg_policy[i];
328
329 if (blkg->pd[i] && pol->pd_offline_fn)
330 pol->pd_offline_fn(blkg->pd[i]);
331 }
332
343 if (parent) { 333 if (parent) {
344 blkg_rwstat_add_aux(&parent->stat_bytes, &blkg->stat_bytes); 334 blkg_rwstat_add_aux(&parent->stat_bytes, &blkg->stat_bytes);
345 blkg_rwstat_add_aux(&parent->stat_ios, &blkg->stat_ios); 335 blkg_rwstat_add_aux(&parent->stat_ios, &blkg->stat_ios);
@@ -382,7 +372,6 @@ static void blkg_destroy_all(struct request_queue *q)
382 struct blkcg *blkcg = blkg->blkcg; 372 struct blkcg *blkcg = blkg->blkcg;
383 373
384 spin_lock(&blkcg->lock); 374 spin_lock(&blkcg->lock);
385 blkg_pd_offline(blkg);
386 blkg_destroy(blkg); 375 blkg_destroy(blkg);
387 spin_unlock(&blkcg->lock); 376 spin_unlock(&blkcg->lock);
388 } 377 }
@@ -1053,59 +1042,64 @@ static struct cftype blkcg_legacy_files[] = {
1053 { } /* terminate */ 1042 { } /* terminate */
1054}; 1043};
1055 1044
1045/*
1046 * blkcg destruction is a three-stage process.
1047 *
1048 * 1. Destruction starts. The blkcg_css_offline() callback is invoked
1049 * which offlines writeback. Here we tie the next stage of blkg destruction
1050 * to the completion of writeback associated with the blkcg. This lets us
1051 * avoid punting potentially large amounts of outstanding writeback to root
1052 * while maintaining any ongoing policies. The next stage is triggered when
1053 * the nr_cgwbs count goes to zero.
1054 *
1055 * 2. When the nr_cgwbs count goes to zero, blkcg_destroy_blkgs() is called
1056 * and handles the destruction of blkgs. Here the css reference held by
1057 * the blkg is put back eventually allowing blkcg_css_free() to be called.
1058 * This work may occur in cgwb_release_workfn() on the cgwb_release
1059 * workqueue. Any submitted ios that fail to get the blkg ref will be
1060 * punted to the root_blkg.
1061 *
1062 * 3. Once the blkcg ref count goes to zero, blkcg_css_free() is called.
1063 * This finally frees the blkcg.
1064 */
1065
1056/** 1066/**
1057 * blkcg_css_offline - cgroup css_offline callback 1067 * blkcg_css_offline - cgroup css_offline callback
1058 * @css: css of interest 1068 * @css: css of interest
1059 * 1069 *
1060 * This function is called when @css is about to go away and responsible 1070 * This function is called when @css is about to go away. Here the cgwbs are
1061 * for offlining all blkgs pd and killing all wbs associated with @css. 1071 * offlined first and only once writeback associated with the blkcg has
1062 * blkgs pd offline should be done while holding both q and blkcg locks. 1072 * finished do we start step 2 (see above).
1063 * As blkcg lock is nested inside q lock, this function performs reverse
1064 * double lock dancing.
1065 *
1066 * This is the blkcg counterpart of ioc_release_fn().
1067 */ 1073 */
1068static void blkcg_css_offline(struct cgroup_subsys_state *css) 1074static void blkcg_css_offline(struct cgroup_subsys_state *css)
1069{ 1075{
1070 struct blkcg *blkcg = css_to_blkcg(css); 1076 struct blkcg *blkcg = css_to_blkcg(css);
1071 struct blkcg_gq *blkg;
1072
1073 spin_lock_irq(&blkcg->lock);
1074
1075 hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) {
1076 struct request_queue *q = blkg->q;
1077
1078 if (spin_trylock(q->queue_lock)) {
1079 blkg_pd_offline(blkg);
1080 spin_unlock(q->queue_lock);
1081 } else {
1082 spin_unlock_irq(&blkcg->lock);
1083 cpu_relax();
1084 spin_lock_irq(&blkcg->lock);
1085 }
1086 }
1087
1088 spin_unlock_irq(&blkcg->lock);
1089 1077
1078 /* this prevents anyone from attaching or migrating to this blkcg */
1090 wb_blkcg_offline(blkcg); 1079 wb_blkcg_offline(blkcg);
1080
1081 /* put the base cgwb reference allowing step 2 to be triggered */
1082 blkcg_cgwb_put(blkcg);
1091} 1083}
1092 1084
1093/** 1085/**
1094 * blkcg_destroy_all_blkgs - destroy all blkgs associated with a blkcg 1086 * blkcg_destroy_blkgs - responsible for shooting down blkgs
1095 * @blkcg: blkcg of interest 1087 * @blkcg: blkcg of interest
1096 * 1088 *
1097 * This function is called when blkcg css is about to free and responsible for 1089 * blkgs should be removed while holding both q and blkcg locks. As blkcg lock
1098 * destroying all blkgs associated with @blkcg.
1099 * blkgs should be removed while holding both q and blkcg locks. As blkcg lock
1100 * is nested inside q lock, this function performs reverse double lock dancing. 1090 * is nested inside q lock, this function performs reverse double lock dancing.
1091 * Destroying the blkgs releases the reference held on the blkcg's css allowing
1092 * blkcg_css_free to eventually be called.
1093 *
1094 * This is the blkcg counterpart of ioc_release_fn().
1101 */ 1095 */
1102static void blkcg_destroy_all_blkgs(struct blkcg *blkcg) 1096void blkcg_destroy_blkgs(struct blkcg *blkcg)
1103{ 1097{
1104 spin_lock_irq(&blkcg->lock); 1098 spin_lock_irq(&blkcg->lock);
1099
1105 while (!hlist_empty(&blkcg->blkg_list)) { 1100 while (!hlist_empty(&blkcg->blkg_list)) {
1106 struct blkcg_gq *blkg = hlist_entry(blkcg->blkg_list.first, 1101 struct blkcg_gq *blkg = hlist_entry(blkcg->blkg_list.first,
1107 struct blkcg_gq, 1102 struct blkcg_gq, blkcg_node);
1108 blkcg_node);
1109 struct request_queue *q = blkg->q; 1103 struct request_queue *q = blkg->q;
1110 1104
1111 if (spin_trylock(q->queue_lock)) { 1105 if (spin_trylock(q->queue_lock)) {
@@ -1117,6 +1111,7 @@ static void blkcg_destroy_all_blkgs(struct blkcg *blkcg)
1117 spin_lock_irq(&blkcg->lock); 1111 spin_lock_irq(&blkcg->lock);
1118 } 1112 }
1119 } 1113 }
1114
1120 spin_unlock_irq(&blkcg->lock); 1115 spin_unlock_irq(&blkcg->lock);
1121} 1116}
1122 1117
@@ -1125,8 +1120,6 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
1125 struct blkcg *blkcg = css_to_blkcg(css); 1120 struct blkcg *blkcg = css_to_blkcg(css);
1126 int i; 1121 int i;
1127 1122
1128 blkcg_destroy_all_blkgs(blkcg);
1129
1130 mutex_lock(&blkcg_pol_mutex); 1123 mutex_lock(&blkcg_pol_mutex);
1131 1124
1132 list_del(&blkcg->all_blkcgs_node); 1125 list_del(&blkcg->all_blkcgs_node);
@@ -1189,6 +1182,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
1189 INIT_HLIST_HEAD(&blkcg->blkg_list); 1182 INIT_HLIST_HEAD(&blkcg->blkg_list);
1190#ifdef CONFIG_CGROUP_WRITEBACK 1183#ifdef CONFIG_CGROUP_WRITEBACK
1191 INIT_LIST_HEAD(&blkcg->cgwb_list); 1184 INIT_LIST_HEAD(&blkcg->cgwb_list);
1185 refcount_set(&blkcg->cgwb_refcnt, 1);
1192#endif 1186#endif
1193 list_add_tail(&blkcg->all_blkcgs_node, &all_blkcgs); 1187 list_add_tail(&blkcg->all_blkcgs_node, &all_blkcgs);
1194 1188
@@ -1480,11 +1474,8 @@ void blkcg_deactivate_policy(struct request_queue *q,
1480 1474
1481 list_for_each_entry(blkg, &q->blkg_list, q_node) { 1475 list_for_each_entry(blkg, &q->blkg_list, q_node) {
1482 if (blkg->pd[pol->plid]) { 1476 if (blkg->pd[pol->plid]) {
1483 if (!blkg->pd[pol->plid]->offline && 1477 if (pol->pd_offline_fn)
1484 pol->pd_offline_fn) {
1485 pol->pd_offline_fn(blkg->pd[pol->plid]); 1478 pol->pd_offline_fn(blkg->pd[pol->plid]);
1486 blkg->pd[pol->plid]->offline = true;
1487 }
1488 pol->pd_free_fn(blkg->pd[pol->plid]); 1479 pol->pd_free_fn(blkg->pd[pol->plid]);
1489 blkg->pd[pol->plid] = NULL; 1480 blkg->pd[pol->plid] = NULL;
1490 } 1481 }
diff --git a/block/blk-core.c b/block/blk-core.c
index dee56c282efb..4dbc93f43b38 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2163,9 +2163,12 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
2163{ 2163{
2164 const int op = bio_op(bio); 2164 const int op = bio_op(bio);
2165 2165
2166 if (part->policy && (op_is_write(op) && !op_is_flush(op))) { 2166 if (part->policy && op_is_write(op)) {
2167 char b[BDEVNAME_SIZE]; 2167 char b[BDEVNAME_SIZE];
2168 2168
2169 if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
2170 return false;
2171
2169 WARN_ONCE(1, 2172 WARN_ONCE(1,
2170 "generic_make_request: Trying to write " 2173 "generic_make_request: Trying to write "
2171 "to read-only block-device %s (partno %d)\n", 2174 "to read-only block-device %s (partno %d)\n",
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index a3eede00d302..01d0620a4e4a 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -2129,8 +2129,9 @@ static inline void throtl_update_latency_buckets(struct throtl_data *td)
2129static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio) 2129static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio)
2130{ 2130{
2131#ifdef CONFIG_BLK_DEV_THROTTLING_LOW 2131#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
2132 if (bio->bi_css) 2132 /* fallback to root_blkg if we fail to get a blkg ref */
2133 bio_associate_blkg(bio, tg_to_blkg(tg)); 2133 if (bio->bi_css && (bio_associate_blkg(bio, tg_to_blkg(tg)) == -ENODEV))
2134 bio_associate_blkg(bio, bio->bi_disk->queue->root_blkg);
2134 bio_issue_init(&bio->bi_issue, bio_sectors(bio)); 2135 bio_issue_init(&bio->bi_issue, bio_sectors(bio));
2135#endif 2136#endif
2136} 2137}
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 9706613eecf9..bf64cfa30feb 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -879,7 +879,7 @@ static void acpi_lpss_dismiss(struct device *dev)
879#define LPSS_GPIODEF0_DMA_LLP BIT(13) 879#define LPSS_GPIODEF0_DMA_LLP BIT(13)
880 880
881static DEFINE_MUTEX(lpss_iosf_mutex); 881static DEFINE_MUTEX(lpss_iosf_mutex);
882static bool lpss_iosf_d3_entered; 882static bool lpss_iosf_d3_entered = true;
883 883
884static void lpss_iosf_enter_d3_state(void) 884static void lpss_iosf_enter_d3_state(void)
885{ 885{
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 292088fcc624..d2e29a19890d 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -35,11 +35,11 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#ifdef CONFIG_X86 36#ifdef CONFIG_X86
37#include <asm/mpspec.h> 37#include <asm/mpspec.h>
38#include <linux/dmi.h>
38#endif 39#endif
39#include <linux/acpi_iort.h> 40#include <linux/acpi_iort.h>
40#include <linux/pci.h> 41#include <linux/pci.h>
41#include <acpi/apei.h> 42#include <acpi/apei.h>
42#include <linux/dmi.h>
43#include <linux/suspend.h> 43#include <linux/suspend.h>
44 44
45#include "internal.h" 45#include "internal.h"
@@ -82,10 +82,6 @@ static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
82 }, 82 },
83 {} 83 {}
84}; 84};
85#else
86static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
87 {}
88};
89#endif 85#endif
90 86
91/* -------------------------------------------------------------------------- 87/* --------------------------------------------------------------------------
@@ -1033,11 +1029,16 @@ void __init acpi_early_init(void)
1033 1029
1034 acpi_permanent_mmap = true; 1030 acpi_permanent_mmap = true;
1035 1031
1032#ifdef CONFIG_X86
1036 /* 1033 /*
1037 * If the machine falls into the DMI check table, 1034 * If the machine falls into the DMI check table,
1038 * DSDT will be copied to memory 1035 * DSDT will be copied to memory.
1036 * Note that calling dmi_check_system() here on other architectures
1037 * would not be OK because only x86 initializes dmi early enough.
1038 * Thankfully only x86 systems need such quirks for now.
1039 */ 1039 */
1040 dmi_check_system(dsdt_dmi_table); 1040 dmi_check_system(dsdt_dmi_table);
1041#endif
1041 1042
1042 status = acpi_reallocate_root_table(); 1043 status = acpi_reallocate_root_table();
1043 if (ACPI_FAILURE(status)) { 1044 if (ACPI_FAILURE(status)) {
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 172e32840256..599e01bcdef2 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -7394,4 +7394,4 @@ EXPORT_SYMBOL_GPL(ata_cable_unknown);
7394EXPORT_SYMBOL_GPL(ata_cable_ignore); 7394EXPORT_SYMBOL_GPL(ata_cable_ignore);
7395EXPORT_SYMBOL_GPL(ata_cable_sata); 7395EXPORT_SYMBOL_GPL(ata_cable_sata);
7396EXPORT_SYMBOL_GPL(ata_host_get); 7396EXPORT_SYMBOL_GPL(ata_host_get);
7397EXPORT_SYMBOL_GPL(ata_host_put); \ No newline at end of file 7397EXPORT_SYMBOL_GPL(ata_host_put);
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index c8a1cb0b6136..817320c7c4c1 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -417,25 +417,23 @@ static ssize_t show_valid_zones(struct device *dev,
417 int nid; 417 int nid;
418 418
419 /* 419 /*
420 * The block contains more than one zone can not be offlined.
421 * This can happen e.g. for ZONE_DMA and ZONE_DMA32
422 */
423 if (!test_pages_in_a_zone(start_pfn, start_pfn + nr_pages, &valid_start_pfn, &valid_end_pfn))
424 return sprintf(buf, "none\n");
425
426 start_pfn = valid_start_pfn;
427 nr_pages = valid_end_pfn - start_pfn;
428
429 /*
430 * Check the existing zone. Make sure that we do that only on the 420 * Check the existing zone. Make sure that we do that only on the
431 * online nodes otherwise the page_zone is not reliable 421 * online nodes otherwise the page_zone is not reliable
432 */ 422 */
433 if (mem->state == MEM_ONLINE) { 423 if (mem->state == MEM_ONLINE) {
424 /*
425 * The block contains more than one zone can not be offlined.
426 * This can happen e.g. for ZONE_DMA and ZONE_DMA32
427 */
428 if (!test_pages_in_a_zone(start_pfn, start_pfn + nr_pages,
429 &valid_start_pfn, &valid_end_pfn))
430 return sprintf(buf, "none\n");
431 start_pfn = valid_start_pfn;
434 strcat(buf, page_zone(pfn_to_page(start_pfn))->name); 432 strcat(buf, page_zone(pfn_to_page(start_pfn))->name);
435 goto out; 433 goto out;
436 } 434 }
437 435
438 nid = pfn_to_nid(start_pfn); 436 nid = mem->nid;
439 default_zone = zone_for_pfn_range(MMOP_ONLINE_KEEP, nid, start_pfn, nr_pages); 437 default_zone = zone_for_pfn_range(MMOP_ONLINE_KEEP, nid, start_pfn, nr_pages);
440 strcat(buf, default_zone->name); 438 strcat(buf, default_zone->name);
441 439
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3863c00372bb..14a51254c3db 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1239,6 +1239,9 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
1239 case NBD_SET_SOCK: 1239 case NBD_SET_SOCK:
1240 return nbd_add_socket(nbd, arg, false); 1240 return nbd_add_socket(nbd, arg, false);
1241 case NBD_SET_BLKSIZE: 1241 case NBD_SET_BLKSIZE:
1242 if (!arg || !is_power_of_2(arg) || arg < 512 ||
1243 arg > PAGE_SIZE)
1244 return -EINVAL;
1242 nbd_size_set(nbd, arg, 1245 nbd_size_set(nbd, arg,
1243 div_s64(config->bytesize, arg)); 1246 div_s64(config->bytesize, arg));
1244 return 0; 1247 return 0;
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7915f3b03736..73ed5f3a862d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4207,11 +4207,13 @@ static ssize_t rbd_parent_show(struct device *dev,
4207 4207
4208 count += sprintf(&buf[count], "%s" 4208 count += sprintf(&buf[count], "%s"
4209 "pool_id %llu\npool_name %s\n" 4209 "pool_id %llu\npool_name %s\n"
4210 "pool_ns %s\n"
4210 "image_id %s\nimage_name %s\n" 4211 "image_id %s\nimage_name %s\n"
4211 "snap_id %llu\nsnap_name %s\n" 4212 "snap_id %llu\nsnap_name %s\n"
4212 "overlap %llu\n", 4213 "overlap %llu\n",
4213 !count ? "" : "\n", /* first? */ 4214 !count ? "" : "\n", /* first? */
4214 spec->pool_id, spec->pool_name, 4215 spec->pool_id, spec->pool_name,
4216 spec->pool_ns ?: "",
4215 spec->image_id, spec->image_name ?: "(unknown)", 4217 spec->image_id, spec->image_name ?: "(unknown)",
4216 spec->snap_id, spec->snap_name, 4218 spec->snap_id, spec->snap_name,
4217 rbd_dev->parent_overlap); 4219 rbd_dev->parent_overlap);
@@ -4584,47 +4586,177 @@ static int rbd_dev_v2_features(struct rbd_device *rbd_dev)
4584 &rbd_dev->header.features); 4586 &rbd_dev->header.features);
4585} 4587}
4586 4588
4589struct parent_image_info {
4590 u64 pool_id;
4591 const char *pool_ns;
4592 const char *image_id;
4593 u64 snap_id;
4594
4595 bool has_overlap;
4596 u64 overlap;
4597};
4598
4599/*
4600 * The caller is responsible for @pii.
4601 */
4602static int decode_parent_image_spec(void **p, void *end,
4603 struct parent_image_info *pii)
4604{
4605 u8 struct_v;
4606 u32 struct_len;
4607 int ret;
4608
4609 ret = ceph_start_decoding(p, end, 1, "ParentImageSpec",
4610 &struct_v, &struct_len);
4611 if (ret)
4612 return ret;
4613
4614 ceph_decode_64_safe(p, end, pii->pool_id, e_inval);
4615 pii->pool_ns = ceph_extract_encoded_string(p, end, NULL, GFP_KERNEL);
4616 if (IS_ERR(pii->pool_ns)) {
4617 ret = PTR_ERR(pii->pool_ns);
4618 pii->pool_ns = NULL;
4619 return ret;
4620 }
4621 pii->image_id = ceph_extract_encoded_string(p, end, NULL, GFP_KERNEL);
4622 if (IS_ERR(pii->image_id)) {
4623 ret = PTR_ERR(pii->image_id);
4624 pii->image_id = NULL;
4625 return ret;
4626 }
4627 ceph_decode_64_safe(p, end, pii->snap_id, e_inval);
4628 return 0;
4629
4630e_inval:
4631 return -EINVAL;
4632}
4633
4634static int __get_parent_info(struct rbd_device *rbd_dev,
4635 struct page *req_page,
4636 struct page *reply_page,
4637 struct parent_image_info *pii)
4638{
4639 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
4640 size_t reply_len = PAGE_SIZE;
4641 void *p, *end;
4642 int ret;
4643
4644 ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc,
4645 "rbd", "parent_get", CEPH_OSD_FLAG_READ,
4646 req_page, sizeof(u64), reply_page, &reply_len);
4647 if (ret)
4648 return ret == -EOPNOTSUPP ? 1 : ret;
4649
4650 p = page_address(reply_page);
4651 end = p + reply_len;
4652 ret = decode_parent_image_spec(&p, end, pii);
4653 if (ret)
4654 return ret;
4655
4656 ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc,
4657 "rbd", "parent_overlap_get", CEPH_OSD_FLAG_READ,
4658 req_page, sizeof(u64), reply_page, &reply_len);
4659 if (ret)
4660 return ret;
4661
4662 p = page_address(reply_page);
4663 end = p + reply_len;
4664 ceph_decode_8_safe(&p, end, pii->has_overlap, e_inval);
4665 if (pii->has_overlap)
4666 ceph_decode_64_safe(&p, end, pii->overlap, e_inval);
4667
4668 return 0;
4669
4670e_inval:
4671 return -EINVAL;
4672}
4673
4674/*
4675 * The caller is responsible for @pii.
4676 */
4677static int __get_parent_info_legacy(struct rbd_device *rbd_dev,
4678 struct page *req_page,
4679 struct page *reply_page,
4680 struct parent_image_info *pii)
4681{
4682 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
4683 size_t reply_len = PAGE_SIZE;
4684 void *p, *end;
4685 int ret;
4686
4687 ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc,
4688 "rbd", "get_parent", CEPH_OSD_FLAG_READ,
4689 req_page, sizeof(u64), reply_page, &reply_len);
4690 if (ret)
4691 return ret;
4692
4693 p = page_address(reply_page);
4694 end = p + reply_len;
4695 ceph_decode_64_safe(&p, end, pii->pool_id, e_inval);
4696 pii->image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
4697 if (IS_ERR(pii->image_id)) {
4698 ret = PTR_ERR(pii->image_id);
4699 pii->image_id = NULL;
4700 return ret;
4701 }
4702 ceph_decode_64_safe(&p, end, pii->snap_id, e_inval);
4703 pii->has_overlap = true;
4704 ceph_decode_64_safe(&p, end, pii->overlap, e_inval);
4705
4706 return 0;
4707
4708e_inval:
4709 return -EINVAL;
4710}
4711
4712static int get_parent_info(struct rbd_device *rbd_dev,
4713 struct parent_image_info *pii)
4714{
4715 struct page *req_page, *reply_page;
4716 void *p;
4717 int ret;
4718
4719 req_page = alloc_page(GFP_KERNEL);
4720 if (!req_page)
4721 return -ENOMEM;
4722
4723 reply_page = alloc_page(GFP_KERNEL);
4724 if (!reply_page) {
4725 __free_page(req_page);
4726 return -ENOMEM;
4727 }
4728
4729 p = page_address(req_page);
4730 ceph_encode_64(&p, rbd_dev->spec->snap_id);
4731 ret = __get_parent_info(rbd_dev, req_page, reply_page, pii);
4732 if (ret > 0)
4733 ret = __get_parent_info_legacy(rbd_dev, req_page, reply_page,
4734 pii);
4735
4736 __free_page(req_page);
4737 __free_page(reply_page);
4738 return ret;
4739}
4740
4587static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) 4741static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
4588{ 4742{
4589 struct rbd_spec *parent_spec; 4743 struct rbd_spec *parent_spec;
4590 size_t size; 4744 struct parent_image_info pii = { 0 };
4591 void *reply_buf = NULL;
4592 __le64 snapid;
4593 void *p;
4594 void *end;
4595 u64 pool_id;
4596 char *image_id;
4597 u64 snap_id;
4598 u64 overlap;
4599 int ret; 4745 int ret;
4600 4746
4601 parent_spec = rbd_spec_alloc(); 4747 parent_spec = rbd_spec_alloc();
4602 if (!parent_spec) 4748 if (!parent_spec)
4603 return -ENOMEM; 4749 return -ENOMEM;
4604 4750
4605 size = sizeof (__le64) + /* pool_id */ 4751 ret = get_parent_info(rbd_dev, &pii);
4606 sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX + /* image_id */ 4752 if (ret)
4607 sizeof (__le64) + /* snap_id */
4608 sizeof (__le64); /* overlap */
4609 reply_buf = kmalloc(size, GFP_KERNEL);
4610 if (!reply_buf) {
4611 ret = -ENOMEM;
4612 goto out_err; 4753 goto out_err;
4613 }
4614 4754
4615 snapid = cpu_to_le64(rbd_dev->spec->snap_id); 4755 dout("%s pool_id %llu pool_ns %s image_id %s snap_id %llu has_overlap %d overlap %llu\n",
4616 ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, 4756 __func__, pii.pool_id, pii.pool_ns, pii.image_id, pii.snap_id,
4617 &rbd_dev->header_oloc, "get_parent", 4757 pii.has_overlap, pii.overlap);
4618 &snapid, sizeof(snapid), reply_buf, size);
4619 dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
4620 if (ret < 0)
4621 goto out_err;
4622 4758
4623 p = reply_buf; 4759 if (pii.pool_id == CEPH_NOPOOL || !pii.has_overlap) {
4624 end = reply_buf + ret;
4625 ret = -ERANGE;
4626 ceph_decode_64_safe(&p, end, pool_id, out_err);
4627 if (pool_id == CEPH_NOPOOL) {
4628 /* 4760 /*
4629 * Either the parent never existed, or we have 4761 * Either the parent never existed, or we have
4630 * record of it but the image got flattened so it no 4762 * record of it but the image got flattened so it no
@@ -4633,6 +4765,10 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
4633 * overlap to 0. The effect of this is that all new 4765 * overlap to 0. The effect of this is that all new
4634 * requests will be treated as if the image had no 4766 * requests will be treated as if the image had no
4635 * parent. 4767 * parent.
4768 *
4769 * If !pii.has_overlap, the parent image spec is not
4770 * applicable. It's there to avoid duplication in each
4771 * snapshot record.
4636 */ 4772 */
4637 if (rbd_dev->parent_overlap) { 4773 if (rbd_dev->parent_overlap) {
4638 rbd_dev->parent_overlap = 0; 4774 rbd_dev->parent_overlap = 0;
@@ -4647,51 +4783,36 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
4647 /* The ceph file layout needs to fit pool id in 32 bits */ 4783 /* The ceph file layout needs to fit pool id in 32 bits */
4648 4784
4649 ret = -EIO; 4785 ret = -EIO;
4650 if (pool_id > (u64)U32_MAX) { 4786 if (pii.pool_id > (u64)U32_MAX) {
4651 rbd_warn(NULL, "parent pool id too large (%llu > %u)", 4787 rbd_warn(NULL, "parent pool id too large (%llu > %u)",
4652 (unsigned long long)pool_id, U32_MAX); 4788 (unsigned long long)pii.pool_id, U32_MAX);
4653 goto out_err; 4789 goto out_err;
4654 } 4790 }
4655 4791
4656 image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
4657 if (IS_ERR(image_id)) {
4658 ret = PTR_ERR(image_id);
4659 goto out_err;
4660 }
4661 ceph_decode_64_safe(&p, end, snap_id, out_err);
4662 ceph_decode_64_safe(&p, end, overlap, out_err);
4663
4664 /* 4792 /*
4665 * The parent won't change (except when the clone is 4793 * The parent won't change (except when the clone is
4666 * flattened, already handled that). So we only need to 4794 * flattened, already handled that). So we only need to
4667 * record the parent spec we have not already done so. 4795 * record the parent spec we have not already done so.
4668 */ 4796 */
4669 if (!rbd_dev->parent_spec) { 4797 if (!rbd_dev->parent_spec) {
4670 parent_spec->pool_id = pool_id; 4798 parent_spec->pool_id = pii.pool_id;
4671 parent_spec->image_id = image_id; 4799 if (pii.pool_ns && *pii.pool_ns) {
4672 parent_spec->snap_id = snap_id; 4800 parent_spec->pool_ns = pii.pool_ns;
4673 4801 pii.pool_ns = NULL;
4674 /* TODO: support cloning across namespaces */
4675 if (rbd_dev->spec->pool_ns) {
4676 parent_spec->pool_ns = kstrdup(rbd_dev->spec->pool_ns,
4677 GFP_KERNEL);
4678 if (!parent_spec->pool_ns) {
4679 ret = -ENOMEM;
4680 goto out_err;
4681 }
4682 } 4802 }
4803 parent_spec->image_id = pii.image_id;
4804 pii.image_id = NULL;
4805 parent_spec->snap_id = pii.snap_id;
4683 4806
4684 rbd_dev->parent_spec = parent_spec; 4807 rbd_dev->parent_spec = parent_spec;
4685 parent_spec = NULL; /* rbd_dev now owns this */ 4808 parent_spec = NULL; /* rbd_dev now owns this */
4686 } else {
4687 kfree(image_id);
4688 } 4809 }
4689 4810
4690 /* 4811 /*
4691 * We always update the parent overlap. If it's zero we issue 4812 * We always update the parent overlap. If it's zero we issue
4692 * a warning, as we will proceed as if there was no parent. 4813 * a warning, as we will proceed as if there was no parent.
4693 */ 4814 */
4694 if (!overlap) { 4815 if (!pii.overlap) {
4695 if (parent_spec) { 4816 if (parent_spec) {
4696 /* refresh, careful to warn just once */ 4817 /* refresh, careful to warn just once */
4697 if (rbd_dev->parent_overlap) 4818 if (rbd_dev->parent_overlap)
@@ -4702,14 +4823,14 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
4702 rbd_warn(rbd_dev, "clone is standalone (overlap 0)"); 4823 rbd_warn(rbd_dev, "clone is standalone (overlap 0)");
4703 } 4824 }
4704 } 4825 }
4705 rbd_dev->parent_overlap = overlap; 4826 rbd_dev->parent_overlap = pii.overlap;
4706 4827
4707out: 4828out:
4708 ret = 0; 4829 ret = 0;
4709out_err: 4830out_err:
4710 kfree(reply_buf); 4831 kfree(pii.pool_ns);
4832 kfree(pii.image_id);
4711 rbd_spec_put(parent_spec); 4833 rbd_spec_put(parent_spec);
4712
4713 return ret; 4834 return ret;
4714} 4835}
4715 4836
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index ce277ee0a28a..40728491f37b 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -566,5 +566,5 @@ config RANDOM_TRUST_CPU
566 that CPU manufacturer (perhaps with the insistence or mandate 566 that CPU manufacturer (perhaps with the insistence or mandate
567 of a Nation State's intelligence or law enforcement agencies) 567 of a Nation State's intelligence or law enforcement agencies)
568 has not installed a hidden back door to compromise the CPU's 568 has not installed a hidden back door to compromise the CPU's
569 random number generation facilities. 569 random number generation facilities. This can also be configured
570 570 at boot with "random.trust_cpu=on/off".
diff --git a/drivers/char/random.c b/drivers/char/random.c
index bf5f99fc36f1..c75b6cdf0053 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly;
779 779
780static void invalidate_batched_entropy(void); 780static void invalidate_batched_entropy(void);
781 781
782static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
783static int __init parse_trust_cpu(char *arg)
784{
785 return kstrtobool(arg, &trust_cpu);
786}
787early_param("random.trust_cpu", parse_trust_cpu);
788
782static void crng_initialize(struct crng_state *crng) 789static void crng_initialize(struct crng_state *crng)
783{ 790{
784 int i; 791 int i;
@@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng)
799 } 806 }
800 crng->state[i] ^= rv; 807 crng->state[i] ^= rv;
801 } 808 }
802#ifdef CONFIG_RANDOM_TRUST_CPU 809 if (trust_cpu && arch_init) {
803 if (arch_init) {
804 crng_init = 2; 810 crng_init = 2;
805 pr_notice("random: crng done (trusting CPU's manufacturer)\n"); 811 pr_notice("random: crng done (trusting CPU's manufacturer)\n");
806 } 812 }
807#endif
808 crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; 813 crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
809} 814}
810 815
diff --git a/drivers/dax/device.c b/drivers/dax/device.c
index 6fd46083e629..bbe4d72ca105 100644
--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@ -392,7 +392,8 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf,
392{ 392{
393 struct file *filp = vmf->vma->vm_file; 393 struct file *filp = vmf->vma->vm_file;
394 unsigned long fault_size; 394 unsigned long fault_size;
395 int rc, id; 395 vm_fault_t rc = VM_FAULT_SIGBUS;
396 int id;
396 pfn_t pfn; 397 pfn_t pfn;
397 struct dev_dax *dev_dax = filp->private_data; 398 struct dev_dax *dev_dax = filp->private_data;
398 399
diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index 721e6c57beae..64342944d917 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -166,7 +166,13 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
166 le32_to_cpu(attr->sustained_freq_khz); 166 le32_to_cpu(attr->sustained_freq_khz);
167 dom_info->sustained_perf_level = 167 dom_info->sustained_perf_level =
168 le32_to_cpu(attr->sustained_perf_level); 168 le32_to_cpu(attr->sustained_perf_level);
169 dom_info->mult_factor = (dom_info->sustained_freq_khz * 1000) / 169 if (!dom_info->sustained_freq_khz ||
170 !dom_info->sustained_perf_level)
171 /* CPUFreq converts to kHz, hence default 1000 */
172 dom_info->mult_factor = 1000;
173 else
174 dom_info->mult_factor =
175 (dom_info->sustained_freq_khz * 1000) /
170 dom_info->sustained_perf_level; 176 dom_info->sustained_perf_level;
171 memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE); 177 memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
172 } 178 }
diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
index 3530ccd17e04..da9781a2ef4a 100644
--- a/drivers/gpio/gpio-adp5588.c
+++ b/drivers/gpio/gpio-adp5588.c
@@ -41,6 +41,8 @@ struct adp5588_gpio {
41 uint8_t int_en[3]; 41 uint8_t int_en[3];
42 uint8_t irq_mask[3]; 42 uint8_t irq_mask[3];
43 uint8_t irq_stat[3]; 43 uint8_t irq_stat[3];
44 uint8_t int_input_en[3];
45 uint8_t int_lvl_cached[3];
44}; 46};
45 47
46static int adp5588_gpio_read(struct i2c_client *client, u8 reg) 48static int adp5588_gpio_read(struct i2c_client *client, u8 reg)
@@ -173,12 +175,28 @@ static void adp5588_irq_bus_sync_unlock(struct irq_data *d)
173 struct adp5588_gpio *dev = irq_data_get_irq_chip_data(d); 175 struct adp5588_gpio *dev = irq_data_get_irq_chip_data(d);
174 int i; 176 int i;
175 177
176 for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) 178 for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) {
179 if (dev->int_input_en[i]) {
180 mutex_lock(&dev->lock);
181 dev->dir[i] &= ~dev->int_input_en[i];
182 dev->int_input_en[i] = 0;
183 adp5588_gpio_write(dev->client, GPIO_DIR1 + i,
184 dev->dir[i]);
185 mutex_unlock(&dev->lock);
186 }
187
188 if (dev->int_lvl_cached[i] != dev->int_lvl[i]) {
189 dev->int_lvl_cached[i] = dev->int_lvl[i];
190 adp5588_gpio_write(dev->client, GPIO_INT_LVL1 + i,
191 dev->int_lvl[i]);
192 }
193
177 if (dev->int_en[i] ^ dev->irq_mask[i]) { 194 if (dev->int_en[i] ^ dev->irq_mask[i]) {
178 dev->int_en[i] = dev->irq_mask[i]; 195 dev->int_en[i] = dev->irq_mask[i];
179 adp5588_gpio_write(dev->client, GPIO_INT_EN1 + i, 196 adp5588_gpio_write(dev->client, GPIO_INT_EN1 + i,
180 dev->int_en[i]); 197 dev->int_en[i]);
181 } 198 }
199 }
182 200
183 mutex_unlock(&dev->irq_lock); 201 mutex_unlock(&dev->irq_lock);
184} 202}
@@ -221,9 +239,7 @@ static int adp5588_irq_set_type(struct irq_data *d, unsigned int type)
221 else 239 else
222 return -EINVAL; 240 return -EINVAL;
223 241
224 adp5588_gpio_direction_input(&dev->gpio_chip, gpio); 242 dev->int_input_en[bank] |= bit;
225 adp5588_gpio_write(dev->client, GPIO_INT_LVL1 + bank,
226 dev->int_lvl[bank]);
227 243
228 return 0; 244 return 0;
229} 245}
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index 28da700f5f52..044888fd96a1 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -728,6 +728,7 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
728out_unregister: 728out_unregister:
729 dwapb_gpio_unregister(gpio); 729 dwapb_gpio_unregister(gpio);
730 dwapb_irq_teardown(gpio); 730 dwapb_irq_teardown(gpio);
731 clk_disable_unprepare(gpio->clk);
731 732
732 return err; 733 return err;
733} 734}
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c48ed9d89ff5..8b9d7e42c600 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -25,7 +25,6 @@
25 25
26struct acpi_gpio_event { 26struct acpi_gpio_event {
27 struct list_head node; 27 struct list_head node;
28 struct list_head initial_sync_list;
29 acpi_handle handle; 28 acpi_handle handle;
30 unsigned int pin; 29 unsigned int pin;
31 unsigned int irq; 30 unsigned int irq;
@@ -49,10 +48,19 @@ struct acpi_gpio_chip {
49 struct mutex conn_lock; 48 struct mutex conn_lock;
50 struct gpio_chip *chip; 49 struct gpio_chip *chip;
51 struct list_head events; 50 struct list_head events;
51 struct list_head deferred_req_irqs_list_entry;
52}; 52};
53 53
54static LIST_HEAD(acpi_gpio_initial_sync_list); 54/*
55static DEFINE_MUTEX(acpi_gpio_initial_sync_list_lock); 55 * For gpiochips which call acpi_gpiochip_request_interrupts() before late_init
56 * (so builtin drivers) we register the ACPI GpioInt event handlers from a
57 * late_initcall_sync handler, so that other builtin drivers can register their
58 * OpRegions before the event handlers can run. This list contains gpiochips
59 * for which the acpi_gpiochip_request_interrupts() has been deferred.
60 */
61static DEFINE_MUTEX(acpi_gpio_deferred_req_irqs_lock);
62static LIST_HEAD(acpi_gpio_deferred_req_irqs_list);
63static bool acpi_gpio_deferred_req_irqs_done;
56 64
57static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) 65static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
58{ 66{
@@ -89,21 +97,6 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
89 return gpiochip_get_desc(chip, pin); 97 return gpiochip_get_desc(chip, pin);
90} 98}
91 99
92static void acpi_gpio_add_to_initial_sync_list(struct acpi_gpio_event *event)
93{
94 mutex_lock(&acpi_gpio_initial_sync_list_lock);
95 list_add(&event->initial_sync_list, &acpi_gpio_initial_sync_list);
96 mutex_unlock(&acpi_gpio_initial_sync_list_lock);
97}
98
99static void acpi_gpio_del_from_initial_sync_list(struct acpi_gpio_event *event)
100{
101 mutex_lock(&acpi_gpio_initial_sync_list_lock);
102 if (!list_empty(&event->initial_sync_list))
103 list_del_init(&event->initial_sync_list);
104 mutex_unlock(&acpi_gpio_initial_sync_list_lock);
105}
106
107static irqreturn_t acpi_gpio_irq_handler(int irq, void *data) 100static irqreturn_t acpi_gpio_irq_handler(int irq, void *data)
108{ 101{
109 struct acpi_gpio_event *event = data; 102 struct acpi_gpio_event *event = data;
@@ -186,7 +179,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
186 179
187 gpiod_direction_input(desc); 180 gpiod_direction_input(desc);
188 181
189 value = gpiod_get_value(desc); 182 value = gpiod_get_value_cansleep(desc);
190 183
191 ret = gpiochip_lock_as_irq(chip, pin); 184 ret = gpiochip_lock_as_irq(chip, pin);
192 if (ret) { 185 if (ret) {
@@ -229,7 +222,6 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
229 event->irq = irq; 222 event->irq = irq;
230 event->pin = pin; 223 event->pin = pin;
231 event->desc = desc; 224 event->desc = desc;
232 INIT_LIST_HEAD(&event->initial_sync_list);
233 225
234 ret = request_threaded_irq(event->irq, NULL, handler, irqflags, 226 ret = request_threaded_irq(event->irq, NULL, handler, irqflags,
235 "ACPI:Event", event); 227 "ACPI:Event", event);
@@ -251,10 +243,9 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
251 * may refer to OperationRegions from other (builtin) drivers which 243 * may refer to OperationRegions from other (builtin) drivers which
252 * may be probed after us. 244 * may be probed after us.
253 */ 245 */
254 if (handler == acpi_gpio_irq_handler && 246 if (((irqflags & IRQF_TRIGGER_RISING) && value == 1) ||
255 (((irqflags & IRQF_TRIGGER_RISING) && value == 1) || 247 ((irqflags & IRQF_TRIGGER_FALLING) && value == 0))
256 ((irqflags & IRQF_TRIGGER_FALLING) && value == 0))) 248 handler(event->irq, event);
257 acpi_gpio_add_to_initial_sync_list(event);
258 249
259 return AE_OK; 250 return AE_OK;
260 251
@@ -283,6 +274,7 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
283 struct acpi_gpio_chip *acpi_gpio; 274 struct acpi_gpio_chip *acpi_gpio;
284 acpi_handle handle; 275 acpi_handle handle;
285 acpi_status status; 276 acpi_status status;
277 bool defer;
286 278
287 if (!chip->parent || !chip->to_irq) 279 if (!chip->parent || !chip->to_irq)
288 return; 280 return;
@@ -295,6 +287,16 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
295 if (ACPI_FAILURE(status)) 287 if (ACPI_FAILURE(status))
296 return; 288 return;
297 289
290 mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
291 defer = !acpi_gpio_deferred_req_irqs_done;
292 if (defer)
293 list_add(&acpi_gpio->deferred_req_irqs_list_entry,
294 &acpi_gpio_deferred_req_irqs_list);
295 mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
296
297 if (defer)
298 return;
299
298 acpi_walk_resources(handle, "_AEI", 300 acpi_walk_resources(handle, "_AEI",
299 acpi_gpiochip_request_interrupt, acpi_gpio); 301 acpi_gpiochip_request_interrupt, acpi_gpio);
300} 302}
@@ -325,11 +327,14 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
325 if (ACPI_FAILURE(status)) 327 if (ACPI_FAILURE(status))
326 return; 328 return;
327 329
330 mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
331 if (!list_empty(&acpi_gpio->deferred_req_irqs_list_entry))
332 list_del_init(&acpi_gpio->deferred_req_irqs_list_entry);
333 mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
334
328 list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { 335 list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) {
329 struct gpio_desc *desc; 336 struct gpio_desc *desc;
330 337
331 acpi_gpio_del_from_initial_sync_list(event);
332
333 if (irqd_is_wakeup_set(irq_get_irq_data(event->irq))) 338 if (irqd_is_wakeup_set(irq_get_irq_data(event->irq)))
334 disable_irq_wake(event->irq); 339 disable_irq_wake(event->irq);
335 340
@@ -1052,6 +1057,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)
1052 1057
1053 acpi_gpio->chip = chip; 1058 acpi_gpio->chip = chip;
1054 INIT_LIST_HEAD(&acpi_gpio->events); 1059 INIT_LIST_HEAD(&acpi_gpio->events);
1060 INIT_LIST_HEAD(&acpi_gpio->deferred_req_irqs_list_entry);
1055 1061
1056 status = acpi_attach_data(handle, acpi_gpio_chip_dh, acpi_gpio); 1062 status = acpi_attach_data(handle, acpi_gpio_chip_dh, acpi_gpio);
1057 if (ACPI_FAILURE(status)) { 1063 if (ACPI_FAILURE(status)) {
@@ -1198,20 +1204,28 @@ bool acpi_can_fallback_to_crs(struct acpi_device *adev, const char *con_id)
1198 return con_id == NULL; 1204 return con_id == NULL;
1199} 1205}
1200 1206
1201/* Sync the initial state of handlers after all builtin drivers have probed */ 1207/* Run deferred acpi_gpiochip_request_interrupts() */
1202static int acpi_gpio_initial_sync(void) 1208static int acpi_gpio_handle_deferred_request_interrupts(void)
1203{ 1209{
1204 struct acpi_gpio_event *event, *ep; 1210 struct acpi_gpio_chip *acpi_gpio, *tmp;
1211
1212 mutex_lock(&acpi_gpio_deferred_req_irqs_lock);
1213 list_for_each_entry_safe(acpi_gpio, tmp,
1214 &acpi_gpio_deferred_req_irqs_list,
1215 deferred_req_irqs_list_entry) {
1216 acpi_handle handle;
1205 1217
1206 mutex_lock(&acpi_gpio_initial_sync_list_lock); 1218 handle = ACPI_HANDLE(acpi_gpio->chip->parent);
1207 list_for_each_entry_safe(event, ep, &acpi_gpio_initial_sync_list, 1219 acpi_walk_resources(handle, "_AEI",
1208 initial_sync_list) { 1220 acpi_gpiochip_request_interrupt, acpi_gpio);
1209 acpi_evaluate_object(event->handle, NULL, NULL, NULL); 1221
1210 list_del_init(&event->initial_sync_list); 1222 list_del_init(&acpi_gpio->deferred_req_irqs_list_entry);
1211 } 1223 }
1212 mutex_unlock(&acpi_gpio_initial_sync_list_lock); 1224
1225 acpi_gpio_deferred_req_irqs_done = true;
1226 mutex_unlock(&acpi_gpio_deferred_req_irqs_lock);
1213 1227
1214 return 0; 1228 return 0;
1215} 1229}
1216/* We must use _sync so that this runs after the first deferred_probe run */ 1230/* We must use _sync so that this runs after the first deferred_probe run */
1217late_initcall_sync(acpi_gpio_initial_sync); 1231late_initcall_sync(acpi_gpio_handle_deferred_request_interrupts);
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index a4f1157d6aa0..d4e7a09598fa 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -31,6 +31,7 @@ static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data)
31 struct of_phandle_args *gpiospec = data; 31 struct of_phandle_args *gpiospec = data;
32 32
33 return chip->gpiodev->dev.of_node == gpiospec->np && 33 return chip->gpiodev->dev.of_node == gpiospec->np &&
34 chip->of_xlate &&
34 chip->of_xlate(chip, gpiospec, NULL) >= 0; 35 chip->of_xlate(chip, gpiospec, NULL) >= 0;
35} 36}
36 37
diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
index 6e3f56684f4e..51ed99a37803 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.c
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -170,20 +170,22 @@ static struct drm_i915_gem_object *vgpu_create_gem(struct drm_device *dev,
170 unsigned int tiling_mode = 0; 170 unsigned int tiling_mode = 0;
171 unsigned int stride = 0; 171 unsigned int stride = 0;
172 172
173 switch (info->drm_format_mod << 10) { 173 switch (info->drm_format_mod) {
174 case PLANE_CTL_TILED_LINEAR: 174 case DRM_FORMAT_MOD_LINEAR:
175 tiling_mode = I915_TILING_NONE; 175 tiling_mode = I915_TILING_NONE;
176 break; 176 break;
177 case PLANE_CTL_TILED_X: 177 case I915_FORMAT_MOD_X_TILED:
178 tiling_mode = I915_TILING_X; 178 tiling_mode = I915_TILING_X;
179 stride = info->stride; 179 stride = info->stride;
180 break; 180 break;
181 case PLANE_CTL_TILED_Y: 181 case I915_FORMAT_MOD_Y_TILED:
182 case I915_FORMAT_MOD_Yf_TILED:
182 tiling_mode = I915_TILING_Y; 183 tiling_mode = I915_TILING_Y;
183 stride = info->stride; 184 stride = info->stride;
184 break; 185 break;
185 default: 186 default:
186 gvt_dbg_core("not supported tiling mode\n"); 187 gvt_dbg_core("invalid drm_format_mod %llx for tiling\n",
188 info->drm_format_mod);
187 } 189 }
188 obj->tiling_and_stride = tiling_mode | stride; 190 obj->tiling_and_stride = tiling_mode | stride;
189 } else { 191 } else {
@@ -222,9 +224,26 @@ static int vgpu_get_plane_info(struct drm_device *dev,
222 info->height = p.height; 224 info->height = p.height;
223 info->stride = p.stride; 225 info->stride = p.stride;
224 info->drm_format = p.drm_format; 226 info->drm_format = p.drm_format;
225 info->drm_format_mod = p.tiled; 227
228 switch (p.tiled) {
229 case PLANE_CTL_TILED_LINEAR:
230 info->drm_format_mod = DRM_FORMAT_MOD_LINEAR;
231 break;
232 case PLANE_CTL_TILED_X:
233 info->drm_format_mod = I915_FORMAT_MOD_X_TILED;
234 break;
235 case PLANE_CTL_TILED_Y:
236 info->drm_format_mod = I915_FORMAT_MOD_Y_TILED;
237 break;
238 case PLANE_CTL_TILED_YF:
239 info->drm_format_mod = I915_FORMAT_MOD_Yf_TILED;
240 break;
241 default:
242 gvt_vgpu_err("invalid tiling mode: %x\n", p.tiled);
243 }
244
226 info->size = (((p.stride * p.height * p.bpp) / 8) + 245 info->size = (((p.stride * p.height * p.bpp) / 8) +
227 (PAGE_SIZE - 1)) >> PAGE_SHIFT; 246 (PAGE_SIZE - 1)) >> PAGE_SHIFT;
228 } else if (plane_id == DRM_PLANE_TYPE_CURSOR) { 247 } else if (plane_id == DRM_PLANE_TYPE_CURSOR) {
229 ret = intel_vgpu_decode_cursor_plane(vgpu, &c); 248 ret = intel_vgpu_decode_cursor_plane(vgpu, &c);
230 if (ret) 249 if (ret)
diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.c b/drivers/gpu/drm/i915/gvt/fb_decoder.c
index face664be3e8..481896fb712a 100644
--- a/drivers/gpu/drm/i915/gvt/fb_decoder.c
+++ b/drivers/gpu/drm/i915/gvt/fb_decoder.c
@@ -220,8 +220,7 @@ int intel_vgpu_decode_primary_plane(struct intel_vgpu *vgpu,
220 if (IS_SKYLAKE(dev_priv) 220 if (IS_SKYLAKE(dev_priv)
221 || IS_KABYLAKE(dev_priv) 221 || IS_KABYLAKE(dev_priv)
222 || IS_BROXTON(dev_priv)) { 222 || IS_BROXTON(dev_priv)) {
223 plane->tiled = (val & PLANE_CTL_TILED_MASK) >> 223 plane->tiled = val & PLANE_CTL_TILED_MASK;
224 _PLANE_CTL_TILED_SHIFT;
225 fmt = skl_format_to_drm( 224 fmt = skl_format_to_drm(
226 val & PLANE_CTL_FORMAT_MASK, 225 val & PLANE_CTL_FORMAT_MASK,
227 val & PLANE_CTL_ORDER_RGBX, 226 val & PLANE_CTL_ORDER_RGBX,
@@ -260,7 +259,7 @@ int intel_vgpu_decode_primary_plane(struct intel_vgpu *vgpu,
260 return -EINVAL; 259 return -EINVAL;
261 } 260 }
262 261
263 plane->stride = intel_vgpu_get_stride(vgpu, pipe, (plane->tiled << 10), 262 plane->stride = intel_vgpu_get_stride(vgpu, pipe, plane->tiled,
264 (IS_SKYLAKE(dev_priv) 263 (IS_SKYLAKE(dev_priv)
265 || IS_KABYLAKE(dev_priv) 264 || IS_KABYLAKE(dev_priv)
266 || IS_BROXTON(dev_priv)) ? 265 || IS_BROXTON(dev_priv)) ?
diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.h b/drivers/gpu/drm/i915/gvt/fb_decoder.h
index cb055f3c81a2..60c155085029 100644
--- a/drivers/gpu/drm/i915/gvt/fb_decoder.h
+++ b/drivers/gpu/drm/i915/gvt/fb_decoder.h
@@ -101,7 +101,7 @@ struct intel_gvt;
101/* color space conversion and gamma correction are not included */ 101/* color space conversion and gamma correction are not included */
102struct intel_vgpu_primary_plane_format { 102struct intel_vgpu_primary_plane_format {
103 u8 enabled; /* plane is enabled */ 103 u8 enabled; /* plane is enabled */
104 u8 tiled; /* X-tiled */ 104 u32 tiled; /* tiling mode: linear, X-tiled, Y tiled, etc */
105 u8 bpp; /* bits per pixel */ 105 u8 bpp; /* bits per pixel */
106 u32 hw_format; /* format field in the PRI_CTL register */ 106 u32 hw_format; /* format field in the PRI_CTL register */
107 u32 drm_format; /* format in DRM definition */ 107 u32 drm_format; /* format in DRM definition */
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 7a58ca555197..72afa518edd9 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -1296,6 +1296,19 @@ static int power_well_ctl_mmio_write(struct intel_vgpu *vgpu,
1296 return 0; 1296 return 0;
1297} 1297}
1298 1298
1299static int gen9_dbuf_ctl_mmio_write(struct intel_vgpu *vgpu,
1300 unsigned int offset, void *p_data, unsigned int bytes)
1301{
1302 write_vreg(vgpu, offset, p_data, bytes);
1303
1304 if (vgpu_vreg(vgpu, offset) & DBUF_POWER_REQUEST)
1305 vgpu_vreg(vgpu, offset) |= DBUF_POWER_STATE;
1306 else
1307 vgpu_vreg(vgpu, offset) &= ~DBUF_POWER_STATE;
1308
1309 return 0;
1310}
1311
1299static int fpga_dbg_mmio_write(struct intel_vgpu *vgpu, 1312static int fpga_dbg_mmio_write(struct intel_vgpu *vgpu,
1300 unsigned int offset, void *p_data, unsigned int bytes) 1313 unsigned int offset, void *p_data, unsigned int bytes)
1301{ 1314{
@@ -1525,9 +1538,15 @@ static int bxt_phy_ctl_family_write(struct intel_vgpu *vgpu,
1525 u32 v = *(u32 *)p_data; 1538 u32 v = *(u32 *)p_data;
1526 u32 data = v & COMMON_RESET_DIS ? BXT_PHY_LANE_ENABLED : 0; 1539 u32 data = v & COMMON_RESET_DIS ? BXT_PHY_LANE_ENABLED : 0;
1527 1540
1528 vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_A) = data; 1541 switch (offset) {
1529 vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_B) = data; 1542 case _PHY_CTL_FAMILY_EDP:
1530 vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_C) = data; 1543 vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_A) = data;
1544 break;
1545 case _PHY_CTL_FAMILY_DDI:
1546 vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_B) = data;
1547 vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_C) = data;
1548 break;
1549 }
1531 1550
1532 vgpu_vreg(vgpu, offset) = v; 1551 vgpu_vreg(vgpu, offset) = v;
1533 1552
@@ -2812,6 +2831,8 @@ static int init_skl_mmio_info(struct intel_gvt *gvt)
2812 MMIO_DH(HSW_PWR_WELL_CTL_DRIVER(SKL_DISP_PW_MISC_IO), D_SKL_PLUS, NULL, 2831 MMIO_DH(HSW_PWR_WELL_CTL_DRIVER(SKL_DISP_PW_MISC_IO), D_SKL_PLUS, NULL,
2813 skl_power_well_ctl_write); 2832 skl_power_well_ctl_write);
2814 2833
2834 MMIO_DH(DBUF_CTL, D_SKL_PLUS, NULL, gen9_dbuf_ctl_mmio_write);
2835
2815 MMIO_D(_MMIO(0xa210), D_SKL_PLUS); 2836 MMIO_D(_MMIO(0xa210), D_SKL_PLUS);
2816 MMIO_D(GEN9_MEDIA_PG_IDLE_HYSTERESIS, D_SKL_PLUS); 2837 MMIO_D(GEN9_MEDIA_PG_IDLE_HYSTERESIS, D_SKL_PLUS);
2817 MMIO_D(GEN9_RENDER_PG_IDLE_HYSTERESIS, D_SKL_PLUS); 2838 MMIO_D(GEN9_RENDER_PG_IDLE_HYSTERESIS, D_SKL_PLUS);
@@ -2987,8 +3008,6 @@ static int init_skl_mmio_info(struct intel_gvt *gvt)
2987 NULL, gen9_trtte_write); 3008 NULL, gen9_trtte_write);
2988 MMIO_DH(_MMIO(0x4dfc), D_SKL_PLUS, NULL, gen9_trtt_chicken_write); 3009 MMIO_DH(_MMIO(0x4dfc), D_SKL_PLUS, NULL, gen9_trtt_chicken_write);
2989 3010
2990 MMIO_D(_MMIO(0x45008), D_SKL_PLUS);
2991
2992 MMIO_D(_MMIO(0x46430), D_SKL_PLUS); 3011 MMIO_D(_MMIO(0x46430), D_SKL_PLUS);
2993 3012
2994 MMIO_D(_MMIO(0x46520), D_SKL_PLUS); 3013 MMIO_D(_MMIO(0x46520), D_SKL_PLUS);
@@ -3025,7 +3044,9 @@ static int init_skl_mmio_info(struct intel_gvt *gvt)
3025 MMIO_D(_MMIO(0x44500), D_SKL_PLUS); 3044 MMIO_D(_MMIO(0x44500), D_SKL_PLUS);
3026 MMIO_DFH(GEN9_CSFE_CHICKEN1_RCS, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL); 3045 MMIO_DFH(GEN9_CSFE_CHICKEN1_RCS, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
3027 MMIO_DFH(GEN8_HDC_CHICKEN1, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS, 3046 MMIO_DFH(GEN8_HDC_CHICKEN1, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS,
3028 NULL, NULL); 3047 NULL, NULL);
3048 MMIO_DFH(GEN9_WM_CHICKEN3, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS,
3049 NULL, NULL);
3029 3050
3030 MMIO_D(_MMIO(0x4ab8), D_KBL); 3051 MMIO_D(_MMIO(0x4ab8), D_KBL);
3031 MMIO_D(_MMIO(0x2248), D_KBL | D_SKL); 3052 MMIO_D(_MMIO(0x2248), D_KBL | D_SKL);
diff --git a/drivers/gpu/drm/i915/gvt/mmio_context.c b/drivers/gpu/drm/i915/gvt/mmio_context.c
index 42e1e6bdcc2c..e872f4847fbe 100644
--- a/drivers/gpu/drm/i915/gvt/mmio_context.c
+++ b/drivers/gpu/drm/i915/gvt/mmio_context.c
@@ -562,11 +562,9 @@ void intel_gvt_switch_mmio(struct intel_vgpu *pre,
562 * performace for batch mmio read/write, so we need 562 * performace for batch mmio read/write, so we need
563 * handle forcewake mannually. 563 * handle forcewake mannually.
564 */ 564 */
565 intel_runtime_pm_get(dev_priv);
566 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); 565 intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
567 switch_mmio(pre, next, ring_id); 566 switch_mmio(pre, next, ring_id);
568 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); 567 intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
569 intel_runtime_pm_put(dev_priv);
570} 568}
571 569
572/** 570/**
diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 09d7bb72b4ff..c32e7d5e8629 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -47,11 +47,15 @@ static bool vgpu_has_pending_workload(struct intel_vgpu *vgpu)
47 return false; 47 return false;
48} 48}
49 49
50/* We give 2 seconds higher prio for vGPU during start */
51#define GVT_SCHED_VGPU_PRI_TIME 2
52
50struct vgpu_sched_data { 53struct vgpu_sched_data {
51 struct list_head lru_list; 54 struct list_head lru_list;
52 struct intel_vgpu *vgpu; 55 struct intel_vgpu *vgpu;
53 bool active; 56 bool active;
54 57 bool pri_sched;
58 ktime_t pri_time;
55 ktime_t sched_in_time; 59 ktime_t sched_in_time;
56 ktime_t sched_time; 60 ktime_t sched_time;
57 ktime_t left_ts; 61 ktime_t left_ts;
@@ -183,6 +187,14 @@ static struct intel_vgpu *find_busy_vgpu(struct gvt_sched_data *sched_data)
183 if (!vgpu_has_pending_workload(vgpu_data->vgpu)) 187 if (!vgpu_has_pending_workload(vgpu_data->vgpu))
184 continue; 188 continue;
185 189
190 if (vgpu_data->pri_sched) {
191 if (ktime_before(ktime_get(), vgpu_data->pri_time)) {
192 vgpu = vgpu_data->vgpu;
193 break;
194 } else
195 vgpu_data->pri_sched = false;
196 }
197
186 /* Return the vGPU only if it has time slice left */ 198 /* Return the vGPU only if it has time slice left */
187 if (vgpu_data->left_ts > 0) { 199 if (vgpu_data->left_ts > 0) {
188 vgpu = vgpu_data->vgpu; 200 vgpu = vgpu_data->vgpu;
@@ -202,6 +214,7 @@ static void tbs_sched_func(struct gvt_sched_data *sched_data)
202 struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler; 214 struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
203 struct vgpu_sched_data *vgpu_data; 215 struct vgpu_sched_data *vgpu_data;
204 struct intel_vgpu *vgpu = NULL; 216 struct intel_vgpu *vgpu = NULL;
217
205 /* no active vgpu or has already had a target */ 218 /* no active vgpu or has already had a target */
206 if (list_empty(&sched_data->lru_runq_head) || scheduler->next_vgpu) 219 if (list_empty(&sched_data->lru_runq_head) || scheduler->next_vgpu)
207 goto out; 220 goto out;
@@ -209,12 +222,13 @@ static void tbs_sched_func(struct gvt_sched_data *sched_data)
209 vgpu = find_busy_vgpu(sched_data); 222 vgpu = find_busy_vgpu(sched_data);
210 if (vgpu) { 223 if (vgpu) {
211 scheduler->next_vgpu = vgpu; 224 scheduler->next_vgpu = vgpu;
212
213 /* Move the last used vGPU to the tail of lru_list */
214 vgpu_data = vgpu->sched_data; 225 vgpu_data = vgpu->sched_data;
215 list_del_init(&vgpu_data->lru_list); 226 if (!vgpu_data->pri_sched) {
216 list_add_tail(&vgpu_data->lru_list, 227 /* Move the last used vGPU to the tail of lru_list */
217 &sched_data->lru_runq_head); 228 list_del_init(&vgpu_data->lru_list);
229 list_add_tail(&vgpu_data->lru_list,
230 &sched_data->lru_runq_head);
231 }
218 } else { 232 } else {
219 scheduler->next_vgpu = gvt->idle_vgpu; 233 scheduler->next_vgpu = gvt->idle_vgpu;
220 } 234 }
@@ -328,11 +342,17 @@ static void tbs_sched_start_schedule(struct intel_vgpu *vgpu)
328{ 342{
329 struct gvt_sched_data *sched_data = vgpu->gvt->scheduler.sched_data; 343 struct gvt_sched_data *sched_data = vgpu->gvt->scheduler.sched_data;
330 struct vgpu_sched_data *vgpu_data = vgpu->sched_data; 344 struct vgpu_sched_data *vgpu_data = vgpu->sched_data;
345 ktime_t now;
331 346
332 if (!list_empty(&vgpu_data->lru_list)) 347 if (!list_empty(&vgpu_data->lru_list))
333 return; 348 return;
334 349
335 list_add_tail(&vgpu_data->lru_list, &sched_data->lru_runq_head); 350 now = ktime_get();
351 vgpu_data->pri_time = ktime_add(now,
352 ktime_set(GVT_SCHED_VGPU_PRI_TIME, 0));
353 vgpu_data->pri_sched = true;
354
355 list_add(&vgpu_data->lru_list, &sched_data->lru_runq_head);
336 356
337 if (!hrtimer_active(&sched_data->timer)) 357 if (!hrtimer_active(&sched_data->timer))
338 hrtimer_start(&sched_data->timer, ktime_add_ns(ktime_get(), 358 hrtimer_start(&sched_data->timer, ktime_add_ns(ktime_get(),
@@ -426,6 +446,7 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
426 &vgpu->gvt->scheduler; 446 &vgpu->gvt->scheduler;
427 int ring_id; 447 int ring_id;
428 struct vgpu_sched_data *vgpu_data = vgpu->sched_data; 448 struct vgpu_sched_data *vgpu_data = vgpu->sched_data;
449 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
429 450
430 if (!vgpu_data->active) 451 if (!vgpu_data->active)
431 return; 452 return;
@@ -444,6 +465,7 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
444 scheduler->current_vgpu = NULL; 465 scheduler->current_vgpu = NULL;
445 } 466 }
446 467
468 intel_runtime_pm_get(dev_priv);
447 spin_lock_bh(&scheduler->mmio_context_lock); 469 spin_lock_bh(&scheduler->mmio_context_lock);
448 for (ring_id = 0; ring_id < I915_NUM_ENGINES; ring_id++) { 470 for (ring_id = 0; ring_id < I915_NUM_ENGINES; ring_id++) {
449 if (scheduler->engine_owner[ring_id] == vgpu) { 471 if (scheduler->engine_owner[ring_id] == vgpu) {
@@ -452,5 +474,6 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
452 } 474 }
453 } 475 }
454 spin_unlock_bh(&scheduler->mmio_context_lock); 476 spin_unlock_bh(&scheduler->mmio_context_lock);
477 intel_runtime_pm_put(dev_priv);
455 mutex_unlock(&vgpu->gvt->sched_lock); 478 mutex_unlock(&vgpu->gvt->sched_lock);
456} 479}
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 08ec7446282e..9e63cd47b60f 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -10422,7 +10422,7 @@ enum skl_power_gate {
10422 _ICL_DSC0_PICTURE_PARAMETER_SET_4_PB, \ 10422 _ICL_DSC0_PICTURE_PARAMETER_SET_4_PB, \
10423 _ICL_DSC0_PICTURE_PARAMETER_SET_4_PC) 10423 _ICL_DSC0_PICTURE_PARAMETER_SET_4_PC)
10424#define ICL_DSC1_PICTURE_PARAMETER_SET_4(pipe) _MMIO_PIPE((pipe) - PIPE_B, \ 10424#define ICL_DSC1_PICTURE_PARAMETER_SET_4(pipe) _MMIO_PIPE((pipe) - PIPE_B, \
10425 _ICL_DSC0_PICTURE_PARAMETER_SET_4_PB, \ 10425 _ICL_DSC1_PICTURE_PARAMETER_SET_4_PB, \
10426 _ICL_DSC1_PICTURE_PARAMETER_SET_4_PC) 10426 _ICL_DSC1_PICTURE_PARAMETER_SET_4_PC)
10427#define DSC_INITIAL_DEC_DELAY(dec_delay) ((dec_delay) << 16) 10427#define DSC_INITIAL_DEC_DELAY(dec_delay) ((dec_delay) << 16)
10428#define DSC_INITIAL_XMIT_DELAY(xmit_delay) ((xmit_delay) << 0) 10428#define DSC_INITIAL_XMIT_DELAY(xmit_delay) ((xmit_delay) << 0)
@@ -10437,7 +10437,7 @@ enum skl_power_gate {
10437 _ICL_DSC0_PICTURE_PARAMETER_SET_5_PB, \ 10437 _ICL_DSC0_PICTURE_PARAMETER_SET_5_PB, \
10438 _ICL_DSC0_PICTURE_PARAMETER_SET_5_PC) 10438 _ICL_DSC0_PICTURE_PARAMETER_SET_5_PC)
10439#define ICL_DSC1_PICTURE_PARAMETER_SET_5(pipe) _MMIO_PIPE((pipe) - PIPE_B, \ 10439#define ICL_DSC1_PICTURE_PARAMETER_SET_5(pipe) _MMIO_PIPE((pipe) - PIPE_B, \
10440 _ICL_DSC1_PICTURE_PARAMETER_SET_5_PC, \ 10440 _ICL_DSC1_PICTURE_PARAMETER_SET_5_PB, \
10441 _ICL_DSC1_PICTURE_PARAMETER_SET_5_PC) 10441 _ICL_DSC1_PICTURE_PARAMETER_SET_5_PC)
10442#define DSC_SCALE_DEC_INTINT(scale_dec) ((scale_dec) << 16) 10442#define DSC_SCALE_DEC_INTINT(scale_dec) ((scale_dec) << 16)
10443#define DSC_SCALE_INC_INT(scale_inc) ((scale_inc) << 0) 10443#define DSC_SCALE_INC_INT(scale_inc) ((scale_inc) << 0)
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 8761513f3532..c9af34861d9e 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -2708,7 +2708,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
2708 if (port != PORT_A || INTEL_GEN(dev_priv) >= 9) 2708 if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
2709 intel_dp_stop_link_train(intel_dp); 2709 intel_dp_stop_link_train(intel_dp);
2710 2710
2711 intel_ddi_enable_pipe_clock(crtc_state); 2711 if (!is_mst)
2712 intel_ddi_enable_pipe_clock(crtc_state);
2712} 2713}
2713 2714
2714static void intel_ddi_pre_enable_hdmi(struct intel_encoder *encoder, 2715static void intel_ddi_pre_enable_hdmi(struct intel_encoder *encoder,
@@ -2810,14 +2811,14 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
2810 bool is_mst = intel_crtc_has_type(old_crtc_state, 2811 bool is_mst = intel_crtc_has_type(old_crtc_state,
2811 INTEL_OUTPUT_DP_MST); 2812 INTEL_OUTPUT_DP_MST);
2812 2813
2813 intel_ddi_disable_pipe_clock(old_crtc_state); 2814 if (!is_mst) {
2814 2815 intel_ddi_disable_pipe_clock(old_crtc_state);
2815 /* 2816 /*
2816 * Power down sink before disabling the port, otherwise we end 2817 * Power down sink before disabling the port, otherwise we end
2817 * up getting interrupts from the sink on detecting link loss. 2818 * up getting interrupts from the sink on detecting link loss.
2818 */ 2819 */
2819 if (!is_mst)
2820 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); 2820 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
2821 }
2821 2822
2822 intel_disable_ddi_buf(encoder); 2823 intel_disable_ddi_buf(encoder);
2823 2824
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index cd0f649b57a5..1193202766a2 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4160,18 +4160,6 @@ intel_dp_needs_link_retrain(struct intel_dp *intel_dp)
4160 return !drm_dp_channel_eq_ok(link_status, intel_dp->lane_count); 4160 return !drm_dp_channel_eq_ok(link_status, intel_dp->lane_count);
4161} 4161}
4162 4162
4163/*
4164 * If display is now connected check links status,
4165 * there has been known issues of link loss triggering
4166 * long pulse.
4167 *
4168 * Some sinks (eg. ASUS PB287Q) seem to perform some
4169 * weird HPD ping pong during modesets. So we can apparently
4170 * end up with HPD going low during a modeset, and then
4171 * going back up soon after. And once that happens we must
4172 * retrain the link to get a picture. That's in case no
4173 * userspace component reacted to intermittent HPD dip.
4174 */
4175int intel_dp_retrain_link(struct intel_encoder *encoder, 4163int intel_dp_retrain_link(struct intel_encoder *encoder,
4176 struct drm_modeset_acquire_ctx *ctx) 4164 struct drm_modeset_acquire_ctx *ctx)
4177{ 4165{
@@ -4661,7 +4649,8 @@ intel_dp_unset_edid(struct intel_dp *intel_dp)
4661} 4649}
4662 4650
4663static int 4651static int
4664intel_dp_long_pulse(struct intel_connector *connector) 4652intel_dp_long_pulse(struct intel_connector *connector,
4653 struct drm_modeset_acquire_ctx *ctx)
4665{ 4654{
4666 struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 4655 struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
4667 struct intel_dp *intel_dp = intel_attached_dp(&connector->base); 4656 struct intel_dp *intel_dp = intel_attached_dp(&connector->base);
@@ -4720,6 +4709,22 @@ intel_dp_long_pulse(struct intel_connector *connector)
4720 */ 4709 */
4721 status = connector_status_disconnected; 4710 status = connector_status_disconnected;
4722 goto out; 4711 goto out;
4712 } else {
4713 /*
4714 * If display is now connected check links status,
4715 * there has been known issues of link loss triggering
4716 * long pulse.
4717 *
4718 * Some sinks (eg. ASUS PB287Q) seem to perform some
4719 * weird HPD ping pong during modesets. So we can apparently
4720 * end up with HPD going low during a modeset, and then
4721 * going back up soon after. And once that happens we must
4722 * retrain the link to get a picture. That's in case no
4723 * userspace component reacted to intermittent HPD dip.
4724 */
4725 struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
4726
4727 intel_dp_retrain_link(encoder, ctx);
4723 } 4728 }
4724 4729
4725 /* 4730 /*
@@ -4781,7 +4786,7 @@ intel_dp_detect(struct drm_connector *connector,
4781 return ret; 4786 return ret;
4782 } 4787 }
4783 4788
4784 status = intel_dp_long_pulse(intel_dp->attached_connector); 4789 status = intel_dp_long_pulse(intel_dp->attached_connector, ctx);
4785 } 4790 }
4786 4791
4787 intel_dp->detect_done = false; 4792 intel_dp->detect_done = false;
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index 7e3e01607643..4ecd65375603 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -166,6 +166,8 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
166 struct intel_connector *connector = 166 struct intel_connector *connector =
167 to_intel_connector(old_conn_state->connector); 167 to_intel_connector(old_conn_state->connector);
168 168
169 intel_ddi_disable_pipe_clock(old_crtc_state);
170
169 /* this can fail */ 171 /* this can fail */
170 drm_dp_check_act_status(&intel_dp->mst_mgr); 172 drm_dp_check_act_status(&intel_dp->mst_mgr);
171 /* and this can also fail */ 173 /* and this can also fail */
@@ -252,6 +254,8 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
252 I915_WRITE(DP_TP_STATUS(port), temp); 254 I915_WRITE(DP_TP_STATUS(port), temp);
253 255
254 ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr); 256 ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr);
257
258 intel_ddi_enable_pipe_clock(pipe_config);
255} 259}
256 260
257static void intel_mst_enable_dp(struct intel_encoder *encoder, 261static void intel_mst_enable_dp(struct intel_encoder *encoder,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 8412119bd940..5691dfa1db6f 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -1123,17 +1123,21 @@ nv50_mstm_enable(struct nv50_mstm *mstm, u8 dpcd, int state)
1123 int ret; 1123 int ret;
1124 1124
1125 if (dpcd >= 0x12) { 1125 if (dpcd >= 0x12) {
1126 ret = drm_dp_dpcd_readb(mstm->mgr.aux, DP_MSTM_CTRL, &dpcd); 1126 /* Even if we're enabling MST, start with disabling the
1127 * branching unit to clear any sink-side MST topology state
1128 * that wasn't set by us
1129 */
1130 ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, 0);
1127 if (ret < 0) 1131 if (ret < 0)
1128 return ret; 1132 return ret;
1129 1133
1130 dpcd &= ~DP_MST_EN; 1134 if (state) {
1131 if (state) 1135 /* Now, start initializing */
1132 dpcd |= DP_MST_EN; 1136 ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL,
1133 1137 DP_MST_EN);
1134 ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, dpcd); 1138 if (ret < 0)
1135 if (ret < 0) 1139 return ret;
1136 return ret; 1140 }
1137 } 1141 }
1138 1142
1139 return nvif_mthd(disp, 0, &args, sizeof(args)); 1143 return nvif_mthd(disp, 0, &args, sizeof(args));
@@ -1142,31 +1146,58 @@ nv50_mstm_enable(struct nv50_mstm *mstm, u8 dpcd, int state)
1142int 1146int
1143nv50_mstm_detect(struct nv50_mstm *mstm, u8 dpcd[8], int allow) 1147nv50_mstm_detect(struct nv50_mstm *mstm, u8 dpcd[8], int allow)
1144{ 1148{
1145 int ret, state = 0; 1149 struct drm_dp_aux *aux;
1150 int ret;
1151 bool old_state, new_state;
1152 u8 mstm_ctrl;
1146 1153
1147 if (!mstm) 1154 if (!mstm)
1148 return 0; 1155 return 0;
1149 1156
1150 if (dpcd[0] >= 0x12) { 1157 mutex_lock(&mstm->mgr.lock);
1151 ret = drm_dp_dpcd_readb(mstm->mgr.aux, DP_MSTM_CAP, &dpcd[1]); 1158
1159 old_state = mstm->mgr.mst_state;
1160 new_state = old_state;
1161 aux = mstm->mgr.aux;
1162
1163 if (old_state) {
1164 /* Just check that the MST hub is still as we expect it */
1165 ret = drm_dp_dpcd_readb(aux, DP_MSTM_CTRL, &mstm_ctrl);
1166 if (ret < 0 || !(mstm_ctrl & DP_MST_EN)) {
1167 DRM_DEBUG_KMS("Hub gone, disabling MST topology\n");
1168 new_state = false;
1169 }
1170 } else if (dpcd[0] >= 0x12) {
1171 ret = drm_dp_dpcd_readb(aux, DP_MSTM_CAP, &dpcd[1]);
1152 if (ret < 0) 1172 if (ret < 0)
1153 return ret; 1173 goto probe_error;
1154 1174
1155 if (!(dpcd[1] & DP_MST_CAP)) 1175 if (!(dpcd[1] & DP_MST_CAP))
1156 dpcd[0] = 0x11; 1176 dpcd[0] = 0x11;
1157 else 1177 else
1158 state = allow; 1178 new_state = allow;
1179 }
1180
1181 if (new_state == old_state) {
1182 mutex_unlock(&mstm->mgr.lock);
1183 return new_state;
1159 } 1184 }
1160 1185
1161 ret = nv50_mstm_enable(mstm, dpcd[0], state); 1186 ret = nv50_mstm_enable(mstm, dpcd[0], new_state);
1162 if (ret) 1187 if (ret)
1163 return ret; 1188 goto probe_error;
1189
1190 mutex_unlock(&mstm->mgr.lock);
1164 1191
1165 ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, state); 1192 ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, new_state);
1166 if (ret) 1193 if (ret)
1167 return nv50_mstm_enable(mstm, dpcd[0], 0); 1194 return nv50_mstm_enable(mstm, dpcd[0], 0);
1168 1195
1169 return mstm->mgr.mst_state; 1196 return new_state;
1197
1198probe_error:
1199 mutex_unlock(&mstm->mgr.lock);
1200 return ret;
1170} 1201}
1171 1202
1172static void 1203static void
@@ -2074,7 +2105,7 @@ nv50_disp_atomic_state_alloc(struct drm_device *dev)
2074static const struct drm_mode_config_funcs 2105static const struct drm_mode_config_funcs
2075nv50_disp_func = { 2106nv50_disp_func = {
2076 .fb_create = nouveau_user_framebuffer_create, 2107 .fb_create = nouveau_user_framebuffer_create,
2077 .output_poll_changed = drm_fb_helper_output_poll_changed, 2108 .output_poll_changed = nouveau_fbcon_output_poll_changed,
2078 .atomic_check = nv50_disp_atomic_check, 2109 .atomic_check = nv50_disp_atomic_check,
2079 .atomic_commit = nv50_disp_atomic_commit, 2110 .atomic_commit = nv50_disp_atomic_commit,
2080 .atomic_state_alloc = nv50_disp_atomic_state_alloc, 2111 .atomic_state_alloc = nv50_disp_atomic_state_alloc,
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 51932c72334e..247f72cc4d10 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -409,59 +409,45 @@ static struct nouveau_encoder *
409nouveau_connector_ddc_detect(struct drm_connector *connector) 409nouveau_connector_ddc_detect(struct drm_connector *connector)
410{ 410{
411 struct drm_device *dev = connector->dev; 411 struct drm_device *dev = connector->dev;
412 struct nouveau_connector *nv_connector = nouveau_connector(connector); 412 struct nouveau_encoder *nv_encoder = NULL, *found = NULL;
413 struct nouveau_drm *drm = nouveau_drm(dev);
414 struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
415 struct nouveau_encoder *nv_encoder = NULL;
416 struct drm_encoder *encoder; 413 struct drm_encoder *encoder;
417 int i, panel = -ENODEV; 414 int i, ret;
418 415 bool switcheroo_ddc = false;
419 /* eDP panels need powering on by us (if the VBIOS doesn't default it
420 * to on) before doing any AUX channel transactions. LVDS panel power
421 * is handled by the SOR itself, and not required for LVDS DDC.
422 */
423 if (nv_connector->type == DCB_CONNECTOR_eDP) {
424 panel = nvkm_gpio_get(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff);
425 if (panel == 0) {
426 nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 1);
427 msleep(300);
428 }
429 }
430 416
431 drm_connector_for_each_possible_encoder(connector, encoder, i) { 417 drm_connector_for_each_possible_encoder(connector, encoder, i) {
432 nv_encoder = nouveau_encoder(encoder); 418 nv_encoder = nouveau_encoder(encoder);
433 419
434 if (nv_encoder->dcb->type == DCB_OUTPUT_DP) { 420 switch (nv_encoder->dcb->type) {
435 int ret = nouveau_dp_detect(nv_encoder); 421 case DCB_OUTPUT_DP:
422 ret = nouveau_dp_detect(nv_encoder);
436 if (ret == NOUVEAU_DP_MST) 423 if (ret == NOUVEAU_DP_MST)
437 return NULL; 424 return NULL;
438 if (ret == NOUVEAU_DP_SST) 425 else if (ret == NOUVEAU_DP_SST)
439 break; 426 found = nv_encoder;
440 } else 427
441 if ((vga_switcheroo_handler_flags() & 428 break;
442 VGA_SWITCHEROO_CAN_SWITCH_DDC) && 429 case DCB_OUTPUT_LVDS:
443 nv_encoder->dcb->type == DCB_OUTPUT_LVDS && 430 switcheroo_ddc = !!(vga_switcheroo_handler_flags() &
444 nv_encoder->i2c) { 431 VGA_SWITCHEROO_CAN_SWITCH_DDC);
445 int ret; 432 /* fall-through */
446 vga_switcheroo_lock_ddc(dev->pdev); 433 default:
447 ret = nvkm_probe_i2c(nv_encoder->i2c, 0x50); 434 if (!nv_encoder->i2c)
448 vga_switcheroo_unlock_ddc(dev->pdev);
449 if (ret)
450 break; 435 break;
451 } else 436
452 if (nv_encoder->i2c) { 437 if (switcheroo_ddc)
438 vga_switcheroo_lock_ddc(dev->pdev);
453 if (nvkm_probe_i2c(nv_encoder->i2c, 0x50)) 439 if (nvkm_probe_i2c(nv_encoder->i2c, 0x50))
454 break; 440 found = nv_encoder;
441 if (switcheroo_ddc)
442 vga_switcheroo_unlock_ddc(dev->pdev);
443
444 break;
455 } 445 }
446 if (found)
447 break;
456 } 448 }
457 449
458 /* eDP panel not detected, restore panel power GPIO to previous 450 return found;
459 * state to avoid confusing the SOR for other output types.
460 */
461 if (!nv_encoder && panel == 0)
462 nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, panel);
463
464 return nv_encoder;
465} 451}
466 452
467static struct nouveau_encoder * 453static struct nouveau_encoder *
@@ -555,12 +541,16 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
555 nv_connector->edid = NULL; 541 nv_connector->edid = NULL;
556 } 542 }
557 543
558 /* Outputs are only polled while runtime active, so acquiring a 544 /* Outputs are only polled while runtime active, so resuming the
559 * runtime PM ref here is unnecessary (and would deadlock upon 545 * device here is unnecessary (and would deadlock upon runtime suspend
560 * runtime suspend because it waits for polling to finish). 546 * because it waits for polling to finish). We do however, want to
547 * prevent the autosuspend timer from elapsing during this operation
548 * if possible.
561 */ 549 */
562 if (!drm_kms_helper_is_poll_worker()) { 550 if (drm_kms_helper_is_poll_worker()) {
563 ret = pm_runtime_get_sync(connector->dev->dev); 551 pm_runtime_get_noresume(dev->dev);
552 } else {
553 ret = pm_runtime_get_sync(dev->dev);
564 if (ret < 0 && ret != -EACCES) 554 if (ret < 0 && ret != -EACCES)
565 return conn_status; 555 return conn_status;
566 } 556 }
@@ -638,10 +628,8 @@ detect_analog:
638 628
639 out: 629 out:
640 630
641 if (!drm_kms_helper_is_poll_worker()) { 631 pm_runtime_mark_last_busy(dev->dev);
642 pm_runtime_mark_last_busy(connector->dev->dev); 632 pm_runtime_put_autosuspend(dev->dev);
643 pm_runtime_put_autosuspend(connector->dev->dev);
644 }
645 633
646 return conn_status; 634 return conn_status;
647} 635}
@@ -1105,6 +1093,26 @@ nouveau_connector_hotplug(struct nvif_notify *notify)
1105 const struct nvif_notify_conn_rep_v0 *rep = notify->data; 1093 const struct nvif_notify_conn_rep_v0 *rep = notify->data;
1106 const char *name = connector->name; 1094 const char *name = connector->name;
1107 struct nouveau_encoder *nv_encoder; 1095 struct nouveau_encoder *nv_encoder;
1096 int ret;
1097
1098 ret = pm_runtime_get(drm->dev->dev);
1099 if (ret == 0) {
1100 /* We can't block here if there's a pending PM request
1101 * running, as we'll deadlock nouveau_display_fini() when it
1102 * calls nvif_put() on our nvif_notify struct. So, simply
1103 * defer the hotplug event until the device finishes resuming
1104 */
1105 NV_DEBUG(drm, "Deferring HPD on %s until runtime resume\n",
1106 name);
1107 schedule_work(&drm->hpd_work);
1108
1109 pm_runtime_put_noidle(drm->dev->dev);
1110 return NVIF_NOTIFY_KEEP;
1111 } else if (ret != 1 && ret != -EACCES) {
1112 NV_WARN(drm, "HPD on %s dropped due to RPM failure: %d\n",
1113 name, ret);
1114 return NVIF_NOTIFY_DROP;
1115 }
1108 1116
1109 if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) { 1117 if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) {
1110 NV_DEBUG(drm, "service %s\n", name); 1118 NV_DEBUG(drm, "service %s\n", name);
@@ -1122,6 +1130,8 @@ nouveau_connector_hotplug(struct nvif_notify *notify)
1122 drm_helper_hpd_irq_event(connector->dev); 1130 drm_helper_hpd_irq_event(connector->dev);
1123 } 1131 }
1124 1132
1133 pm_runtime_mark_last_busy(drm->dev->dev);
1134 pm_runtime_put_autosuspend(drm->dev->dev);
1125 return NVIF_NOTIFY_KEEP; 1135 return NVIF_NOTIFY_KEEP;
1126} 1136}
1127 1137
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 139368b31916..540c0cbbfcee 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -293,7 +293,7 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
293 293
294static const struct drm_mode_config_funcs nouveau_mode_config_funcs = { 294static const struct drm_mode_config_funcs nouveau_mode_config_funcs = {
295 .fb_create = nouveau_user_framebuffer_create, 295 .fb_create = nouveau_user_framebuffer_create,
296 .output_poll_changed = drm_fb_helper_output_poll_changed, 296 .output_poll_changed = nouveau_fbcon_output_poll_changed,
297}; 297};
298 298
299 299
@@ -355,8 +355,6 @@ nouveau_display_hpd_work(struct work_struct *work)
355 pm_runtime_get_sync(drm->dev->dev); 355 pm_runtime_get_sync(drm->dev->dev);
356 356
357 drm_helper_hpd_irq_event(drm->dev); 357 drm_helper_hpd_irq_event(drm->dev);
358 /* enable polling for external displays */
359 drm_kms_helper_poll_enable(drm->dev);
360 358
361 pm_runtime_mark_last_busy(drm->dev->dev); 359 pm_runtime_mark_last_busy(drm->dev->dev);
362 pm_runtime_put_sync(drm->dev->dev); 360 pm_runtime_put_sync(drm->dev->dev);
@@ -379,15 +377,29 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,
379{ 377{
380 struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb); 378 struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb);
381 struct acpi_bus_event *info = data; 379 struct acpi_bus_event *info = data;
380 int ret;
382 381
383 if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) { 382 if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) {
384 if (info->type == ACPI_VIDEO_NOTIFY_PROBE) { 383 if (info->type == ACPI_VIDEO_NOTIFY_PROBE) {
385 /* 384 ret = pm_runtime_get(drm->dev->dev);
386 * This may be the only indication we receive of a 385 if (ret == 1 || ret == -EACCES) {
387 * connector hotplug on a runtime suspended GPU, 386 /* If the GPU is already awake, or in a state
388 * schedule hpd_work to check. 387 * where we can't wake it up, it can handle
389 */ 388 * it's own hotplug events.
390 schedule_work(&drm->hpd_work); 389 */
390 pm_runtime_put_autosuspend(drm->dev->dev);
391 } else if (ret == 0) {
392 /* This may be the only indication we receive
393 * of a connector hotplug on a runtime
394 * suspended GPU, schedule hpd_work to check.
395 */
396 NV_DEBUG(drm, "ACPI requested connector reprobe\n");
397 schedule_work(&drm->hpd_work);
398 pm_runtime_put_noidle(drm->dev->dev);
399 } else {
400 NV_WARN(drm, "Dropped ACPI reprobe event due to RPM error: %d\n",
401 ret);
402 }
391 403
392 /* acpi-video should not generate keypresses for this */ 404 /* acpi-video should not generate keypresses for this */
393 return NOTIFY_BAD; 405 return NOTIFY_BAD;
@@ -411,6 +423,11 @@ nouveau_display_init(struct drm_device *dev)
411 if (ret) 423 if (ret)
412 return ret; 424 return ret;
413 425
426 /* enable connector detection and polling for connectors without HPD
427 * support
428 */
429 drm_kms_helper_poll_enable(dev);
430
414 /* enable hotplug interrupts */ 431 /* enable hotplug interrupts */
415 drm_connector_list_iter_begin(dev, &conn_iter); 432 drm_connector_list_iter_begin(dev, &conn_iter);
416 nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) { 433 nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
@@ -425,7 +442,7 @@ nouveau_display_init(struct drm_device *dev)
425} 442}
426 443
427void 444void
428nouveau_display_fini(struct drm_device *dev, bool suspend) 445nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime)
429{ 446{
430 struct nouveau_display *disp = nouveau_display(dev); 447 struct nouveau_display *disp = nouveau_display(dev);
431 struct nouveau_drm *drm = nouveau_drm(dev); 448 struct nouveau_drm *drm = nouveau_drm(dev);
@@ -450,6 +467,9 @@ nouveau_display_fini(struct drm_device *dev, bool suspend)
450 } 467 }
451 drm_connector_list_iter_end(&conn_iter); 468 drm_connector_list_iter_end(&conn_iter);
452 469
470 if (!runtime)
471 cancel_work_sync(&drm->hpd_work);
472
453 drm_kms_helper_poll_disable(dev); 473 drm_kms_helper_poll_disable(dev);
454 disp->fini(dev); 474 disp->fini(dev);
455} 475}
@@ -618,11 +638,11 @@ nouveau_display_suspend(struct drm_device *dev, bool runtime)
618 } 638 }
619 } 639 }
620 640
621 nouveau_display_fini(dev, true); 641 nouveau_display_fini(dev, true, runtime);
622 return 0; 642 return 0;
623 } 643 }
624 644
625 nouveau_display_fini(dev, true); 645 nouveau_display_fini(dev, true, runtime);
626 646
627 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 647 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
628 struct nouveau_framebuffer *nouveau_fb; 648 struct nouveau_framebuffer *nouveau_fb;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h
index 54aa7c3fa42d..ff92b54ce448 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -62,7 +62,7 @@ nouveau_display(struct drm_device *dev)
62int nouveau_display_create(struct drm_device *dev); 62int nouveau_display_create(struct drm_device *dev);
63void nouveau_display_destroy(struct drm_device *dev); 63void nouveau_display_destroy(struct drm_device *dev);
64int nouveau_display_init(struct drm_device *dev); 64int nouveau_display_init(struct drm_device *dev);
65void nouveau_display_fini(struct drm_device *dev, bool suspend); 65void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
66int nouveau_display_suspend(struct drm_device *dev, bool runtime); 66int nouveau_display_suspend(struct drm_device *dev, bool runtime);
67void nouveau_display_resume(struct drm_device *dev, bool runtime); 67void nouveau_display_resume(struct drm_device *dev, bool runtime);
68int nouveau_display_vblank_enable(struct drm_device *, unsigned int); 68int nouveau_display_vblank_enable(struct drm_device *, unsigned int);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index c7ec86d6c3c9..74d2283f2c28 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -230,7 +230,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
230 mutex_unlock(&drm->master.lock); 230 mutex_unlock(&drm->master.lock);
231 } 231 }
232 if (ret) { 232 if (ret) {
233 NV_ERROR(drm, "Client allocation failed: %d\n", ret); 233 NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
234 goto done; 234 goto done;
235 } 235 }
236 236
@@ -240,37 +240,37 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
240 }, sizeof(struct nv_device_v0), 240 }, sizeof(struct nv_device_v0),
241 &cli->device); 241 &cli->device);
242 if (ret) { 242 if (ret) {
243 NV_ERROR(drm, "Device allocation failed: %d\n", ret); 243 NV_PRINTK(err, cli, "Device allocation failed: %d\n", ret);
244 goto done; 244 goto done;
245 } 245 }
246 246
247 ret = nvif_mclass(&cli->device.object, mmus); 247 ret = nvif_mclass(&cli->device.object, mmus);
248 if (ret < 0) { 248 if (ret < 0) {
249 NV_ERROR(drm, "No supported MMU class\n"); 249 NV_PRINTK(err, cli, "No supported MMU class\n");
250 goto done; 250 goto done;
251 } 251 }
252 252
253 ret = nvif_mmu_init(&cli->device.object, mmus[ret].oclass, &cli->mmu); 253 ret = nvif_mmu_init(&cli->device.object, mmus[ret].oclass, &cli->mmu);
254 if (ret) { 254 if (ret) {
255 NV_ERROR(drm, "MMU allocation failed: %d\n", ret); 255 NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
256 goto done; 256 goto done;
257 } 257 }
258 258
259 ret = nvif_mclass(&cli->mmu.object, vmms); 259 ret = nvif_mclass(&cli->mmu.object, vmms);
260 if (ret < 0) { 260 if (ret < 0) {
261 NV_ERROR(drm, "No supported VMM class\n"); 261 NV_PRINTK(err, cli, "No supported VMM class\n");
262 goto done; 262 goto done;
263 } 263 }
264 264
265 ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm); 265 ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm);
266 if (ret) { 266 if (ret) {
267 NV_ERROR(drm, "VMM allocation failed: %d\n", ret); 267 NV_PRINTK(err, cli, "VMM allocation failed: %d\n", ret);
268 goto done; 268 goto done;
269 } 269 }
270 270
271 ret = nvif_mclass(&cli->mmu.object, mems); 271 ret = nvif_mclass(&cli->mmu.object, mems);
272 if (ret < 0) { 272 if (ret < 0) {
273 NV_ERROR(drm, "No supported MEM class\n"); 273 NV_PRINTK(err, cli, "No supported MEM class\n");
274 goto done; 274 goto done;
275 } 275 }
276 276
@@ -592,10 +592,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
592 pm_runtime_allow(dev->dev); 592 pm_runtime_allow(dev->dev);
593 pm_runtime_mark_last_busy(dev->dev); 593 pm_runtime_mark_last_busy(dev->dev);
594 pm_runtime_put(dev->dev); 594 pm_runtime_put(dev->dev);
595 } else {
596 /* enable polling for external displays */
597 drm_kms_helper_poll_enable(dev);
598 } 595 }
596
599 return 0; 597 return 0;
600 598
601fail_dispinit: 599fail_dispinit:
@@ -629,7 +627,7 @@ nouveau_drm_unload(struct drm_device *dev)
629 nouveau_debugfs_fini(drm); 627 nouveau_debugfs_fini(drm);
630 628
631 if (dev->mode_config.num_crtc) 629 if (dev->mode_config.num_crtc)
632 nouveau_display_fini(dev, false); 630 nouveau_display_fini(dev, false, false);
633 nouveau_display_destroy(dev); 631 nouveau_display_destroy(dev);
634 632
635 nouveau_bios_takedown(dev); 633 nouveau_bios_takedown(dev);
@@ -835,7 +833,6 @@ nouveau_pmops_runtime_suspend(struct device *dev)
835 return -EBUSY; 833 return -EBUSY;
836 } 834 }
837 835
838 drm_kms_helper_poll_disable(drm_dev);
839 nouveau_switcheroo_optimus_dsm(); 836 nouveau_switcheroo_optimus_dsm();
840 ret = nouveau_do_suspend(drm_dev, true); 837 ret = nouveau_do_suspend(drm_dev, true);
841 pci_save_state(pdev); 838 pci_save_state(pdev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 844498c4267c..0f64c0a1d4b3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -466,6 +466,7 @@ nouveau_fbcon_set_suspend_work(struct work_struct *work)
466 console_unlock(); 466 console_unlock();
467 467
468 if (state == FBINFO_STATE_RUNNING) { 468 if (state == FBINFO_STATE_RUNNING) {
469 nouveau_fbcon_hotplug_resume(drm->fbcon);
469 pm_runtime_mark_last_busy(drm->dev->dev); 470 pm_runtime_mark_last_busy(drm->dev->dev);
470 pm_runtime_put_sync(drm->dev->dev); 471 pm_runtime_put_sync(drm->dev->dev);
471 } 472 }
@@ -487,6 +488,61 @@ nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
487 schedule_work(&drm->fbcon_work); 488 schedule_work(&drm->fbcon_work);
488} 489}
489 490
491void
492nouveau_fbcon_output_poll_changed(struct drm_device *dev)
493{
494 struct nouveau_drm *drm = nouveau_drm(dev);
495 struct nouveau_fbdev *fbcon = drm->fbcon;
496 int ret;
497
498 if (!fbcon)
499 return;
500
501 mutex_lock(&fbcon->hotplug_lock);
502
503 ret = pm_runtime_get(dev->dev);
504 if (ret == 1 || ret == -EACCES) {
505 drm_fb_helper_hotplug_event(&fbcon->helper);
506
507 pm_runtime_mark_last_busy(dev->dev);
508 pm_runtime_put_autosuspend(dev->dev);
509 } else if (ret == 0) {
510 /* If the GPU was already in the process of suspending before
511 * this event happened, then we can't block here as we'll
512 * deadlock the runtime pmops since they wait for us to
513 * finish. So, just defer this event for when we runtime
514 * resume again. It will be handled by fbcon_work.
515 */
516 NV_DEBUG(drm, "fbcon HPD event deferred until runtime resume\n");
517 fbcon->hotplug_waiting = true;
518 pm_runtime_put_noidle(drm->dev->dev);
519 } else {
520 DRM_WARN("fbcon HPD event lost due to RPM failure: %d\n",
521 ret);
522 }
523
524 mutex_unlock(&fbcon->hotplug_lock);
525}
526
527void
528nouveau_fbcon_hotplug_resume(struct nouveau_fbdev *fbcon)
529{
530 struct nouveau_drm *drm;
531
532 if (!fbcon)
533 return;
534 drm = nouveau_drm(fbcon->helper.dev);
535
536 mutex_lock(&fbcon->hotplug_lock);
537 if (fbcon->hotplug_waiting) {
538 fbcon->hotplug_waiting = false;
539
540 NV_DEBUG(drm, "Handling deferred fbcon HPD events\n");
541 drm_fb_helper_hotplug_event(&fbcon->helper);
542 }
543 mutex_unlock(&fbcon->hotplug_lock);
544}
545
490int 546int
491nouveau_fbcon_init(struct drm_device *dev) 547nouveau_fbcon_init(struct drm_device *dev)
492{ 548{
@@ -505,6 +561,7 @@ nouveau_fbcon_init(struct drm_device *dev)
505 561
506 drm->fbcon = fbcon; 562 drm->fbcon = fbcon;
507 INIT_WORK(&drm->fbcon_work, nouveau_fbcon_set_suspend_work); 563 INIT_WORK(&drm->fbcon_work, nouveau_fbcon_set_suspend_work);
564 mutex_init(&fbcon->hotplug_lock);
508 565
509 drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs); 566 drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs);
510 567
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.h b/drivers/gpu/drm/nouveau/nouveau_fbcon.h
index a6f192ea3fa6..db9d52047ef8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.h
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.h
@@ -41,6 +41,9 @@ struct nouveau_fbdev {
41 struct nvif_object gdi; 41 struct nvif_object gdi;
42 struct nvif_object blit; 42 struct nvif_object blit;
43 struct nvif_object twod; 43 struct nvif_object twod;
44
45 struct mutex hotplug_lock;
46 bool hotplug_waiting;
44}; 47};
45 48
46void nouveau_fbcon_restore(void); 49void nouveau_fbcon_restore(void);
@@ -68,6 +71,8 @@ void nouveau_fbcon_set_suspend(struct drm_device *dev, int state);
68void nouveau_fbcon_accel_save_disable(struct drm_device *dev); 71void nouveau_fbcon_accel_save_disable(struct drm_device *dev);
69void nouveau_fbcon_accel_restore(struct drm_device *dev); 72void nouveau_fbcon_accel_restore(struct drm_device *dev);
70 73
74void nouveau_fbcon_output_poll_changed(struct drm_device *dev);
75void nouveau_fbcon_hotplug_resume(struct nouveau_fbdev *fbcon);
71extern int nouveau_nofbaccel; 76extern int nouveau_nofbaccel;
72 77
73#endif /* __NV50_FBCON_H__ */ 78#endif /* __NV50_FBCON_H__ */
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 3da5a4305aa4..8f1ce4833230 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -46,12 +46,10 @@ nouveau_switcheroo_set_state(struct pci_dev *pdev,
46 pr_err("VGA switcheroo: switched nouveau on\n"); 46 pr_err("VGA switcheroo: switched nouveau on\n");
47 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; 47 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
48 nouveau_pmops_resume(&pdev->dev); 48 nouveau_pmops_resume(&pdev->dev);
49 drm_kms_helper_poll_enable(dev);
50 dev->switch_power_state = DRM_SWITCH_POWER_ON; 49 dev->switch_power_state = DRM_SWITCH_POWER_ON;
51 } else { 50 } else {
52 pr_err("VGA switcheroo: switched nouveau off\n"); 51 pr_err("VGA switcheroo: switched nouveau off\n");
53 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; 52 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
54 drm_kms_helper_poll_disable(dev);
55 nouveau_switcheroo_optimus_dsm(); 53 nouveau_switcheroo_optimus_dsm();
56 nouveau_pmops_suspend(&pdev->dev); 54 nouveau_pmops_suspend(&pdev->dev);
57 dev->switch_power_state = DRM_SWITCH_POWER_OFF; 55 dev->switch_power_state = DRM_SWITCH_POWER_OFF;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 32fa94a9773f..cbd33e87b799 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -275,6 +275,7 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
275 struct nvkm_outp *outp, *outt, *pair; 275 struct nvkm_outp *outp, *outt, *pair;
276 struct nvkm_conn *conn; 276 struct nvkm_conn *conn;
277 struct nvkm_head *head; 277 struct nvkm_head *head;
278 struct nvkm_ior *ior;
278 struct nvbios_connE connE; 279 struct nvbios_connE connE;
279 struct dcb_output dcbE; 280 struct dcb_output dcbE;
280 u8 hpd = 0, ver, hdr; 281 u8 hpd = 0, ver, hdr;
@@ -399,6 +400,19 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
399 return ret; 400 return ret;
400 } 401 }
401 402
403 /* Enforce identity-mapped SOR assignment for panels, which have
404 * certain bits (ie. backlight controls) wired to a specific SOR.
405 */
406 list_for_each_entry(outp, &disp->outp, head) {
407 if (outp->conn->info.type == DCB_CONNECTOR_LVDS ||
408 outp->conn->info.type == DCB_CONNECTOR_eDP) {
409 ior = nvkm_ior_find(disp, SOR, ffs(outp->info.or) - 1);
410 if (!WARN_ON(!ior))
411 ior->identity = true;
412 outp->identity = true;
413 }
414 }
415
402 i = 0; 416 i = 0;
403 list_for_each_entry(head, &disp->head, head) 417 list_for_each_entry(head, &disp->head, head)
404 i = max(i, head->id + 1); 418 i = max(i, head->id + 1);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 7c5bed29ffef..5f301e632599 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -28,6 +28,7 @@
28 28
29#include <subdev/bios.h> 29#include <subdev/bios.h>
30#include <subdev/bios/init.h> 30#include <subdev/bios/init.h>
31#include <subdev/gpio.h>
31#include <subdev/i2c.h> 32#include <subdev/i2c.h>
32 33
33#include <nvif/event.h> 34#include <nvif/event.h>
@@ -412,14 +413,10 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
412} 413}
413 414
414static void 415static void
415nvkm_dp_release(struct nvkm_outp *outp, struct nvkm_ior *ior) 416nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
416{ 417{
417 struct nvkm_dp *dp = nvkm_dp(outp); 418 struct nvkm_dp *dp = nvkm_dp(outp);
418 419
419 /* Prevent link from being retrained if sink sends an IRQ. */
420 atomic_set(&dp->lt.done, 0);
421 ior->dp.nr = 0;
422
423 /* Execute DisableLT script from DP Info Table. */ 420 /* Execute DisableLT script from DP Info Table. */
424 nvbios_init(&ior->disp->engine.subdev, dp->info.script[4], 421 nvbios_init(&ior->disp->engine.subdev, dp->info.script[4],
425 init.outp = &dp->outp.info; 422 init.outp = &dp->outp.info;
@@ -428,6 +425,16 @@ nvkm_dp_release(struct nvkm_outp *outp, struct nvkm_ior *ior)
428 ); 425 );
429} 426}
430 427
428static void
429nvkm_dp_release(struct nvkm_outp *outp)
430{
431 struct nvkm_dp *dp = nvkm_dp(outp);
432
433 /* Prevent link from being retrained if sink sends an IRQ. */
434 atomic_set(&dp->lt.done, 0);
435 dp->outp.ior->dp.nr = 0;
436}
437
431static int 438static int
432nvkm_dp_acquire(struct nvkm_outp *outp) 439nvkm_dp_acquire(struct nvkm_outp *outp)
433{ 440{
@@ -491,7 +498,7 @@ done:
491 return ret; 498 return ret;
492} 499}
493 500
494static void 501static bool
495nvkm_dp_enable(struct nvkm_dp *dp, bool enable) 502nvkm_dp_enable(struct nvkm_dp *dp, bool enable)
496{ 503{
497 struct nvkm_i2c_aux *aux = dp->aux; 504 struct nvkm_i2c_aux *aux = dp->aux;
@@ -505,7 +512,7 @@ nvkm_dp_enable(struct nvkm_dp *dp, bool enable)
505 512
506 if (!nvkm_rdaux(aux, DPCD_RC00_DPCD_REV, dp->dpcd, 513 if (!nvkm_rdaux(aux, DPCD_RC00_DPCD_REV, dp->dpcd,
507 sizeof(dp->dpcd))) 514 sizeof(dp->dpcd)))
508 return; 515 return true;
509 } 516 }
510 517
511 if (dp->present) { 518 if (dp->present) {
@@ -515,6 +522,7 @@ nvkm_dp_enable(struct nvkm_dp *dp, bool enable)
515 } 522 }
516 523
517 atomic_set(&dp->lt.done, 0); 524 atomic_set(&dp->lt.done, 0);
525 return false;
518} 526}
519 527
520static int 528static int
@@ -555,9 +563,38 @@ nvkm_dp_fini(struct nvkm_outp *outp)
555static void 563static void
556nvkm_dp_init(struct nvkm_outp *outp) 564nvkm_dp_init(struct nvkm_outp *outp)
557{ 565{
566 struct nvkm_gpio *gpio = outp->disp->engine.subdev.device->gpio;
558 struct nvkm_dp *dp = nvkm_dp(outp); 567 struct nvkm_dp *dp = nvkm_dp(outp);
568
559 nvkm_notify_put(&dp->outp.conn->hpd); 569 nvkm_notify_put(&dp->outp.conn->hpd);
560 nvkm_dp_enable(dp, true); 570
571 /* eDP panels need powering on by us (if the VBIOS doesn't default it
572 * to on) before doing any AUX channel transactions. LVDS panel power
573 * is handled by the SOR itself, and not required for LVDS DDC.
574 */
575 if (dp->outp.conn->info.type == DCB_CONNECTOR_eDP) {
576 int power = nvkm_gpio_get(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff);
577 if (power == 0)
578 nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 1);
579
580 /* We delay here unconditionally, even if already powered,
581 * because some laptop panels having a significant resume
582 * delay before the panel begins responding.
583 *
584 * This is likely a bit of a hack, but no better idea for
585 * handling this at the moment.
586 */
587 msleep(300);
588
589 /* If the eDP panel can't be detected, we need to restore
590 * the panel power GPIO to avoid breaking another output.
591 */
592 if (!nvkm_dp_enable(dp, true) && power == 0)
593 nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 0);
594 } else {
595 nvkm_dp_enable(dp, true);
596 }
597
561 nvkm_notify_get(&dp->hpd); 598 nvkm_notify_get(&dp->hpd);
562} 599}
563 600
@@ -576,6 +613,7 @@ nvkm_dp_func = {
576 .fini = nvkm_dp_fini, 613 .fini = nvkm_dp_fini,
577 .acquire = nvkm_dp_acquire, 614 .acquire = nvkm_dp_acquire,
578 .release = nvkm_dp_release, 615 .release = nvkm_dp_release,
616 .disable = nvkm_dp_disable,
579}; 617};
580 618
581static int 619static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
index e0b4e0c5704e..19911211a12a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
@@ -16,6 +16,7 @@ struct nvkm_ior {
16 char name[8]; 16 char name[8];
17 17
18 struct list_head head; 18 struct list_head head;
19 bool identity;
19 20
20 struct nvkm_ior_state { 21 struct nvkm_ior_state {
21 struct nvkm_outp *outp; 22 struct nvkm_outp *outp;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
index f89c7b977aa5..def005dd5fda 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
@@ -501,11 +501,11 @@ nv50_disp_super_2_0(struct nv50_disp *disp, struct nvkm_head *head)
501 nv50_disp_super_ied_off(head, ior, 2); 501 nv50_disp_super_ied_off(head, ior, 2);
502 502
503 /* If we're shutting down the OR's only active head, execute 503 /* If we're shutting down the OR's only active head, execute
504 * the output path's release function. 504 * the output path's disable function.
505 */ 505 */
506 if (ior->arm.head == (1 << head->id)) { 506 if (ior->arm.head == (1 << head->id)) {
507 if ((outp = ior->arm.outp) && outp->func->release) 507 if ((outp = ior->arm.outp) && outp->func->disable)
508 outp->func->release(outp, ior); 508 outp->func->disable(outp, ior);
509 } 509 }
510} 510}
511 511
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index be9e7f8c3b23..c62030c96fba 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -93,6 +93,8 @@ nvkm_outp_release(struct nvkm_outp *outp, u8 user)
93 if (ior) { 93 if (ior) {
94 outp->acquired &= ~user; 94 outp->acquired &= ~user;
95 if (!outp->acquired) { 95 if (!outp->acquired) {
96 if (outp->func->release && outp->ior)
97 outp->func->release(outp);
96 outp->ior->asy.outp = NULL; 98 outp->ior->asy.outp = NULL;
97 outp->ior = NULL; 99 outp->ior = NULL;
98 } 100 }
@@ -127,17 +129,26 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user)
127 if (proto == UNKNOWN) 129 if (proto == UNKNOWN)
128 return -ENOSYS; 130 return -ENOSYS;
129 131
132 /* Deal with panels requiring identity-mapped SOR assignment. */
133 if (outp->identity) {
134 ior = nvkm_ior_find(outp->disp, SOR, ffs(outp->info.or) - 1);
135 if (WARN_ON(!ior))
136 return -ENOSPC;
137 return nvkm_outp_acquire_ior(outp, user, ior);
138 }
139
130 /* First preference is to reuse the OR that is currently armed 140 /* First preference is to reuse the OR that is currently armed
131 * on HW, if any, in order to prevent unnecessary switching. 141 * on HW, if any, in order to prevent unnecessary switching.
132 */ 142 */
133 list_for_each_entry(ior, &outp->disp->ior, head) { 143 list_for_each_entry(ior, &outp->disp->ior, head) {
134 if (!ior->asy.outp && ior->arm.outp == outp) 144 if (!ior->identity && !ior->asy.outp && ior->arm.outp == outp)
135 return nvkm_outp_acquire_ior(outp, user, ior); 145 return nvkm_outp_acquire_ior(outp, user, ior);
136 } 146 }
137 147
138 /* Failing that, a completely unused OR is the next best thing. */ 148 /* Failing that, a completely unused OR is the next best thing. */
139 list_for_each_entry(ior, &outp->disp->ior, head) { 149 list_for_each_entry(ior, &outp->disp->ior, head) {
140 if (!ior->asy.outp && ior->type == type && !ior->arm.outp && 150 if (!ior->identity &&
151 !ior->asy.outp && ior->type == type && !ior->arm.outp &&
141 (ior->func->route.set || ior->id == __ffs(outp->info.or))) 152 (ior->func->route.set || ior->id == __ffs(outp->info.or)))
142 return nvkm_outp_acquire_ior(outp, user, ior); 153 return nvkm_outp_acquire_ior(outp, user, ior);
143 } 154 }
@@ -146,7 +157,7 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user)
146 * but will be released during the next modeset. 157 * but will be released during the next modeset.
147 */ 158 */
148 list_for_each_entry(ior, &outp->disp->ior, head) { 159 list_for_each_entry(ior, &outp->disp->ior, head) {
149 if (!ior->asy.outp && ior->type == type && 160 if (!ior->identity && !ior->asy.outp && ior->type == type &&
150 (ior->func->route.set || ior->id == __ffs(outp->info.or))) 161 (ior->func->route.set || ior->id == __ffs(outp->info.or)))
151 return nvkm_outp_acquire_ior(outp, user, ior); 162 return nvkm_outp_acquire_ior(outp, user, ior);
152 } 163 }
@@ -245,7 +256,6 @@ nvkm_outp_ctor(const struct nvkm_outp_func *func, struct nvkm_disp *disp,
245 outp->index = index; 256 outp->index = index;
246 outp->info = *dcbE; 257 outp->info = *dcbE;
247 outp->i2c = nvkm_i2c_bus_find(i2c, dcbE->i2c_index); 258 outp->i2c = nvkm_i2c_bus_find(i2c, dcbE->i2c_index);
248 outp->or = ffs(outp->info.or) - 1;
249 259
250 OUTP_DBG(outp, "type %02x loc %d or %d link %d con %x " 260 OUTP_DBG(outp, "type %02x loc %d or %d link %d con %x "
251 "edid %x bus %d head %x", 261 "edid %x bus %d head %x",
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
index ea84d7d5741a..6c8aa5cfed9d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
@@ -13,10 +13,10 @@ struct nvkm_outp {
13 struct dcb_output info; 13 struct dcb_output info;
14 14
15 struct nvkm_i2c_bus *i2c; 15 struct nvkm_i2c_bus *i2c;
16 int or;
17 16
18 struct list_head head; 17 struct list_head head;
19 struct nvkm_conn *conn; 18 struct nvkm_conn *conn;
19 bool identity;
20 20
21 /* Assembly state. */ 21 /* Assembly state. */
22#define NVKM_OUTP_PRIV 1 22#define NVKM_OUTP_PRIV 1
@@ -41,7 +41,8 @@ struct nvkm_outp_func {
41 void (*init)(struct nvkm_outp *); 41 void (*init)(struct nvkm_outp *);
42 void (*fini)(struct nvkm_outp *); 42 void (*fini)(struct nvkm_outp *);
43 int (*acquire)(struct nvkm_outp *); 43 int (*acquire)(struct nvkm_outp *);
44 void (*release)(struct nvkm_outp *, struct nvkm_ior *); 44 void (*release)(struct nvkm_outp *);
45 void (*disable)(struct nvkm_outp *, struct nvkm_ior *);
45}; 46};
46 47
47#define OUTP_MSG(o,l,f,a...) do { \ 48#define OUTP_MSG(o,l,f,a...) do { \
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c
index b80618e35491..d65959ef0564 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c
@@ -158,7 +158,8 @@ gm200_devinit_post(struct nvkm_devinit *base, bool post)
158 } 158 }
159 159
160 /* load and execute some other ucode image (bios therm?) */ 160 /* load and execute some other ucode image (bios therm?) */
161 return pmu_load(init, 0x01, post, NULL, NULL); 161 pmu_load(init, 0x01, post, NULL, NULL);
162 return 0;
162} 163}
163 164
164static const struct nvkm_devinit_func 165static const struct nvkm_devinit_func
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
index de269eb482dd..7459def78d50 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
@@ -1423,7 +1423,7 @@ nvkm_vmm_get(struct nvkm_vmm *vmm, u8 page, u64 size, struct nvkm_vma **pvma)
1423void 1423void
1424nvkm_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst) 1424nvkm_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst)
1425{ 1425{
1426 if (vmm->func->part && inst) { 1426 if (inst && vmm->func->part) {
1427 mutex_lock(&vmm->mutex); 1427 mutex_lock(&vmm->mutex);
1428 vmm->func->part(vmm, inst); 1428 vmm->func->part(vmm, inst);
1429 mutex_unlock(&vmm->mutex); 1429 mutex_unlock(&vmm->mutex);
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 25b7bd56ae11..1cb41992aaa1 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -335,7 +335,8 @@ static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
335 struct hid_field *field, struct hid_usage *usage, 335 struct hid_field *field, struct hid_usage *usage,
336 unsigned long **bit, int *max) 336 unsigned long **bit, int *max)
337{ 337{
338 if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { 338 if (usage->hid == (HID_UP_CUSTOM | 0x0003) ||
339 usage->hid == (HID_UP_MSVENDOR | 0x0003)) {
339 /* The fn key on Apple USB keyboards */ 340 /* The fn key on Apple USB keyboards */
340 set_bit(EV_REP, hi->input->evbit); 341 set_bit(EV_REP, hi->input->evbit);
341 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); 342 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
@@ -472,6 +473,12 @@ static const struct hid_device_id apple_devices[] = {
472 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 473 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
473 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), 474 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
474 .driver_data = APPLE_HAS_FN }, 475 .driver_data = APPLE_HAS_FN },
476 { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
477 .driver_data = APPLE_HAS_FN },
478 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
479 .driver_data = APPLE_HAS_FN },
480 { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
481 .driver_data = APPLE_HAS_FN },
475 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), 482 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
476 .driver_data = APPLE_HAS_FN }, 483 .driver_data = APPLE_HAS_FN },
477 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), 484 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 3da354af7a0a..44564f61e9cc 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1000,7 +1000,7 @@ int hid_open_report(struct hid_device *device)
1000 parser = vzalloc(sizeof(struct hid_parser)); 1000 parser = vzalloc(sizeof(struct hid_parser));
1001 if (!parser) { 1001 if (!parser) {
1002 ret = -ENOMEM; 1002 ret = -ENOMEM;
1003 goto err; 1003 goto alloc_err;
1004 } 1004 }
1005 1005
1006 parser->device = device; 1006 parser->device = device;
@@ -1039,6 +1039,7 @@ int hid_open_report(struct hid_device *device)
1039 hid_err(device, "unbalanced delimiter at end of report description\n"); 1039 hid_err(device, "unbalanced delimiter at end of report description\n");
1040 goto err; 1040 goto err;
1041 } 1041 }
1042 kfree(parser->collection_stack);
1042 vfree(parser); 1043 vfree(parser);
1043 device->status |= HID_STAT_PARSED; 1044 device->status |= HID_STAT_PARSED;
1044 return 0; 1045 return 0;
@@ -1047,6 +1048,8 @@ int hid_open_report(struct hid_device *device)
1047 1048
1048 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); 1049 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
1049err: 1050err:
1051 kfree(parser->collection_stack);
1052alloc_err:
1050 vfree(parser); 1053 vfree(parser);
1051 hid_close_report(device); 1054 hid_close_report(device);
1052 return ret; 1055 return ret;
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 79bdf0c7e351..5146ee029db4 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -88,6 +88,7 @@
88#define USB_DEVICE_ID_ANTON_TOUCH_PAD 0x3101 88#define USB_DEVICE_ID_ANTON_TOUCH_PAD 0x3101
89 89
90#define USB_VENDOR_ID_APPLE 0x05ac 90#define USB_VENDOR_ID_APPLE 0x05ac
91#define BT_VENDOR_ID_APPLE 0x004c
91#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 92#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
92#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d 93#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d
93#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e 94#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e
@@ -157,6 +158,7 @@
157#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256 158#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
158#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257 159#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257
159#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267 160#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267
161#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI 0x026c
160#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290 162#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
161#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291 163#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
162#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292 164#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
@@ -528,9 +530,6 @@
528#define I2C_VENDOR_ID_HANTICK 0x0911 530#define I2C_VENDOR_ID_HANTICK 0x0911
529#define I2C_PRODUCT_ID_HANTICK_5288 0x5288 531#define I2C_PRODUCT_ID_HANTICK_5288 0x5288
530 532
531#define I2C_VENDOR_ID_RAYD 0x2386
532#define I2C_PRODUCT_ID_RAYD_3118 0x3118
533
534#define USB_VENDOR_ID_HANWANG 0x0b57 533#define USB_VENDOR_ID_HANWANG 0x0b57
535#define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000 534#define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000
536#define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff 535#define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff
@@ -950,6 +949,7 @@
950#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 949#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
951#define USB_DEVICE_ID_SAITEK_PS1000 0x0621 950#define USB_DEVICE_ID_SAITEK_PS1000 0x0621
952#define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb 951#define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb
952#define USB_DEVICE_ID_SAITEK_RAT7_CONTAGION 0x0ccd
953#define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7 953#define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7
954#define USB_DEVICE_ID_SAITEK_RAT9 0x0cfa 954#define USB_DEVICE_ID_SAITEK_RAT9 0x0cfa
955#define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0 955#define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 4e94ea3e280a..a481eaf39e88 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1582,6 +1582,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid,
1582 input_dev->dev.parent = &hid->dev; 1582 input_dev->dev.parent = &hid->dev;
1583 1583
1584 hidinput->input = input_dev; 1584 hidinput->input = input_dev;
1585 hidinput->application = application;
1585 list_add_tail(&hidinput->list, &hid->inputs); 1586 list_add_tail(&hidinput->list, &hid->inputs);
1586 1587
1587 INIT_LIST_HEAD(&hidinput->reports); 1588 INIT_LIST_HEAD(&hidinput->reports);
@@ -1677,8 +1678,7 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)
1677 struct hid_input *hidinput; 1678 struct hid_input *hidinput;
1678 1679
1679 list_for_each_entry(hidinput, &hid->inputs, list) { 1680 list_for_each_entry(hidinput, &hid->inputs, list) {
1680 if (hidinput->report && 1681 if (hidinput->application == report->application)
1681 hidinput->report->application == report->application)
1682 return hidinput; 1682 return hidinput;
1683 } 1683 }
1684 1684
@@ -1815,6 +1815,7 @@ void hidinput_disconnect(struct hid_device *hid)
1815 input_unregister_device(hidinput->input); 1815 input_unregister_device(hidinput->input);
1816 else 1816 else
1817 input_free_device(hidinput->input); 1817 input_free_device(hidinput->input);
1818 kfree(hidinput->name);
1818 kfree(hidinput); 1819 kfree(hidinput);
1819 } 1820 }
1820 1821
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 40fbb7c52723..da954f3f4da7 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1375,7 +1375,8 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
1375 struct hid_usage *usage, 1375 struct hid_usage *usage,
1376 enum latency_mode latency, 1376 enum latency_mode latency,
1377 bool surface_switch, 1377 bool surface_switch,
1378 bool button_switch) 1378 bool button_switch,
1379 bool *inputmode_found)
1379{ 1380{
1380 struct mt_device *td = hid_get_drvdata(hdev); 1381 struct mt_device *td = hid_get_drvdata(hdev);
1381 struct mt_class *cls = &td->mtclass; 1382 struct mt_class *cls = &td->mtclass;
@@ -1387,6 +1388,14 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
1387 1388
1388 switch (usage->hid) { 1389 switch (usage->hid) {
1389 case HID_DG_INPUTMODE: 1390 case HID_DG_INPUTMODE:
1391 /*
1392 * Some elan panels wrongly declare 2 input mode features,
1393 * and silently ignore when we set the value in the second
1394 * field. Skip the second feature and hope for the best.
1395 */
1396 if (*inputmode_found)
1397 return false;
1398
1390 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { 1399 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) {
1391 report_len = hid_report_len(report); 1400 report_len = hid_report_len(report);
1392 buf = hid_alloc_report_buf(report, GFP_KERNEL); 1401 buf = hid_alloc_report_buf(report, GFP_KERNEL);
@@ -1402,6 +1411,7 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
1402 } 1411 }
1403 1412
1404 field->value[index] = td->inputmode_value; 1413 field->value[index] = td->inputmode_value;
1414 *inputmode_found = true;
1405 return true; 1415 return true;
1406 1416
1407 case HID_DG_CONTACTMAX: 1417 case HID_DG_CONTACTMAX:
@@ -1439,6 +1449,7 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency,
1439 struct hid_usage *usage; 1449 struct hid_usage *usage;
1440 int i, j; 1450 int i, j;
1441 bool update_report; 1451 bool update_report;
1452 bool inputmode_found = false;
1442 1453
1443 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; 1454 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
1444 list_for_each_entry(rep, &rep_enum->report_list, list) { 1455 list_for_each_entry(rep, &rep_enum->report_list, list) {
@@ -1457,7 +1468,8 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency,
1457 usage, 1468 usage,
1458 latency, 1469 latency,
1459 surface_switch, 1470 surface_switch,
1460 button_switch)) 1471 button_switch,
1472 &inputmode_found))
1461 update_report = true; 1473 update_report = true;
1462 } 1474 }
1463 } 1475 }
@@ -1685,6 +1697,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
1685 */ 1697 */
1686 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; 1698 hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
1687 1699
1700 if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
1701 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
1702
1688 timer_setup(&td->release_timer, mt_expired_timeout, 0); 1703 timer_setup(&td->release_timer, mt_expired_timeout, 0);
1689 1704
1690 ret = hid_parse(hdev); 1705 ret = hid_parse(hdev);
diff --git a/drivers/hid/hid-saitek.c b/drivers/hid/hid-saitek.c
index 39e642686ff0..683861f324e3 100644
--- a/drivers/hid/hid-saitek.c
+++ b/drivers/hid/hid-saitek.c
@@ -183,6 +183,8 @@ static const struct hid_device_id saitek_devices[] = {
183 .driver_data = SAITEK_RELEASE_MODE_RAT7 }, 183 .driver_data = SAITEK_RELEASE_MODE_RAT7 },
184 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7), 184 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7),
185 .driver_data = SAITEK_RELEASE_MODE_RAT7 }, 185 .driver_data = SAITEK_RELEASE_MODE_RAT7 },
186 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_CONTAGION),
187 .driver_data = SAITEK_RELEASE_MODE_RAT7 },
186 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9), 188 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9),
187 .driver_data = SAITEK_RELEASE_MODE_RAT7 }, 189 .driver_data = SAITEK_RELEASE_MODE_RAT7 },
188 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9), 190 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9),
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 50af72baa5ca..2b63487057c2 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -579,6 +579,28 @@ void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
579} 579}
580EXPORT_SYMBOL_GPL(sensor_hub_device_close); 580EXPORT_SYMBOL_GPL(sensor_hub_device_close);
581 581
582static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
583 unsigned int *rsize)
584{
585 /*
586 * Checks if the report descriptor of Thinkpad Helix 2 has a logical
587 * minimum for magnetic flux axis greater than the maximum.
588 */
589 if (hdev->product == USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA &&
590 *rsize == 2558 && rdesc[913] == 0x17 && rdesc[914] == 0x40 &&
591 rdesc[915] == 0x81 && rdesc[916] == 0x08 &&
592 rdesc[917] == 0x00 && rdesc[918] == 0x27 &&
593 rdesc[921] == 0x07 && rdesc[922] == 0x00) {
594 /* Sets negative logical minimum for mag x, y and z */
595 rdesc[914] = rdesc[935] = rdesc[956] = 0xc0;
596 rdesc[915] = rdesc[936] = rdesc[957] = 0x7e;
597 rdesc[916] = rdesc[937] = rdesc[958] = 0xf7;
598 rdesc[917] = rdesc[938] = rdesc[959] = 0xff;
599 }
600
601 return rdesc;
602}
603
582static int sensor_hub_probe(struct hid_device *hdev, 604static int sensor_hub_probe(struct hid_device *hdev,
583 const struct hid_device_id *id) 605 const struct hid_device_id *id)
584{ 606{
@@ -743,6 +765,7 @@ static struct hid_driver sensor_hub_driver = {
743 .probe = sensor_hub_probe, 765 .probe = sensor_hub_probe,
744 .remove = sensor_hub_remove, 766 .remove = sensor_hub_remove,
745 .raw_event = sensor_hub_raw_event, 767 .raw_event = sensor_hub_raw_event,
768 .report_fixup = sensor_hub_report_fixup,
746#ifdef CONFIG_PM 769#ifdef CONFIG_PM
747 .suspend = sensor_hub_suspend, 770 .suspend = sensor_hub_suspend,
748 .resume = sensor_hub_resume, 771 .resume = sensor_hub_resume,
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 2ce194a84868..f3076659361a 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -170,8 +170,6 @@ static const struct i2c_hid_quirks {
170 I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, 170 I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
171 { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, 171 { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
172 I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, 172 I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
173 { I2C_VENDOR_ID_RAYD, I2C_PRODUCT_ID_RAYD_3118,
174 I2C_HID_QUIRK_RESEND_REPORT_DESCR },
175 { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH, 173 { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH,
176 I2C_HID_QUIRK_RESEND_REPORT_DESCR }, 174 I2C_HID_QUIRK_RESEND_REPORT_DESCR },
177 { 0, 0 } 175 { 0, 0 }
@@ -1235,11 +1233,16 @@ static int i2c_hid_resume(struct device *dev)
1235 pm_runtime_enable(dev); 1233 pm_runtime_enable(dev);
1236 1234
1237 enable_irq(client->irq); 1235 enable_irq(client->irq);
1238 ret = i2c_hid_hwreset(client); 1236
1237 /* Instead of resetting device, simply powers the device on. This
1238 * solves "incomplete reports" on Raydium devices 2386:3118 and
1239 * 2386:4B33
1240 */
1241 ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
1239 if (ret) 1242 if (ret)
1240 return ret; 1243 return ret;
1241 1244
1242 /* RAYDIUM device (2386:3118) need to re-send report descr cmd 1245 /* Some devices need to re-send report descr cmd
1243 * after resume, after this it will be back normal. 1246 * after resume, after this it will be back normal.
1244 * otherwise it issues too many incomplete reports. 1247 * otherwise it issues too many incomplete reports.
1245 */ 1248 */
diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish.h b/drivers/hid/intel-ish-hid/ipc/hw-ish.h
index 97869b7410eb..da133716bed0 100644
--- a/drivers/hid/intel-ish-hid/ipc/hw-ish.h
+++ b/drivers/hid/intel-ish-hid/ipc/hw-ish.h
@@ -29,6 +29,7 @@
29#define CNL_Ax_DEVICE_ID 0x9DFC 29#define CNL_Ax_DEVICE_ID 0x9DFC
30#define GLK_Ax_DEVICE_ID 0x31A2 30#define GLK_Ax_DEVICE_ID 0x31A2
31#define CNL_H_DEVICE_ID 0xA37C 31#define CNL_H_DEVICE_ID 0xA37C
32#define SPT_H_DEVICE_ID 0xA135
32 33
33#define REVISION_ID_CHT_A0 0x6 34#define REVISION_ID_CHT_A0 0x6
34#define REVISION_ID_CHT_Ax_SI 0x0 35#define REVISION_ID_CHT_Ax_SI 0x0
diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
index 050f9872f5c0..a1125a5c7965 100644
--- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c
+++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
@@ -38,6 +38,7 @@ static const struct pci_device_id ish_pci_tbl[] = {
38 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)}, 38 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)},
39 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)}, 39 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)},
40 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)}, 40 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)},
41 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, SPT_H_DEVICE_ID)},
41 {0, } 42 {0, }
42}; 43};
43MODULE_DEVICE_TABLE(pci, ish_pci_tbl); 44MODULE_DEVICE_TABLE(pci, ish_pci_tbl);
diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
index fb4e4a6bb1f6..be5ba4690895 100644
--- a/drivers/hwmon/raspberrypi-hwmon.c
+++ b/drivers/hwmon/raspberrypi-hwmon.c
@@ -164,3 +164,4 @@ module_platform_driver(rpi_hwmon_driver);
164MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>"); 164MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
165MODULE_DESCRIPTION("Raspberry Pi voltage sensor driver"); 165MODULE_DESCRIPTION("Raspberry Pi voltage sensor driver");
166MODULE_LICENSE("GPL v2"); 166MODULE_LICENSE("GPL v2");
167MODULE_ALIAS("platform:raspberrypi-hwmon");
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 04b60a349d7e..c91e145ef5a5 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -140,6 +140,7 @@
140 140
141#define SBREG_BAR 0x10 141#define SBREG_BAR 0x10
142#define SBREG_SMBCTRL 0xc6000c 142#define SBREG_SMBCTRL 0xc6000c
143#define SBREG_SMBCTRL_DNV 0xcf000c
143 144
144/* Host status bits for SMBPCISTS */ 145/* Host status bits for SMBPCISTS */
145#define SMBPCISTS_INTS BIT(3) 146#define SMBPCISTS_INTS BIT(3)
@@ -1399,7 +1400,11 @@ static void i801_add_tco(struct i801_priv *priv)
1399 spin_unlock(&p2sb_spinlock); 1400 spin_unlock(&p2sb_spinlock);
1400 1401
1401 res = &tco_res[ICH_RES_MEM_OFF]; 1402 res = &tco_res[ICH_RES_MEM_OFF];
1402 res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL; 1403 if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
1404 res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV;
1405 else
1406 res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
1407
1403 res->end = res->start + 3; 1408 res->end = res->start + 3;
1404 res->flags = IORESOURCE_MEM; 1409 res->flags = IORESOURCE_MEM;
1405 1410
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 6d975f5221ca..06c4c767af32 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -538,7 +538,6 @@ static const struct i2c_algorithm lpi2c_imx_algo = {
538 538
539static const struct of_device_id lpi2c_imx_of_match[] = { 539static const struct of_device_id lpi2c_imx_of_match[] = {
540 { .compatible = "fsl,imx7ulp-lpi2c" }, 540 { .compatible = "fsl,imx7ulp-lpi2c" },
541 { .compatible = "fsl,imx8dv-lpi2c" },
542 { }, 541 { },
543}; 542};
544MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match); 543MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match);
diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
index 9918bdd81619..a403e8579b65 100644
--- a/drivers/i2c/busses/i2c-uniphier-f.c
+++ b/drivers/i2c/busses/i2c-uniphier-f.c
@@ -401,11 +401,8 @@ static int uniphier_fi2c_master_xfer(struct i2c_adapter *adap,
401 return ret; 401 return ret;
402 402
403 for (msg = msgs; msg < emsg; msg++) { 403 for (msg = msgs; msg < emsg; msg++) {
404 /* If next message is read, skip the stop condition */ 404 /* Emit STOP if it is the last message or I2C_M_STOP is set. */
405 bool stop = !(msg + 1 < emsg && msg[1].flags & I2C_M_RD); 405 bool stop = (msg + 1 == emsg) || (msg->flags & I2C_M_STOP);
406 /* but, force it if I2C_M_STOP is set */
407 if (msg->flags & I2C_M_STOP)
408 stop = true;
409 406
410 ret = uniphier_fi2c_master_xfer_one(adap, msg, stop); 407 ret = uniphier_fi2c_master_xfer_one(adap, msg, stop);
411 if (ret) 408 if (ret)
diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c
index bb181b088291..454f914ae66d 100644
--- a/drivers/i2c/busses/i2c-uniphier.c
+++ b/drivers/i2c/busses/i2c-uniphier.c
@@ -248,11 +248,8 @@ static int uniphier_i2c_master_xfer(struct i2c_adapter *adap,
248 return ret; 248 return ret;
249 249
250 for (msg = msgs; msg < emsg; msg++) { 250 for (msg = msgs; msg < emsg; msg++) {
251 /* If next message is read, skip the stop condition */ 251 /* Emit STOP if it is the last message or I2C_M_STOP is set. */
252 bool stop = !(msg + 1 < emsg && msg[1].flags & I2C_M_RD); 252 bool stop = (msg + 1 == emsg) || (msg->flags & I2C_M_STOP);
253 /* but, force it if I2C_M_STOP is set */
254 if (msg->flags & I2C_M_STOP)
255 stop = true;
256 253
257 ret = uniphier_i2c_master_xfer_one(adap, msg, stop); 254 ret = uniphier_i2c_master_xfer_one(adap, msg, stop);
258 if (ret) 255 if (ret)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 9a71e50d21f1..0c51c0ffdda9 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -532,6 +532,7 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
532{ 532{
533 u8 rx_watermark; 533 u8 rx_watermark;
534 struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; 534 struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg;
535 unsigned long flags;
535 536
536 /* Clear and enable Rx full interrupt. */ 537 /* Clear and enable Rx full interrupt. */
537 xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); 538 xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK);
@@ -547,6 +548,7 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
547 rx_watermark = IIC_RX_FIFO_DEPTH; 548 rx_watermark = IIC_RX_FIFO_DEPTH;
548 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1); 549 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1);
549 550
551 local_irq_save(flags);
550 if (!(msg->flags & I2C_M_NOSTART)) 552 if (!(msg->flags & I2C_M_NOSTART))
551 /* write the address */ 553 /* write the address */
552 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, 554 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET,
@@ -556,6 +558,8 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
556 558
557 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, 559 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET,
558 msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); 560 msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0));
561 local_irq_restore(flags);
562
559 if (i2c->nmsgs == 1) 563 if (i2c->nmsgs == 1)
560 /* very last, enable bus not busy as well */ 564 /* very last, enable bus not busy as well */
561 xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); 565 xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index f72677291b69..a36c94930c31 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -724,6 +724,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
724 dgid = (union ib_gid *) &addr->sib_addr; 724 dgid = (union ib_gid *) &addr->sib_addr;
725 pkey = ntohs(addr->sib_pkey); 725 pkey = ntohs(addr->sib_pkey);
726 726
727 mutex_lock(&lock);
727 list_for_each_entry(cur_dev, &dev_list, list) { 728 list_for_each_entry(cur_dev, &dev_list, list) {
728 for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { 729 for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
729 if (!rdma_cap_af_ib(cur_dev->device, p)) 730 if (!rdma_cap_af_ib(cur_dev->device, p))
@@ -750,18 +751,19 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
750 cma_dev = cur_dev; 751 cma_dev = cur_dev;
751 sgid = gid; 752 sgid = gid;
752 id_priv->id.port_num = p; 753 id_priv->id.port_num = p;
754 goto found;
753 } 755 }
754 } 756 }
755 } 757 }
756 } 758 }
757 759 mutex_unlock(&lock);
758 if (!cma_dev) 760 return -ENODEV;
759 return -ENODEV;
760 761
761found: 762found:
762 cma_attach_to_dev(id_priv, cma_dev); 763 cma_attach_to_dev(id_priv, cma_dev);
763 addr = (struct sockaddr_ib *) cma_src_addr(id_priv); 764 mutex_unlock(&lock);
764 memcpy(&addr->sib_addr, &sgid, sizeof sgid); 765 addr = (struct sockaddr_ib *)cma_src_addr(id_priv);
766 memcpy(&addr->sib_addr, &sgid, sizeof(sgid));
765 cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr); 767 cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
766 return 0; 768 return 0;
767} 769}
diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
index 6eb64c6f0802..c4118bcd5103 100644
--- a/drivers/infiniband/core/rdma_core.c
+++ b/drivers/infiniband/core/rdma_core.c
@@ -882,6 +882,8 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
882 WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE)); 882 WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE));
883 if (!uverbs_destroy_uobject(obj, reason)) 883 if (!uverbs_destroy_uobject(obj, reason))
884 ret = 0; 884 ret = 0;
885 else
886 atomic_set(&obj->usecnt, 0);
885 } 887 }
886 return ret; 888 return ret;
887} 889}
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index ec8fb289621f..5f437d1570fb 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -124,6 +124,8 @@ static DEFINE_MUTEX(mut);
124static DEFINE_IDR(ctx_idr); 124static DEFINE_IDR(ctx_idr);
125static DEFINE_IDR(multicast_idr); 125static DEFINE_IDR(multicast_idr);
126 126
127static const struct file_operations ucma_fops;
128
127static inline struct ucma_context *_ucma_find_context(int id, 129static inline struct ucma_context *_ucma_find_context(int id,
128 struct ucma_file *file) 130 struct ucma_file *file)
129{ 131{
@@ -1581,6 +1583,10 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
1581 f = fdget(cmd.fd); 1583 f = fdget(cmd.fd);
1582 if (!f.file) 1584 if (!f.file)
1583 return -ENOENT; 1585 return -ENOENT;
1586 if (f.file->f_op != &ucma_fops) {
1587 ret = -EINVAL;
1588 goto file_put;
1589 }
1584 1590
1585 /* Validate current fd and prevent destruction of id. */ 1591 /* Validate current fd and prevent destruction of id. */
1586 ctx = ucma_get_ctx(f.file->private_data, cmd.id); 1592 ctx = ucma_get_ctx(f.file->private_data, cmd.id);
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 823beca448e1..6d974e2363df 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -1050,7 +1050,7 @@ static void ib_uverbs_add_one(struct ib_device *device)
1050 uverbs_dev->num_comp_vectors = device->num_comp_vectors; 1050 uverbs_dev->num_comp_vectors = device->num_comp_vectors;
1051 1051
1052 if (ib_uverbs_create_uapi(device, uverbs_dev)) 1052 if (ib_uverbs_create_uapi(device, uverbs_dev))
1053 goto err; 1053 goto err_uapi;
1054 1054
1055 cdev_init(&uverbs_dev->cdev, NULL); 1055 cdev_init(&uverbs_dev->cdev, NULL);
1056 uverbs_dev->cdev.owner = THIS_MODULE; 1056 uverbs_dev->cdev.owner = THIS_MODULE;
@@ -1077,11 +1077,10 @@ static void ib_uverbs_add_one(struct ib_device *device)
1077 1077
1078err_class: 1078err_class:
1079 device_destroy(uverbs_class, uverbs_dev->cdev.dev); 1079 device_destroy(uverbs_class, uverbs_dev->cdev.dev);
1080
1081err_cdev: 1080err_cdev:
1082 cdev_del(&uverbs_dev->cdev); 1081 cdev_del(&uverbs_dev->cdev);
1082err_uapi:
1083 clear_bit(devnum, dev_map); 1083 clear_bit(devnum, dev_map);
1084
1085err: 1084err:
1086 if (atomic_dec_and_test(&uverbs_dev->refcount)) 1085 if (atomic_dec_and_test(&uverbs_dev->refcount))
1087 ib_uverbs_comp_dev(uverbs_dev); 1086 ib_uverbs_comp_dev(uverbs_dev);
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index bbfb86eb2d24..bc2b9e038439 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -833,6 +833,8 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp)
833 "Failed to destroy Shadow QP"); 833 "Failed to destroy Shadow QP");
834 return rc; 834 return rc;
835 } 835 }
836 bnxt_qplib_free_qp_res(&rdev->qplib_res,
837 &rdev->qp1_sqp->qplib_qp);
836 mutex_lock(&rdev->qp_lock); 838 mutex_lock(&rdev->qp_lock);
837 list_del(&rdev->qp1_sqp->list); 839 list_del(&rdev->qp1_sqp->list);
838 atomic_dec(&rdev->qp_count); 840 atomic_dec(&rdev->qp_count);
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
index e426b990c1dd..6ad0d46ab879 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -196,7 +196,7 @@ static int bnxt_qplib_alloc_qp_hdr_buf(struct bnxt_qplib_res *res,
196 struct bnxt_qplib_qp *qp) 196 struct bnxt_qplib_qp *qp)
197{ 197{
198 struct bnxt_qplib_q *rq = &qp->rq; 198 struct bnxt_qplib_q *rq = &qp->rq;
199 struct bnxt_qplib_q *sq = &qp->rq; 199 struct bnxt_qplib_q *sq = &qp->sq;
200 int rc = 0; 200 int rc = 0;
201 201
202 if (qp->sq_hdr_buf_size && sq->hwq.max_elements) { 202 if (qp->sq_hdr_buf_size && sq->hwq.max_elements) {
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index b3203afa3b1d..347fe18b1a41 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1685,6 +1685,12 @@ static void flush_qp(struct c4iw_qp *qhp)
1685 schp = to_c4iw_cq(qhp->ibqp.send_cq); 1685 schp = to_c4iw_cq(qhp->ibqp.send_cq);
1686 1686
1687 if (qhp->ibqp.uobject) { 1687 if (qhp->ibqp.uobject) {
1688
1689 /* for user qps, qhp->wq.flushed is protected by qhp->mutex */
1690 if (qhp->wq.flushed)
1691 return;
1692
1693 qhp->wq.flushed = 1;
1688 t4_set_wq_in_error(&qhp->wq, 0); 1694 t4_set_wq_in_error(&qhp->wq, 0);
1689 t4_set_cq_in_error(&rchp->cq); 1695 t4_set_cq_in_error(&rchp->cq);
1690 spin_lock_irqsave(&rchp->comp_handler_lock, flag); 1696 spin_lock_irqsave(&rchp->comp_handler_lock, flag);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ca0f1ee26091..0bbeaaae47e0 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -517,9 +517,11 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
517 props->page_size_cap = dev->dev->caps.page_size_cap; 517 props->page_size_cap = dev->dev->caps.page_size_cap;
518 props->max_qp = dev->dev->quotas.qp; 518 props->max_qp = dev->dev->quotas.qp;
519 props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE; 519 props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE;
520 props->max_send_sge = dev->dev->caps.max_sq_sg; 520 props->max_send_sge =
521 props->max_recv_sge = dev->dev->caps.max_rq_sg; 521 min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg);
522 props->max_sge_rd = MLX4_MAX_SGE_RD; 522 props->max_recv_sge =
523 min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg);
524 props->max_sge_rd = MLX4_MAX_SGE_RD;
523 props->max_cq = dev->dev->quotas.cq; 525 props->max_cq = dev->dev->quotas.cq;
524 props->max_cqe = dev->dev->caps.max_cqes; 526 props->max_cqe = dev->dev->caps.max_cqes;
525 props->max_mr = dev->dev->quotas.mpt; 527 props->max_mr = dev->dev->quotas.mpt;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index ea01b8dd2be6..3d5424f335cb 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1027,12 +1027,14 @@ static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id,
1027 1027
1028 skb_queue_head_init(&skqueue); 1028 skb_queue_head_init(&skqueue);
1029 1029
1030 netif_tx_lock_bh(p->dev);
1030 spin_lock_irq(&priv->lock); 1031 spin_lock_irq(&priv->lock);
1031 set_bit(IPOIB_FLAG_OPER_UP, &p->flags); 1032 set_bit(IPOIB_FLAG_OPER_UP, &p->flags);
1032 if (p->neigh) 1033 if (p->neigh)
1033 while ((skb = __skb_dequeue(&p->neigh->queue))) 1034 while ((skb = __skb_dequeue(&p->neigh->queue)))
1034 __skb_queue_tail(&skqueue, skb); 1035 __skb_queue_tail(&skqueue, skb);
1035 spin_unlock_irq(&priv->lock); 1036 spin_unlock_irq(&priv->lock);
1037 netif_tx_unlock_bh(p->dev);
1036 1038
1037 while ((skb = __skb_dequeue(&skqueue))) { 1039 while ((skb = __skb_dequeue(&skqueue))) {
1038 skb->dev = p->dev; 1040 skb->dev = p->dev;
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 316a57530f6d..c2df341ff6fa 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -1439,6 +1439,7 @@ static struct irq_chip its_irq_chip = {
1439 * The consequence of the above is that allocation is cost is low, but 1439 * The consequence of the above is that allocation is cost is low, but
1440 * freeing is expensive. We assumes that freeing rarely occurs. 1440 * freeing is expensive. We assumes that freeing rarely occurs.
1441 */ 1441 */
1442#define ITS_MAX_LPI_NRBITS 16 /* 64K LPIs */
1442 1443
1443static DEFINE_MUTEX(lpi_range_lock); 1444static DEFINE_MUTEX(lpi_range_lock);
1444static LIST_HEAD(lpi_range_list); 1445static LIST_HEAD(lpi_range_list);
@@ -1625,7 +1626,8 @@ static int __init its_alloc_lpi_tables(void)
1625{ 1626{
1626 phys_addr_t paddr; 1627 phys_addr_t paddr;
1627 1628
1628 lpi_id_bits = GICD_TYPER_ID_BITS(gic_rdists->gicd_typer); 1629 lpi_id_bits = min_t(u32, GICD_TYPER_ID_BITS(gic_rdists->gicd_typer),
1630 ITS_MAX_LPI_NRBITS);
1629 gic_rdists->prop_page = its_allocate_prop_table(GFP_NOWAIT); 1631 gic_rdists->prop_page = its_allocate_prop_table(GFP_NOWAIT);
1630 if (!gic_rdists->prop_page) { 1632 if (!gic_rdists->prop_page) {
1631 pr_err("Failed to allocate PROPBASE\n"); 1633 pr_err("Failed to allocate PROPBASE\n");
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 94329e03001e..0b2af6e74fc3 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1276,18 +1276,18 @@ static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi)
1276static int resync_finish(struct mddev *mddev) 1276static int resync_finish(struct mddev *mddev)
1277{ 1277{
1278 struct md_cluster_info *cinfo = mddev->cluster_info; 1278 struct md_cluster_info *cinfo = mddev->cluster_info;
1279 int ret = 0;
1279 1280
1280 clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery); 1281 clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
1281 dlm_unlock_sync(cinfo->resync_lockres);
1282 1282
1283 /* 1283 /*
1284 * If resync thread is interrupted so we can't say resync is finished, 1284 * If resync thread is interrupted so we can't say resync is finished,
1285 * another node will launch resync thread to continue. 1285 * another node will launch resync thread to continue.
1286 */ 1286 */
1287 if (test_bit(MD_CLOSING, &mddev->flags)) 1287 if (!test_bit(MD_CLOSING, &mddev->flags))
1288 return 0; 1288 ret = resync_info_update(mddev, 0, 0);
1289 else 1289 dlm_unlock_sync(cinfo->resync_lockres);
1290 return resync_info_update(mddev, 0, 0); 1290 return ret;
1291} 1291}
1292 1292
1293static int area_resyncing(struct mddev *mddev, int direction, 1293static int area_resyncing(struct mddev *mddev, int direction,
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 981898049491..d6f7978b4449 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4529,11 +4529,12 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
4529 allow_barrier(conf); 4529 allow_barrier(conf);
4530 } 4530 }
4531 4531
4532 raise_barrier(conf, 0);
4532read_more: 4533read_more:
4533 /* Now schedule reads for blocks from sector_nr to last */ 4534 /* Now schedule reads for blocks from sector_nr to last */
4534 r10_bio = raid10_alloc_init_r10buf(conf); 4535 r10_bio = raid10_alloc_init_r10buf(conf);
4535 r10_bio->state = 0; 4536 r10_bio->state = 0;
4536 raise_barrier(conf, sectors_done != 0); 4537 raise_barrier(conf, 1);
4537 atomic_set(&r10_bio->remaining, 0); 4538 atomic_set(&r10_bio->remaining, 0);
4538 r10_bio->mddev = mddev; 4539 r10_bio->mddev = mddev;
4539 r10_bio->sector = sector_nr; 4540 r10_bio->sector = sector_nr;
@@ -4629,6 +4630,8 @@ read_more:
4629 if (sector_nr <= last) 4630 if (sector_nr <= last)
4630 goto read_more; 4631 goto read_more;
4631 4632
4633 lower_barrier(conf);
4634
4632 /* Now that we have done the whole section we can 4635 /* Now that we have done the whole section we can
4633 * update reshape_progress 4636 * update reshape_progress
4634 */ 4637 */
diff --git a/drivers/md/raid5-log.h b/drivers/md/raid5-log.h
index a001808a2b77..bfb811407061 100644
--- a/drivers/md/raid5-log.h
+++ b/drivers/md/raid5-log.h
@@ -46,6 +46,11 @@ extern int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add);
46extern void ppl_quiesce(struct r5conf *conf, int quiesce); 46extern void ppl_quiesce(struct r5conf *conf, int quiesce);
47extern int ppl_handle_flush_request(struct r5l_log *log, struct bio *bio); 47extern int ppl_handle_flush_request(struct r5l_log *log, struct bio *bio);
48 48
49static inline bool raid5_has_log(struct r5conf *conf)
50{
51 return test_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
52}
53
49static inline bool raid5_has_ppl(struct r5conf *conf) 54static inline bool raid5_has_ppl(struct r5conf *conf)
50{ 55{
51 return test_bit(MD_HAS_PPL, &conf->mddev->flags); 56 return test_bit(MD_HAS_PPL, &conf->mddev->flags);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 4ce0d7502fad..e4e98f47865d 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -733,7 +733,7 @@ static bool stripe_can_batch(struct stripe_head *sh)
733{ 733{
734 struct r5conf *conf = sh->raid_conf; 734 struct r5conf *conf = sh->raid_conf;
735 735
736 if (conf->log || raid5_has_ppl(conf)) 736 if (raid5_has_log(conf) || raid5_has_ppl(conf))
737 return false; 737 return false;
738 return test_bit(STRIPE_BATCH_READY, &sh->state) && 738 return test_bit(STRIPE_BATCH_READY, &sh->state) &&
739 !test_bit(STRIPE_BITMAP_PENDING, &sh->state) && 739 !test_bit(STRIPE_BITMAP_PENDING, &sh->state) &&
@@ -7737,7 +7737,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
7737 sector_t newsize; 7737 sector_t newsize;
7738 struct r5conf *conf = mddev->private; 7738 struct r5conf *conf = mddev->private;
7739 7739
7740 if (conf->log || raid5_has_ppl(conf)) 7740 if (raid5_has_log(conf) || raid5_has_ppl(conf))
7741 return -EINVAL; 7741 return -EINVAL;
7742 sectors &= ~((sector_t)conf->chunk_sectors - 1); 7742 sectors &= ~((sector_t)conf->chunk_sectors - 1);
7743 newsize = raid5_size(mddev, sectors, mddev->raid_disks); 7743 newsize = raid5_size(mddev, sectors, mddev->raid_disks);
@@ -7788,7 +7788,7 @@ static int check_reshape(struct mddev *mddev)
7788{ 7788{
7789 struct r5conf *conf = mddev->private; 7789 struct r5conf *conf = mddev->private;
7790 7790
7791 if (conf->log || raid5_has_ppl(conf)) 7791 if (raid5_has_log(conf) || raid5_has_ppl(conf))
7792 return -EINVAL; 7792 return -EINVAL;
7793 if (mddev->delta_disks == 0 && 7793 if (mddev->delta_disks == 0 &&
7794 mddev->new_layout == mddev->layout && 7794 mddev->new_layout == mddev->layout &&
diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c
index 31112f622b88..475e5b3790ed 100644
--- a/drivers/memory/ti-aemif.c
+++ b/drivers/memory/ti-aemif.c
@@ -411,7 +411,7 @@ static int aemif_probe(struct platform_device *pdev)
411 if (ret < 0) 411 if (ret < 0)
412 goto error; 412 goto error;
413 } 413 }
414 } else { 414 } else if (pdata) {
415 for (i = 0; i < pdata->num_sub_devices; i++) { 415 for (i = 0; i < pdata->num_sub_devices; i++) {
416 pdata->sub_devices[i].dev.parent = dev; 416 pdata->sub_devices[i].dev.parent = dev;
417 ret = platform_device_register(&pdata->sub_devices[i]); 417 ret = platform_device_register(&pdata->sub_devices[i]);
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index 9375cef22420..3d27616d9c85 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -283,8 +283,12 @@ static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
283 case SIOCFINDIPDDPRT: 283 case SIOCFINDIPDDPRT:
284 spin_lock_bh(&ipddp_route_lock); 284 spin_lock_bh(&ipddp_route_lock);
285 rp = __ipddp_find_route(&rcp); 285 rp = __ipddp_find_route(&rcp);
286 if (rp) 286 if (rp) {
287 memcpy(&rcp2, rp, sizeof(rcp2)); 287 memset(&rcp2, 0, sizeof(rcp2));
288 rcp2.ip = rp->ip;
289 rcp2.at = rp->at;
290 rcp2.flags = rp->flags;
291 }
288 spin_unlock_bh(&ipddp_route_lock); 292 spin_unlock_bh(&ipddp_route_lock);
289 293
290 if (rp) { 294 if (rp) {
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 7a637b51c7d2..e08301d833e2 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -274,6 +274,7 @@ ltq_etop_hw_init(struct net_device *dev)
274 struct ltq_etop_chan *ch = &priv->ch[i]; 274 struct ltq_etop_chan *ch = &priv->ch[i];
275 275
276 ch->idx = ch->dma.nr = i; 276 ch->idx = ch->dma.nr = i;
277 ch->dma.dev = &priv->pdev->dev;
277 278
278 if (IS_TX(i)) { 279 if (IS_TX(i)) {
279 ltq_dma_alloc_tx(&ch->dma); 280 ltq_dma_alloc_tx(&ch->dma);
diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index 9044496803e6..46ba0cf257c6 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -52,6 +52,7 @@
52#define NFP_FL_TUNNEL_CSUM cpu_to_be16(0x01) 52#define NFP_FL_TUNNEL_CSUM cpu_to_be16(0x01)
53#define NFP_FL_TUNNEL_KEY cpu_to_be16(0x04) 53#define NFP_FL_TUNNEL_KEY cpu_to_be16(0x04)
54#define NFP_FL_TUNNEL_GENEVE_OPT cpu_to_be16(0x0800) 54#define NFP_FL_TUNNEL_GENEVE_OPT cpu_to_be16(0x0800)
55#define NFP_FL_SUPPORTED_TUNNEL_INFO_FLAGS IP_TUNNEL_INFO_TX
55#define NFP_FL_SUPPORTED_IPV4_UDP_TUN_FLAGS (NFP_FL_TUNNEL_CSUM | \ 56#define NFP_FL_SUPPORTED_IPV4_UDP_TUN_FLAGS (NFP_FL_TUNNEL_CSUM | \
56 NFP_FL_TUNNEL_KEY | \ 57 NFP_FL_TUNNEL_KEY | \
57 NFP_FL_TUNNEL_GENEVE_OPT) 58 NFP_FL_TUNNEL_GENEVE_OPT)
@@ -741,11 +742,16 @@ nfp_flower_loop_action(struct nfp_app *app, const struct tc_action *a,
741 nfp_fl_push_vlan(psh_v, a); 742 nfp_fl_push_vlan(psh_v, a);
742 *a_len += sizeof(struct nfp_fl_push_vlan); 743 *a_len += sizeof(struct nfp_fl_push_vlan);
743 } else if (is_tcf_tunnel_set(a)) { 744 } else if (is_tcf_tunnel_set(a)) {
745 struct ip_tunnel_info *ip_tun = tcf_tunnel_info(a);
744 struct nfp_repr *repr = netdev_priv(netdev); 746 struct nfp_repr *repr = netdev_priv(netdev);
747
745 *tun_type = nfp_fl_get_tun_from_act_l4_port(repr->app, a); 748 *tun_type = nfp_fl_get_tun_from_act_l4_port(repr->app, a);
746 if (*tun_type == NFP_FL_TUNNEL_NONE) 749 if (*tun_type == NFP_FL_TUNNEL_NONE)
747 return -EOPNOTSUPP; 750 return -EOPNOTSUPP;
748 751
752 if (ip_tun->mode & ~NFP_FL_SUPPORTED_TUNNEL_INFO_FLAGS)
753 return -EOPNOTSUPP;
754
749 /* Pre-tunnel action is required for tunnel encap. 755 /* Pre-tunnel action is required for tunnel encap.
750 * This checks for next hop entries on NFP. 756 * This checks for next hop entries on NFP.
751 * If none, the packet falls back before applying other actions. 757 * If none, the packet falls back before applying other actions.
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h
index 85f8209bf007..81d941ab895c 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/main.h
+++ b/drivers/net/ethernet/netronome/nfp/flower/main.h
@@ -70,6 +70,7 @@ struct nfp_app;
70#define NFP_FL_FEATS_GENEVE BIT(0) 70#define NFP_FL_FEATS_GENEVE BIT(0)
71#define NFP_FL_NBI_MTU_SETTING BIT(1) 71#define NFP_FL_NBI_MTU_SETTING BIT(1)
72#define NFP_FL_FEATS_GENEVE_OPT BIT(2) 72#define NFP_FL_FEATS_GENEVE_OPT BIT(2)
73#define NFP_FL_FEATS_VLAN_PCP BIT(3)
73#define NFP_FL_FEATS_LAG BIT(31) 74#define NFP_FL_FEATS_LAG BIT(31)
74 75
75struct nfp_fl_mask_id { 76struct nfp_fl_mask_id {
diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c
index a0c72f277faa..17acb8cc6044 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/match.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/match.c
@@ -56,7 +56,7 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_tci *frame,
56 FLOW_DISSECTOR_KEY_VLAN, 56 FLOW_DISSECTOR_KEY_VLAN,
57 target); 57 target);
58 /* Populate the tci field. */ 58 /* Populate the tci field. */
59 if (flow_vlan->vlan_id) { 59 if (flow_vlan->vlan_id || flow_vlan->vlan_priority) {
60 tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, 60 tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO,
61 flow_vlan->vlan_priority) | 61 flow_vlan->vlan_priority) |
62 FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, 62 FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID,
diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c
index 2edab01c3beb..bd19624f10cf 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c
@@ -192,6 +192,17 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,
192 key_size += sizeof(struct nfp_flower_mac_mpls); 192 key_size += sizeof(struct nfp_flower_mac_mpls);
193 } 193 }
194 194
195 if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
196 struct flow_dissector_key_vlan *flow_vlan;
197
198 flow_vlan = skb_flow_dissector_target(flow->dissector,
199 FLOW_DISSECTOR_KEY_VLAN,
200 flow->mask);
201 if (!(priv->flower_ext_feats & NFP_FL_FEATS_VLAN_PCP) &&
202 flow_vlan->vlan_priority)
203 return -EOPNOTSUPP;
204 }
205
195 if (dissector_uses_key(flow->dissector, 206 if (dissector_uses_key(flow->dissector,
196 FLOW_DISSECTOR_KEY_ENC_CONTROL)) { 207 FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
197 struct flow_dissector_key_ipv4_addrs *mask_ipv4 = NULL; 208 struct flow_dissector_key_ipv4_addrs *mask_ipv4 = NULL;
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index a1f37d58e2fe..1d8631303b53 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -631,7 +631,7 @@ struct rtl8169_tc_offsets {
631}; 631};
632 632
633enum rtl_flag { 633enum rtl_flag {
634 RTL_FLAG_TASK_ENABLED, 634 RTL_FLAG_TASK_ENABLED = 0,
635 RTL_FLAG_TASK_SLOW_PENDING, 635 RTL_FLAG_TASK_SLOW_PENDING,
636 RTL_FLAG_TASK_RESET_PENDING, 636 RTL_FLAG_TASK_RESET_PENDING,
637 RTL_FLAG_MAX 637 RTL_FLAG_MAX
@@ -6655,7 +6655,8 @@ static int rtl8169_close(struct net_device *dev)
6655 rtl8169_update_counters(tp); 6655 rtl8169_update_counters(tp);
6656 6656
6657 rtl_lock_work(tp); 6657 rtl_lock_work(tp);
6658 clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); 6658 /* Clear all task flags */
6659 bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
6659 6660
6660 rtl8169_down(dev); 6661 rtl8169_down(dev);
6661 rtl_unlock_work(tp); 6662 rtl_unlock_work(tp);
@@ -6838,7 +6839,9 @@ static void rtl8169_net_suspend(struct net_device *dev)
6838 6839
6839 rtl_lock_work(tp); 6840 rtl_lock_work(tp);
6840 napi_disable(&tp->napi); 6841 napi_disable(&tp->napi);
6841 clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); 6842 /* Clear all task flags */
6843 bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);
6844
6842 rtl_unlock_work(tp); 6845 rtl_unlock_work(tp);
6843 6846
6844 rtl_pll_power_down(tp); 6847 rtl_pll_power_down(tp);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 70921bbe0e28..915fbd66a02b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2272,17 +2272,15 @@ static int netvsc_remove(struct hv_device *dev)
2272 2272
2273 cancel_delayed_work_sync(&ndev_ctx->dwork); 2273 cancel_delayed_work_sync(&ndev_ctx->dwork);
2274 2274
2275 rcu_read_lock(); 2275 rtnl_lock();
2276 nvdev = rcu_dereference(ndev_ctx->nvdev); 2276 nvdev = rtnl_dereference(ndev_ctx->nvdev);
2277 2277 if (nvdev)
2278 if (nvdev)
2279 cancel_work_sync(&nvdev->subchan_work); 2278 cancel_work_sync(&nvdev->subchan_work);
2280 2279
2281 /* 2280 /*
2282 * Call to the vsc driver to let it know that the device is being 2281 * Call to the vsc driver to let it know that the device is being
2283 * removed. Also blocks mtu and channel changes. 2282 * removed. Also blocks mtu and channel changes.
2284 */ 2283 */
2285 rtnl_lock();
2286 vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev); 2284 vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev);
2287 if (vf_netdev) 2285 if (vf_netdev)
2288 netvsc_unregister_vf(vf_netdev); 2286 netvsc_unregister_vf(vf_netdev);
@@ -2294,7 +2292,6 @@ static int netvsc_remove(struct hv_device *dev)
2294 list_del(&ndev_ctx->list); 2292 list_del(&ndev_ctx->list);
2295 2293
2296 rtnl_unlock(); 2294 rtnl_unlock();
2297 rcu_read_unlock();
2298 2295
2299 hv_set_drvdata(dev, NULL); 2296 hv_set_drvdata(dev, NULL);
2300 2297
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 9407acbd19a9..f17f602e6171 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -908,7 +908,11 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
908 BUG_ON(pull_to <= skb_headlen(skb)); 908 BUG_ON(pull_to <= skb_headlen(skb));
909 __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); 909 __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
910 } 910 }
911 BUG_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS); 911 if (unlikely(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS)) {
912 queue->rx.rsp_cons = ++cons;
913 kfree_skb(nskb);
914 return ~0U;
915 }
912 916
913 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, 917 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
914 skb_frag_page(nfrag), 918 skb_frag_page(nfrag),
@@ -1045,6 +1049,8 @@ err:
1045 skb->len += rx->status; 1049 skb->len += rx->status;
1046 1050
1047 i = xennet_fill_frags(queue, skb, &tmpq); 1051 i = xennet_fill_frags(queue, skb, &tmpq);
1052 if (unlikely(i == ~0U))
1053 goto err;
1048 1054
1049 if (rx->flags & XEN_NETRXF_csum_blank) 1055 if (rx->flags & XEN_NETRXF_csum_blank)
1050 skb->ip_summed = CHECKSUM_PARTIAL; 1056 skb->ip_summed = CHECKSUM_PARTIAL;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 49f64eb3eab0..de8282420f96 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -25,6 +25,7 @@
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26#include <linux/netdev_features.h> 26#include <linux/netdev_features.h>
27#include <linux/skbuff.h> 27#include <linux/skbuff.h>
28#include <linux/vmalloc.h>
28 29
29#include <net/iucv/af_iucv.h> 30#include <net/iucv/af_iucv.h>
30#include <net/dsfield.h> 31#include <net/dsfield.h>
@@ -4699,7 +4700,7 @@ static int qeth_query_oat_command(struct qeth_card *card, char __user *udata)
4699 4700
4700 priv.buffer_len = oat_data.buffer_len; 4701 priv.buffer_len = oat_data.buffer_len;
4701 priv.response_len = 0; 4702 priv.response_len = 0;
4702 priv.buffer = kzalloc(oat_data.buffer_len, GFP_KERNEL); 4703 priv.buffer = vzalloc(oat_data.buffer_len);
4703 if (!priv.buffer) { 4704 if (!priv.buffer) {
4704 rc = -ENOMEM; 4705 rc = -ENOMEM;
4705 goto out; 4706 goto out;
@@ -4740,7 +4741,7 @@ static int qeth_query_oat_command(struct qeth_card *card, char __user *udata)
4740 rc = -EFAULT; 4741 rc = -EFAULT;
4741 4742
4742out_free: 4743out_free:
4743 kfree(priv.buffer); 4744 vfree(priv.buffer);
4744out: 4745out:
4745 return rc; 4746 return rc;
4746} 4747}
@@ -5706,6 +5707,8 @@ static struct net_device *qeth_alloc_netdev(struct qeth_card *card)
5706 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 5707 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
5707 dev->hw_features |= NETIF_F_SG; 5708 dev->hw_features |= NETIF_F_SG;
5708 dev->vlan_features |= NETIF_F_SG; 5709 dev->vlan_features |= NETIF_F_SG;
5710 if (IS_IQD(card))
5711 dev->features |= NETIF_F_SG;
5709 } 5712 }
5710 5713
5711 return dev; 5714 return dev;
@@ -5768,8 +5771,10 @@ static int qeth_core_probe_device(struct ccwgroup_device *gdev)
5768 qeth_update_from_chp_desc(card); 5771 qeth_update_from_chp_desc(card);
5769 5772
5770 card->dev = qeth_alloc_netdev(card); 5773 card->dev = qeth_alloc_netdev(card);
5771 if (!card->dev) 5774 if (!card->dev) {
5775 rc = -ENOMEM;
5772 goto err_card; 5776 goto err_card;
5777 }
5773 5778
5774 qeth_determine_capabilities(card); 5779 qeth_determine_capabilities(card);
5775 enforced_disc = qeth_enforce_discipline(card); 5780 enforced_disc = qeth_enforce_discipline(card);
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 710fa74892ae..b5e38531733f 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -423,7 +423,7 @@ static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
423 default: 423 default:
424 dev_kfree_skb_any(skb); 424 dev_kfree_skb_any(skb);
425 QETH_CARD_TEXT(card, 3, "inbunkno"); 425 QETH_CARD_TEXT(card, 3, "inbunkno");
426 QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN); 426 QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr));
427 continue; 427 continue;
428 } 428 }
429 work_done++; 429 work_done++;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 7175086677fb..ada258c01a08 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1390,7 +1390,7 @@ static int qeth_l3_process_inbound_buffer(struct qeth_card *card,
1390 default: 1390 default:
1391 dev_kfree_skb_any(skb); 1391 dev_kfree_skb_any(skb);
1392 QETH_CARD_TEXT(card, 3, "inbunkno"); 1392 QETH_CARD_TEXT(card, 3, "inbunkno");
1393 QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN); 1393 QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr));
1394 continue; 1394 continue;
1395 } 1395 }
1396 work_done++; 1396 work_done++;
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 8fc851a9e116..7c097006c54d 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -52,12 +52,12 @@ config SCSI_MQ_DEFAULT
52 default y 52 default y
53 depends on SCSI 53 depends on SCSI
54 ---help--- 54 ---help---
55 This option enables the new blk-mq based I/O path for SCSI 55 This option enables the blk-mq based I/O path for SCSI devices by
56 devices by default. With the option the scsi_mod.use_blk_mq 56 default. With this option the scsi_mod.use_blk_mq module/boot
57 module/boot option defaults to Y, without it to N, but it can 57 option defaults to Y, without it to N, but it can still be
58 still be overridden either way. 58 overridden either way.
59 59
60 If unsure say N. 60 If unsure say Y.
61 61
62config SCSI_PROC_FS 62config SCSI_PROC_FS
63 bool "legacy /proc/scsi/ support" 63 bool "legacy /proc/scsi/ support"
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 29bf1e60f542..39eb415987fc 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -1346,7 +1346,7 @@ struct fib {
1346struct aac_hba_map_info { 1346struct aac_hba_map_info {
1347 __le32 rmw_nexus; /* nexus for native HBA devices */ 1347 __le32 rmw_nexus; /* nexus for native HBA devices */
1348 u8 devtype; /* device type */ 1348 u8 devtype; /* device type */
1349 u8 reset_state; /* 0 - no reset, 1..x - */ 1349 s8 reset_state; /* 0 - no reset, 1..x - */
1350 /* after xth TM LUN reset */ 1350 /* after xth TM LUN reset */
1351 u16 qd_limit; 1351 u16 qd_limit;
1352 u32 scan_counter; 1352 u32 scan_counter;
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 23d07e9f87d0..e51923886475 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -1602,6 +1602,46 @@ fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t caps16)
1602} 1602}
1603 1603
1604/** 1604/**
1605 * fwcaps32_to_caps16 - convert 32-bit Port Capabilities to 16-bits
1606 * @caps32: a 32-bit Port Capabilities value
1607 *
1608 * Returns the equivalent 16-bit Port Capabilities value. Note that
1609 * not all 32-bit Port Capabilities can be represented in the 16-bit
1610 * Port Capabilities and some fields/values may not make it.
1611 */
1612fw_port_cap16_t fwcaps32_to_caps16(fw_port_cap32_t caps32)
1613{
1614 fw_port_cap16_t caps16 = 0;
1615
1616 #define CAP32_TO_CAP16(__cap) \
1617 do { \
1618 if (caps32 & FW_PORT_CAP32_##__cap) \
1619 caps16 |= FW_PORT_CAP_##__cap; \
1620 } while (0)
1621
1622 CAP32_TO_CAP16(SPEED_100M);
1623 CAP32_TO_CAP16(SPEED_1G);
1624 CAP32_TO_CAP16(SPEED_10G);
1625 CAP32_TO_CAP16(SPEED_25G);
1626 CAP32_TO_CAP16(SPEED_40G);
1627 CAP32_TO_CAP16(SPEED_100G);
1628 CAP32_TO_CAP16(FC_RX);
1629 CAP32_TO_CAP16(FC_TX);
1630 CAP32_TO_CAP16(802_3_PAUSE);
1631 CAP32_TO_CAP16(802_3_ASM_DIR);
1632 CAP32_TO_CAP16(ANEG);
1633 CAP32_TO_CAP16(FORCE_PAUSE);
1634 CAP32_TO_CAP16(MDIAUTO);
1635 CAP32_TO_CAP16(MDISTRAIGHT);
1636 CAP32_TO_CAP16(FEC_RS);
1637 CAP32_TO_CAP16(FEC_BASER_RS);
1638
1639 #undef CAP32_TO_CAP16
1640
1641 return caps16;
1642}
1643
1644/**
1605 * lstatus_to_fwcap - translate old lstatus to 32-bit Port Capabilities 1645 * lstatus_to_fwcap - translate old lstatus to 32-bit Port Capabilities
1606 * @lstatus: old FW_PORT_ACTION_GET_PORT_INFO lstatus value 1646 * @lstatus: old FW_PORT_ACTION_GET_PORT_INFO lstatus value
1607 * 1647 *
@@ -1759,7 +1799,7 @@ csio_enable_ports(struct csio_hw *hw)
1759 val = 1; 1799 val = 1;
1760 1800
1761 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO, 1801 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO,
1762 hw->pfn, 0, 1, &param, &val, false, 1802 hw->pfn, 0, 1, &param, &val, true,
1763 NULL); 1803 NULL);
1764 1804
1765 if (csio_mb_issue(hw, mbp)) { 1805 if (csio_mb_issue(hw, mbp)) {
@@ -1769,16 +1809,9 @@ csio_enable_ports(struct csio_hw *hw)
1769 return -EINVAL; 1809 return -EINVAL;
1770 } 1810 }
1771 1811
1772 csio_mb_process_read_params_rsp(hw, mbp, &retval, 1, 1812 csio_mb_process_read_params_rsp(hw, mbp, &retval,
1773 &val); 1813 0, NULL);
1774 if (retval != FW_SUCCESS) { 1814 fw_caps = retval ? FW_CAPS16 : FW_CAPS32;
1775 csio_err(hw, "FW_PARAMS_CMD(r) port:%d failed: 0x%x\n",
1776 portid, retval);
1777 mempool_free(mbp, hw->mb_mempool);
1778 return -EINVAL;
1779 }
1780
1781 fw_caps = val;
1782 } 1815 }
1783 1816
1784 /* Read PORT information */ 1817 /* Read PORT information */
@@ -2364,8 +2397,8 @@ bye:
2364} 2397}
2365 2398
2366/* 2399/*
2367 * Returns -EINVAL if attempts to flash the firmware failed 2400 * Returns -EINVAL if attempts to flash the firmware failed,
2368 * else returns 0, 2401 * -ENOMEM if memory allocation failed else returns 0,
2369 * if flashing was not attempted because the card had the 2402 * if flashing was not attempted because the card had the
2370 * latest firmware ECANCELED is returned 2403 * latest firmware ECANCELED is returned
2371 */ 2404 */
@@ -2393,6 +2426,13 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
2393 return -EINVAL; 2426 return -EINVAL;
2394 } 2427 }
2395 2428
2429 /* allocate memory to read the header of the firmware on the
2430 * card
2431 */
2432 card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL);
2433 if (!card_fw)
2434 return -ENOMEM;
2435
2396 if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK)) 2436 if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK))
2397 fw_bin_file = FW_FNAME_T5; 2437 fw_bin_file = FW_FNAME_T5;
2398 else 2438 else
@@ -2406,11 +2446,6 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
2406 fw_size = fw->size; 2446 fw_size = fw->size;
2407 } 2447 }
2408 2448
2409 /* allocate memory to read the header of the firmware on the
2410 * card
2411 */
2412 card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL);
2413
2414 /* upgrade FW logic */ 2449 /* upgrade FW logic */
2415 ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, 2450 ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw,
2416 hw->fw_state, reset); 2451 hw->fw_state, reset);
diff --git a/drivers/scsi/csiostor/csio_hw.h b/drivers/scsi/csiostor/csio_hw.h
index 9e73ef771eb7..e351af6e7c81 100644
--- a/drivers/scsi/csiostor/csio_hw.h
+++ b/drivers/scsi/csiostor/csio_hw.h
@@ -639,6 +639,7 @@ int csio_handle_intr_status(struct csio_hw *, unsigned int,
639 639
640fw_port_cap32_t fwcap_to_fwspeed(fw_port_cap32_t acaps); 640fw_port_cap32_t fwcap_to_fwspeed(fw_port_cap32_t acaps);
641fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t caps16); 641fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t caps16);
642fw_port_cap16_t fwcaps32_to_caps16(fw_port_cap32_t caps32);
642fw_port_cap32_t lstatus_to_fwcap(u32 lstatus); 643fw_port_cap32_t lstatus_to_fwcap(u32 lstatus);
643 644
644int csio_hw_start(struct csio_hw *); 645int csio_hw_start(struct csio_hw *);
diff --git a/drivers/scsi/csiostor/csio_mb.c b/drivers/scsi/csiostor/csio_mb.c
index c026417269c3..6f13673d6aa0 100644
--- a/drivers/scsi/csiostor/csio_mb.c
+++ b/drivers/scsi/csiostor/csio_mb.c
@@ -368,7 +368,7 @@ csio_mb_port(struct csio_hw *hw, struct csio_mb *mbp, uint32_t tmo,
368 FW_CMD_LEN16_V(sizeof(*cmdp) / 16)); 368 FW_CMD_LEN16_V(sizeof(*cmdp) / 16));
369 369
370 if (fw_caps == FW_CAPS16) 370 if (fw_caps == FW_CAPS16)
371 cmdp->u.l1cfg.rcap = cpu_to_be32(fc); 371 cmdp->u.l1cfg.rcap = cpu_to_be32(fwcaps32_to_caps16(fc));
372 else 372 else
373 cmdp->u.l1cfg32.rcap32 = cpu_to_be32(fc); 373 cmdp->u.l1cfg32.rcap32 = cpu_to_be32(fc);
374} 374}
@@ -395,8 +395,8 @@ csio_mb_process_read_port_rsp(struct csio_hw *hw, struct csio_mb *mbp,
395 *pcaps = fwcaps16_to_caps32(ntohs(rsp->u.info.pcap)); 395 *pcaps = fwcaps16_to_caps32(ntohs(rsp->u.info.pcap));
396 *acaps = fwcaps16_to_caps32(ntohs(rsp->u.info.acap)); 396 *acaps = fwcaps16_to_caps32(ntohs(rsp->u.info.acap));
397 } else { 397 } else {
398 *pcaps = ntohs(rsp->u.info32.pcaps32); 398 *pcaps = be32_to_cpu(rsp->u.info32.pcaps32);
399 *acaps = ntohs(rsp->u.info32.acaps32); 399 *acaps = be32_to_cpu(rsp->u.info32.acaps32);
400 } 400 }
401 } 401 }
402} 402}
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index f02dcc875a09..ea4b0bb0c1cd 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -563,35 +563,13 @@ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
563} 563}
564EXPORT_SYMBOL(scsi_host_get); 564EXPORT_SYMBOL(scsi_host_get);
565 565
566struct scsi_host_mq_in_flight {
567 int cnt;
568};
569
570static void scsi_host_check_in_flight(struct request *rq, void *data,
571 bool reserved)
572{
573 struct scsi_host_mq_in_flight *in_flight = data;
574
575 if (blk_mq_request_started(rq))
576 in_flight->cnt++;
577}
578
579/** 566/**
580 * scsi_host_busy - Return the host busy counter 567 * scsi_host_busy - Return the host busy counter
581 * @shost: Pointer to Scsi_Host to inc. 568 * @shost: Pointer to Scsi_Host to inc.
582 **/ 569 **/
583int scsi_host_busy(struct Scsi_Host *shost) 570int scsi_host_busy(struct Scsi_Host *shost)
584{ 571{
585 struct scsi_host_mq_in_flight in_flight = { 572 return atomic_read(&shost->host_busy);
586 .cnt = 0,
587 };
588
589 if (!shost->use_blk_mq)
590 return atomic_read(&shost->host_busy);
591
592 blk_mq_tagset_busy_iter(&shost->tag_set, scsi_host_check_in_flight,
593 &in_flight);
594 return in_flight.cnt;
595} 573}
596EXPORT_SYMBOL(scsi_host_busy); 574EXPORT_SYMBOL(scsi_host_busy);
597 575
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 58bb70b886d7..c120929d4ffe 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -976,7 +976,7 @@ static struct scsi_host_template hpsa_driver_template = {
976#endif 976#endif
977 .sdev_attrs = hpsa_sdev_attrs, 977 .sdev_attrs = hpsa_sdev_attrs,
978 .shost_attrs = hpsa_shost_attrs, 978 .shost_attrs = hpsa_shost_attrs,
979 .max_sectors = 1024, 979 .max_sectors = 2048,
980 .no_write_same = 1, 980 .no_write_same = 1,
981}; 981};
982 982
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index e0d0da5f43d6..43732e8d1347 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -672,7 +672,7 @@ struct lpfc_hba {
672#define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */ 672#define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
673#define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */ 673#define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */
674#define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */ 674#define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
675#define LS_MDS_LOOPBACK 0x16 /* MDS Diagnostics Link Up (Loopback) */ 675#define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
676 676
677 uint32_t hba_flag; /* hba generic flags */ 677 uint32_t hba_flag; /* hba generic flags */
678#define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */ 678#define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 5a25553415f8..057a60abe664 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -5122,16 +5122,16 @@ LPFC_ATTR_R(enable_SmartSAN, 0, 0, 1, "Enable SmartSAN functionality");
5122 5122
5123/* 5123/*
5124# lpfc_fdmi_on: Controls FDMI support. 5124# lpfc_fdmi_on: Controls FDMI support.
5125# 0 No FDMI support (default) 5125# 0 No FDMI support
5126# 1 Traditional FDMI support 5126# 1 Traditional FDMI support (default)
5127# Traditional FDMI support means the driver will assume FDMI-2 support; 5127# Traditional FDMI support means the driver will assume FDMI-2 support;
5128# however, if that fails, it will fallback to FDMI-1. 5128# however, if that fails, it will fallback to FDMI-1.
5129# If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on. 5129# If lpfc_enable_SmartSAN is set to 1, the driver ignores lpfc_fdmi_on.
5130# If lpfc_enable_SmartSAN is set 0, the driver uses the current value of 5130# If lpfc_enable_SmartSAN is set 0, the driver uses the current value of
5131# lpfc_fdmi_on. 5131# lpfc_fdmi_on.
5132# Value range [0,1]. Default value is 0. 5132# Value range [0,1]. Default value is 1.
5133*/ 5133*/
5134LPFC_ATTR_R(fdmi_on, 0, 0, 1, "Enable FDMI support"); 5134LPFC_ATTR_R(fdmi_on, 1, 0, 1, "Enable FDMI support");
5135 5135
5136/* 5136/*
5137# Specifies the maximum number of ELS cmds we can have outstanding (for 5137# Specifies the maximum number of ELS cmds we can have outstanding (for
diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h
index fc3babc15fa3..a6f96b35e971 100644
--- a/drivers/scsi/qedi/qedi.h
+++ b/drivers/scsi/qedi/qedi.h
@@ -77,6 +77,11 @@ enum qedi_nvm_tgts {
77 QEDI_NVM_TGT_SEC, 77 QEDI_NVM_TGT_SEC,
78}; 78};
79 79
80struct qedi_nvm_iscsi_image {
81 struct nvm_iscsi_cfg iscsi_cfg;
82 u32 crc;
83};
84
80struct qedi_uio_ctrl { 85struct qedi_uio_ctrl {
81 /* meta data */ 86 /* meta data */
82 u32 uio_hsi_version; 87 u32 uio_hsi_version;
@@ -294,7 +299,7 @@ struct qedi_ctx {
294 void *bdq_pbl_list; 299 void *bdq_pbl_list;
295 dma_addr_t bdq_pbl_list_dma; 300 dma_addr_t bdq_pbl_list_dma;
296 u8 bdq_pbl_list_num_entries; 301 u8 bdq_pbl_list_num_entries;
297 struct nvm_iscsi_cfg *iscsi_cfg; 302 struct qedi_nvm_iscsi_image *iscsi_image;
298 dma_addr_t nvm_buf_dma; 303 dma_addr_t nvm_buf_dma;
299 void __iomem *bdq_primary_prod; 304 void __iomem *bdq_primary_prod;
300 void __iomem *bdq_secondary_prod; 305 void __iomem *bdq_secondary_prod;
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index aa96bccb5a96..cc8e64dc65ad 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -1346,23 +1346,26 @@ exit_setup_int:
1346 1346
1347static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) 1347static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi)
1348{ 1348{
1349 if (qedi->iscsi_cfg) 1349 if (qedi->iscsi_image)
1350 dma_free_coherent(&qedi->pdev->dev, 1350 dma_free_coherent(&qedi->pdev->dev,
1351 sizeof(struct nvm_iscsi_cfg), 1351 sizeof(struct qedi_nvm_iscsi_image),
1352 qedi->iscsi_cfg, qedi->nvm_buf_dma); 1352 qedi->iscsi_image, qedi->nvm_buf_dma);
1353} 1353}
1354 1354
1355static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) 1355static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi)
1356{ 1356{
1357 qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev, 1357 struct qedi_nvm_iscsi_image nvm_image;
1358 sizeof(struct nvm_iscsi_cfg), 1358
1359 &qedi->nvm_buf_dma, GFP_KERNEL); 1359 qedi->iscsi_image = dma_zalloc_coherent(&qedi->pdev->dev,
1360 if (!qedi->iscsi_cfg) { 1360 sizeof(nvm_image),
1361 &qedi->nvm_buf_dma,
1362 GFP_KERNEL);
1363 if (!qedi->iscsi_image) {
1361 QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); 1364 QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n");
1362 return -ENOMEM; 1365 return -ENOMEM;
1363 } 1366 }
1364 QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, 1367 QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
1365 "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg, 1368 "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_image,
1366 qedi->nvm_buf_dma); 1369 qedi->nvm_buf_dma);
1367 1370
1368 return 0; 1371 return 0;
@@ -1905,7 +1908,7 @@ qedi_get_nvram_block(struct qedi_ctx *qedi)
1905 struct nvm_iscsi_block *block; 1908 struct nvm_iscsi_block *block;
1906 1909
1907 pf = qedi->dev_info.common.abs_pf_id; 1910 pf = qedi->dev_info.common.abs_pf_id;
1908 block = &qedi->iscsi_cfg->block[0]; 1911 block = &qedi->iscsi_image->iscsi_cfg.block[0];
1909 for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { 1912 for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) {
1910 flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> 1913 flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >>
1911 NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; 1914 NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET;
@@ -2194,15 +2197,14 @@ static void qedi_boot_release(void *data)
2194static int qedi_get_boot_info(struct qedi_ctx *qedi) 2197static int qedi_get_boot_info(struct qedi_ctx *qedi)
2195{ 2198{
2196 int ret = 1; 2199 int ret = 1;
2197 u16 len; 2200 struct qedi_nvm_iscsi_image nvm_image;
2198
2199 len = sizeof(struct nvm_iscsi_cfg);
2200 2201
2201 QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, 2202 QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
2202 "Get NVM iSCSI CFG image\n"); 2203 "Get NVM iSCSI CFG image\n");
2203 ret = qedi_ops->common->nvm_get_image(qedi->cdev, 2204 ret = qedi_ops->common->nvm_get_image(qedi->cdev,
2204 QED_NVM_IMAGE_ISCSI_CFG, 2205 QED_NVM_IMAGE_ISCSI_CFG,
2205 (char *)qedi->iscsi_cfg, len); 2206 (char *)qedi->iscsi_image,
2207 sizeof(nvm_image));
2206 if (ret) 2208 if (ret)
2207 QEDI_ERR(&qedi->dbg_ctx, 2209 QEDI_ERR(&qedi->dbg_ctx,
2208 "Could not get NVM image. ret = %d\n", ret); 2210 "Could not get NVM image. ret = %d\n", ret);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0adfb3bce0fd..eb97d2dd3651 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -345,8 +345,7 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost)
345 unsigned long flags; 345 unsigned long flags;
346 346
347 rcu_read_lock(); 347 rcu_read_lock();
348 if (!shost->use_blk_mq) 348 atomic_dec(&shost->host_busy);
349 atomic_dec(&shost->host_busy);
350 if (unlikely(scsi_host_in_recovery(shost))) { 349 if (unlikely(scsi_host_in_recovery(shost))) {
351 spin_lock_irqsave(shost->host_lock, flags); 350 spin_lock_irqsave(shost->host_lock, flags);
352 if (shost->host_failed || shost->host_eh_scheduled) 351 if (shost->host_failed || shost->host_eh_scheduled)
@@ -445,12 +444,7 @@ static inline bool scsi_target_is_busy(struct scsi_target *starget)
445 444
446static inline bool scsi_host_is_busy(struct Scsi_Host *shost) 445static inline bool scsi_host_is_busy(struct Scsi_Host *shost)
447{ 446{
448 /* 447 if (shost->can_queue > 0 &&
449 * blk-mq can handle host queue busy efficiently via host-wide driver
450 * tag allocation
451 */
452
453 if (!shost->use_blk_mq && shost->can_queue > 0 &&
454 atomic_read(&shost->host_busy) >= shost->can_queue) 448 atomic_read(&shost->host_busy) >= shost->can_queue)
455 return true; 449 return true;
456 if (atomic_read(&shost->host_blocked) > 0) 450 if (atomic_read(&shost->host_blocked) > 0)
@@ -1606,10 +1600,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
1606 if (scsi_host_in_recovery(shost)) 1600 if (scsi_host_in_recovery(shost))
1607 return 0; 1601 return 0;
1608 1602
1609 if (!shost->use_blk_mq) 1603 busy = atomic_inc_return(&shost->host_busy) - 1;
1610 busy = atomic_inc_return(&shost->host_busy) - 1;
1611 else
1612 busy = 0;
1613 if (atomic_read(&shost->host_blocked) > 0) { 1604 if (atomic_read(&shost->host_blocked) > 0) {
1614 if (busy) 1605 if (busy)
1615 goto starved; 1606 goto starved;
@@ -1625,7 +1616,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
1625 "unblocking host at zero depth\n")); 1616 "unblocking host at zero depth\n"));
1626 } 1617 }
1627 1618
1628 if (!shost->use_blk_mq && shost->can_queue > 0 && busy >= shost->can_queue) 1619 if (shost->can_queue > 0 && busy >= shost->can_queue)
1629 goto starved; 1620 goto starved;
1630 if (shost->host_self_blocked) 1621 if (shost->host_self_blocked)
1631 goto starved; 1622 goto starved;
@@ -1711,9 +1702,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
1711 * with the locks as normal issue path does. 1702 * with the locks as normal issue path does.
1712 */ 1703 */
1713 atomic_inc(&sdev->device_busy); 1704 atomic_inc(&sdev->device_busy);
1714 1705 atomic_inc(&shost->host_busy);
1715 if (!shost->use_blk_mq)
1716 atomic_inc(&shost->host_busy);
1717 if (starget->can_queue > 0) 1706 if (starget->can_queue > 0)
1718 atomic_inc(&starget->target_busy); 1707 atomic_inc(&starget->target_busy);
1719 1708
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c
index 768cce0ccb80..76a262674c8d 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c
@@ -207,8 +207,8 @@ cxgbit_ddp_reserve(struct cxgbit_sock *csk, struct cxgbi_task_tag_info *ttinfo,
207 ret = dma_map_sg(&ppm->pdev->dev, sgl, sgcnt, DMA_FROM_DEVICE); 207 ret = dma_map_sg(&ppm->pdev->dev, sgl, sgcnt, DMA_FROM_DEVICE);
208 sgl->offset = sg_offset; 208 sgl->offset = sg_offset;
209 if (!ret) { 209 if (!ret) {
210 pr_info("%s: 0x%x, xfer %u, sgl %u dma mapping err.\n", 210 pr_debug("%s: 0x%x, xfer %u, sgl %u dma mapping err.\n",
211 __func__, 0, xferlen, sgcnt); 211 __func__, 0, xferlen, sgcnt);
212 goto rel_ppods; 212 goto rel_ppods;
213 } 213 }
214 214
@@ -250,8 +250,8 @@ cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
250 250
251 ret = cxgbit_ddp_reserve(csk, ttinfo, cmd->se_cmd.data_length); 251 ret = cxgbit_ddp_reserve(csk, ttinfo, cmd->se_cmd.data_length);
252 if (ret < 0) { 252 if (ret < 0) {
253 pr_info("csk 0x%p, cmd 0x%p, xfer len %u, sgcnt %u no ddp.\n", 253 pr_debug("csk 0x%p, cmd 0x%p, xfer len %u, sgcnt %u no ddp.\n",
254 csk, cmd, cmd->se_cmd.data_length, ttinfo->nents); 254 csk, cmd, cmd->se_cmd.data_length, ttinfo->nents);
255 255
256 ttinfo->sgl = NULL; 256 ttinfo->sgl = NULL;
257 ttinfo->nents = 0; 257 ttinfo->nents = 0;
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 94bad43c41ff..9cdfccbdd06f 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -4208,22 +4208,15 @@ int iscsit_close_connection(
4208 crypto_free_ahash(tfm); 4208 crypto_free_ahash(tfm);
4209 } 4209 }
4210 4210
4211 free_cpumask_var(conn->conn_cpumask);
4212
4213 kfree(conn->conn_ops);
4214 conn->conn_ops = NULL;
4215
4216 if (conn->sock) 4211 if (conn->sock)
4217 sock_release(conn->sock); 4212 sock_release(conn->sock);
4218 4213
4219 if (conn->conn_transport->iscsit_free_conn) 4214 if (conn->conn_transport->iscsit_free_conn)
4220 conn->conn_transport->iscsit_free_conn(conn); 4215 conn->conn_transport->iscsit_free_conn(conn);
4221 4216
4222 iscsit_put_transport(conn->conn_transport);
4223
4224 pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); 4217 pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
4225 conn->conn_state = TARG_CONN_STATE_FREE; 4218 conn->conn_state = TARG_CONN_STATE_FREE;
4226 kfree(conn); 4219 iscsit_free_conn(conn);
4227 4220
4228 spin_lock_bh(&sess->conn_lock); 4221 spin_lock_bh(&sess->conn_lock);
4229 atomic_dec(&sess->nconn); 4222 atomic_dec(&sess->nconn);
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 9e74f8bc2963..bb90c80ff388 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -67,45 +67,10 @@ static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn)
67 goto out_req_buf; 67 goto out_req_buf;
68 } 68 }
69 69
70 conn->conn_ops = kzalloc(sizeof(struct iscsi_conn_ops), GFP_KERNEL);
71 if (!conn->conn_ops) {
72 pr_err("Unable to allocate memory for"
73 " struct iscsi_conn_ops.\n");
74 goto out_rsp_buf;
75 }
76
77 init_waitqueue_head(&conn->queues_wq);
78 INIT_LIST_HEAD(&conn->conn_list);
79 INIT_LIST_HEAD(&conn->conn_cmd_list);
80 INIT_LIST_HEAD(&conn->immed_queue_list);
81 INIT_LIST_HEAD(&conn->response_queue_list);
82 init_completion(&conn->conn_post_wait_comp);
83 init_completion(&conn->conn_wait_comp);
84 init_completion(&conn->conn_wait_rcfr_comp);
85 init_completion(&conn->conn_waiting_on_uc_comp);
86 init_completion(&conn->conn_logout_comp);
87 init_completion(&conn->rx_half_close_comp);
88 init_completion(&conn->tx_half_close_comp);
89 init_completion(&conn->rx_login_comp);
90 spin_lock_init(&conn->cmd_lock);
91 spin_lock_init(&conn->conn_usage_lock);
92 spin_lock_init(&conn->immed_queue_lock);
93 spin_lock_init(&conn->nopin_timer_lock);
94 spin_lock_init(&conn->response_queue_lock);
95 spin_lock_init(&conn->state_lock);
96
97 if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) {
98 pr_err("Unable to allocate conn->conn_cpumask\n");
99 goto out_conn_ops;
100 }
101 conn->conn_login = login; 70 conn->conn_login = login;
102 71
103 return login; 72 return login;
104 73
105out_conn_ops:
106 kfree(conn->conn_ops);
107out_rsp_buf:
108 kfree(login->rsp_buf);
109out_req_buf: 74out_req_buf:
110 kfree(login->req_buf); 75 kfree(login->req_buf);
111out_login: 76out_login:
@@ -310,11 +275,9 @@ static int iscsi_login_zero_tsih_s1(
310 return -ENOMEM; 275 return -ENOMEM;
311 } 276 }
312 277
313 ret = iscsi_login_set_conn_values(sess, conn, pdu->cid); 278 if (iscsi_login_set_conn_values(sess, conn, pdu->cid))
314 if (unlikely(ret)) { 279 goto free_sess;
315 kfree(sess); 280
316 return ret;
317 }
318 sess->init_task_tag = pdu->itt; 281 sess->init_task_tag = pdu->itt;
319 memcpy(&sess->isid, pdu->isid, 6); 282 memcpy(&sess->isid, pdu->isid, 6);
320 sess->exp_cmd_sn = be32_to_cpu(pdu->cmdsn); 283 sess->exp_cmd_sn = be32_to_cpu(pdu->cmdsn);
@@ -1149,6 +1112,75 @@ iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t)
1149 return 0; 1112 return 0;
1150} 1113}
1151 1114
1115static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np)
1116{
1117 struct iscsi_conn *conn;
1118
1119 conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL);
1120 if (!conn) {
1121 pr_err("Could not allocate memory for new connection\n");
1122 return NULL;
1123 }
1124 pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
1125 conn->conn_state = TARG_CONN_STATE_FREE;
1126
1127 init_waitqueue_head(&conn->queues_wq);
1128 INIT_LIST_HEAD(&conn->conn_list);
1129 INIT_LIST_HEAD(&conn->conn_cmd_list);
1130 INIT_LIST_HEAD(&conn->immed_queue_list);
1131 INIT_LIST_HEAD(&conn->response_queue_list);
1132 init_completion(&conn->conn_post_wait_comp);
1133 init_completion(&conn->conn_wait_comp);
1134 init_completion(&conn->conn_wait_rcfr_comp);
1135 init_completion(&conn->conn_waiting_on_uc_comp);
1136 init_completion(&conn->conn_logout_comp);
1137 init_completion(&conn->rx_half_close_comp);
1138 init_completion(&conn->tx_half_close_comp);
1139 init_completion(&conn->rx_login_comp);
1140 spin_lock_init(&conn->cmd_lock);
1141 spin_lock_init(&conn->conn_usage_lock);
1142 spin_lock_init(&conn->immed_queue_lock);
1143 spin_lock_init(&conn->nopin_timer_lock);
1144 spin_lock_init(&conn->response_queue_lock);
1145 spin_lock_init(&conn->state_lock);
1146
1147 timer_setup(&conn->nopin_response_timer,
1148 iscsit_handle_nopin_response_timeout, 0);
1149 timer_setup(&conn->nopin_timer, iscsit_handle_nopin_timeout, 0);
1150
1151 if (iscsit_conn_set_transport(conn, np->np_transport) < 0)
1152 goto free_conn;
1153
1154 conn->conn_ops = kzalloc(sizeof(struct iscsi_conn_ops), GFP_KERNEL);
1155 if (!conn->conn_ops) {
1156 pr_err("Unable to allocate memory for struct iscsi_conn_ops.\n");
1157 goto put_transport;
1158 }
1159
1160 if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) {
1161 pr_err("Unable to allocate conn->conn_cpumask\n");
1162 goto free_mask;
1163 }
1164
1165 return conn;
1166
1167free_mask:
1168 free_cpumask_var(conn->conn_cpumask);
1169put_transport:
1170 iscsit_put_transport(conn->conn_transport);
1171free_conn:
1172 kfree(conn);
1173 return NULL;
1174}
1175
1176void iscsit_free_conn(struct iscsi_conn *conn)
1177{
1178 free_cpumask_var(conn->conn_cpumask);
1179 kfree(conn->conn_ops);
1180 iscsit_put_transport(conn->conn_transport);
1181 kfree(conn);
1182}
1183
1152void iscsi_target_login_sess_out(struct iscsi_conn *conn, 1184void iscsi_target_login_sess_out(struct iscsi_conn *conn,
1153 struct iscsi_np *np, bool zero_tsih, bool new_sess) 1185 struct iscsi_np *np, bool zero_tsih, bool new_sess)
1154{ 1186{
@@ -1198,10 +1230,6 @@ old_sess_out:
1198 crypto_free_ahash(tfm); 1230 crypto_free_ahash(tfm);
1199 } 1231 }
1200 1232
1201 free_cpumask_var(conn->conn_cpumask);
1202
1203 kfree(conn->conn_ops);
1204
1205 if (conn->param_list) { 1233 if (conn->param_list) {
1206 iscsi_release_param_list(conn->param_list); 1234 iscsi_release_param_list(conn->param_list);
1207 conn->param_list = NULL; 1235 conn->param_list = NULL;
@@ -1219,8 +1247,7 @@ old_sess_out:
1219 if (conn->conn_transport->iscsit_free_conn) 1247 if (conn->conn_transport->iscsit_free_conn)
1220 conn->conn_transport->iscsit_free_conn(conn); 1248 conn->conn_transport->iscsit_free_conn(conn);
1221 1249
1222 iscsit_put_transport(conn->conn_transport); 1250 iscsit_free_conn(conn);
1223 kfree(conn);
1224} 1251}
1225 1252
1226static int __iscsi_target_login_thread(struct iscsi_np *np) 1253static int __iscsi_target_login_thread(struct iscsi_np *np)
@@ -1250,31 +1277,16 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
1250 } 1277 }
1251 spin_unlock_bh(&np->np_thread_lock); 1278 spin_unlock_bh(&np->np_thread_lock);
1252 1279
1253 conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); 1280 conn = iscsit_alloc_conn(np);
1254 if (!conn) { 1281 if (!conn) {
1255 pr_err("Could not allocate memory for"
1256 " new connection\n");
1257 /* Get another socket */ 1282 /* Get another socket */
1258 return 1; 1283 return 1;
1259 } 1284 }
1260 pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
1261 conn->conn_state = TARG_CONN_STATE_FREE;
1262
1263 timer_setup(&conn->nopin_response_timer,
1264 iscsit_handle_nopin_response_timeout, 0);
1265 timer_setup(&conn->nopin_timer, iscsit_handle_nopin_timeout, 0);
1266
1267 if (iscsit_conn_set_transport(conn, np->np_transport) < 0) {
1268 kfree(conn);
1269 return 1;
1270 }
1271 1285
1272 rc = np->np_transport->iscsit_accept_np(np, conn); 1286 rc = np->np_transport->iscsit_accept_np(np, conn);
1273 if (rc == -ENOSYS) { 1287 if (rc == -ENOSYS) {
1274 complete(&np->np_restart_comp); 1288 complete(&np->np_restart_comp);
1275 iscsit_put_transport(conn->conn_transport); 1289 iscsit_free_conn(conn);
1276 kfree(conn);
1277 conn = NULL;
1278 goto exit; 1290 goto exit;
1279 } else if (rc < 0) { 1291 } else if (rc < 0) {
1280 spin_lock_bh(&np->np_thread_lock); 1292 spin_lock_bh(&np->np_thread_lock);
@@ -1282,17 +1294,13 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
1282 np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; 1294 np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
1283 spin_unlock_bh(&np->np_thread_lock); 1295 spin_unlock_bh(&np->np_thread_lock);
1284 complete(&np->np_restart_comp); 1296 complete(&np->np_restart_comp);
1285 iscsit_put_transport(conn->conn_transport); 1297 iscsit_free_conn(conn);
1286 kfree(conn);
1287 conn = NULL;
1288 /* Get another socket */ 1298 /* Get another socket */
1289 return 1; 1299 return 1;
1290 } 1300 }
1291 spin_unlock_bh(&np->np_thread_lock); 1301 spin_unlock_bh(&np->np_thread_lock);
1292 iscsit_put_transport(conn->conn_transport); 1302 iscsit_free_conn(conn);
1293 kfree(conn); 1303 return 1;
1294 conn = NULL;
1295 goto out;
1296 } 1304 }
1297 /* 1305 /*
1298 * Perform the remaining iSCSI connection initialization items.. 1306 * Perform the remaining iSCSI connection initialization items..
@@ -1442,7 +1450,6 @@ old_sess_out:
1442 tpg_np = NULL; 1450 tpg_np = NULL;
1443 } 1451 }
1444 1452
1445out:
1446 return 1; 1453 return 1;
1447 1454
1448exit: 1455exit:
diff --git a/drivers/target/iscsi/iscsi_target_login.h b/drivers/target/iscsi/iscsi_target_login.h
index 74ac3abc44a0..3b8e3639ff5d 100644
--- a/drivers/target/iscsi/iscsi_target_login.h
+++ b/drivers/target/iscsi/iscsi_target_login.h
@@ -19,7 +19,7 @@ extern int iscsi_target_setup_login_socket(struct iscsi_np *,
19extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *); 19extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *);
20extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *); 20extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);
21extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); 21extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);
22extern void iscsit_free_conn(struct iscsi_np *, struct iscsi_conn *); 22extern void iscsit_free_conn(struct iscsi_conn *);
23extern int iscsit_start_kthreads(struct iscsi_conn *); 23extern int iscsit_start_kthreads(struct iscsi_conn *);
24extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8); 24extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8);
25extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *, 25extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *,
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 0c3285c8db95..476dcbb79713 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -98,13 +98,13 @@ static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
98 goto inval; 98 goto inval;
99 99
100 args = strchr(name, ' '); 100 args = strchr(name, ' ');
101 if (!args) 101 if (args) {
102 goto inval; 102 do {
103 do { 103 *args++ = 0;
104 *args++ = 0; 104 } while(*args == ' ');
105 } while(*args == ' '); 105 if (!*args)
106 if (!*args) 106 goto inval;
107 goto inval; 107 }
108 108
109 /* determine command to perform */ 109 /* determine command to perform */
110 _debug("cmd=%s name=%s args=%s", buf, name, args); 110 _debug("cmd=%s name=%s args=%s", buf, name, args);
@@ -120,7 +120,6 @@ static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
120 120
121 if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags)) 121 if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags))
122 afs_put_cell(net, cell); 122 afs_put_cell(net, cell);
123 printk("kAFS: Added new cell '%s'\n", name);
124 } else { 123 } else {
125 goto inval; 124 goto inval;
126 } 125 }
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 53af9f5253f4..2cddfe7806a4 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1280,6 +1280,7 @@ struct btrfs_root {
1280 int send_in_progress; 1280 int send_in_progress;
1281 struct btrfs_subvolume_writers *subv_writers; 1281 struct btrfs_subvolume_writers *subv_writers;
1282 atomic_t will_be_snapshotted; 1282 atomic_t will_be_snapshotted;
1283 atomic_t snapshot_force_cow;
1283 1284
1284 /* For qgroup metadata reserved space */ 1285 /* For qgroup metadata reserved space */
1285 spinlock_t qgroup_meta_rsv_lock; 1286 spinlock_t qgroup_meta_rsv_lock;
@@ -3390,9 +3391,9 @@ do { \
3390#define btrfs_debug(fs_info, fmt, args...) \ 3391#define btrfs_debug(fs_info, fmt, args...) \
3391 btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args) 3392 btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
3392#define btrfs_debug_in_rcu(fs_info, fmt, args...) \ 3393#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
3393 btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args) 3394 btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
3394#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ 3395#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
3395 btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args) 3396 btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
3396#define btrfs_debug_rl(fs_info, fmt, args...) \ 3397#define btrfs_debug_rl(fs_info, fmt, args...) \
3397 btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args) 3398 btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
3398#endif 3399#endif
@@ -3404,6 +3405,13 @@ do { \
3404 rcu_read_unlock(); \ 3405 rcu_read_unlock(); \
3405} while (0) 3406} while (0)
3406 3407
3408#define btrfs_no_printk_in_rcu(fs_info, fmt, args...) \
3409do { \
3410 rcu_read_lock(); \
3411 btrfs_no_printk(fs_info, fmt, ##args); \
3412 rcu_read_unlock(); \
3413} while (0)
3414
3407#define btrfs_printk_ratelimited(fs_info, fmt, args...) \ 3415#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
3408do { \ 3416do { \
3409 static DEFINE_RATELIMIT_STATE(_rs, \ 3417 static DEFINE_RATELIMIT_STATE(_rs, \
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 5124c15705ce..05dc3c17cb62 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1187,6 +1187,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
1187 atomic_set(&root->log_batch, 0); 1187 atomic_set(&root->log_batch, 0);
1188 refcount_set(&root->refs, 1); 1188 refcount_set(&root->refs, 1);
1189 atomic_set(&root->will_be_snapshotted, 0); 1189 atomic_set(&root->will_be_snapshotted, 0);
1190 atomic_set(&root->snapshot_force_cow, 0);
1190 root->log_transid = 0; 1191 root->log_transid = 0;
1191 root->log_transid_committed = -1; 1192 root->log_transid_committed = -1;
1192 root->last_log_commit = 0; 1193 root->last_log_commit = 0;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index de6f75f5547b..2d9074295d7f 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5800,7 +5800,7 @@ void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans)
5800 * root: the root of the parent directory 5800 * root: the root of the parent directory
5801 * rsv: block reservation 5801 * rsv: block reservation
5802 * items: the number of items that we need do reservation 5802 * items: the number of items that we need do reservation
5803 * qgroup_reserved: used to return the reserved size in qgroup 5803 * use_global_rsv: allow fallback to the global block reservation
5804 * 5804 *
5805 * This function is used to reserve the space for snapshot/subvolume 5805 * This function is used to reserve the space for snapshot/subvolume
5806 * creation and deletion. Those operations are different with the 5806 * creation and deletion. Those operations are different with the
@@ -5810,10 +5810,10 @@ void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans)
5810 * the space reservation mechanism in start_transaction(). 5810 * the space reservation mechanism in start_transaction().
5811 */ 5811 */
5812int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, 5812int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
5813 struct btrfs_block_rsv *rsv, 5813 struct btrfs_block_rsv *rsv, int items,
5814 int items,
5815 bool use_global_rsv) 5814 bool use_global_rsv)
5816{ 5815{
5816 u64 qgroup_num_bytes = 0;
5817 u64 num_bytes; 5817 u64 num_bytes;
5818 int ret; 5818 int ret;
5819 struct btrfs_fs_info *fs_info = root->fs_info; 5819 struct btrfs_fs_info *fs_info = root->fs_info;
@@ -5821,12 +5821,11 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
5821 5821
5822 if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) { 5822 if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags)) {
5823 /* One for parent inode, two for dir entries */ 5823 /* One for parent inode, two for dir entries */
5824 num_bytes = 3 * fs_info->nodesize; 5824 qgroup_num_bytes = 3 * fs_info->nodesize;
5825 ret = btrfs_qgroup_reserve_meta_prealloc(root, num_bytes, true); 5825 ret = btrfs_qgroup_reserve_meta_prealloc(root,
5826 qgroup_num_bytes, true);
5826 if (ret) 5827 if (ret)
5827 return ret; 5828 return ret;
5828 } else {
5829 num_bytes = 0;
5830 } 5829 }
5831 5830
5832 num_bytes = btrfs_calc_trans_metadata_size(fs_info, items); 5831 num_bytes = btrfs_calc_trans_metadata_size(fs_info, items);
@@ -5838,8 +5837,8 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
5838 if (ret == -ENOSPC && use_global_rsv) 5837 if (ret == -ENOSPC && use_global_rsv)
5839 ret = btrfs_block_rsv_migrate(global_rsv, rsv, num_bytes, 1); 5838 ret = btrfs_block_rsv_migrate(global_rsv, rsv, num_bytes, 1);
5840 5839
5841 if (ret && num_bytes) 5840 if (ret && qgroup_num_bytes)
5842 btrfs_qgroup_free_meta_prealloc(root, num_bytes); 5841 btrfs_qgroup_free_meta_prealloc(root, qgroup_num_bytes);
5843 5842
5844 return ret; 5843 return ret;
5845} 5844}
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9357a19d2bff..3ea5339603cf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1271,7 +1271,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1271 u64 disk_num_bytes; 1271 u64 disk_num_bytes;
1272 u64 ram_bytes; 1272 u64 ram_bytes;
1273 int extent_type; 1273 int extent_type;
1274 int ret, err; 1274 int ret;
1275 int type; 1275 int type;
1276 int nocow; 1276 int nocow;
1277 int check_prev = 1; 1277 int check_prev = 1;
@@ -1403,11 +1403,8 @@ next_slot:
1403 * if there are pending snapshots for this root, 1403 * if there are pending snapshots for this root,
1404 * we fall into common COW way. 1404 * we fall into common COW way.
1405 */ 1405 */
1406 if (!nolock) { 1406 if (!nolock && atomic_read(&root->snapshot_force_cow))
1407 err = btrfs_start_write_no_snapshotting(root); 1407 goto out_check;
1408 if (!err)
1409 goto out_check;
1410 }
1411 /* 1408 /*
1412 * force cow if csum exists in the range. 1409 * force cow if csum exists in the range.
1413 * this ensure that csum for a given extent are 1410 * this ensure that csum for a given extent are
@@ -1416,9 +1413,6 @@ next_slot:
1416 ret = csum_exist_in_range(fs_info, disk_bytenr, 1413 ret = csum_exist_in_range(fs_info, disk_bytenr,
1417 num_bytes); 1414 num_bytes);
1418 if (ret) { 1415 if (ret) {
1419 if (!nolock)
1420 btrfs_end_write_no_snapshotting(root);
1421
1422 /* 1416 /*
1423 * ret could be -EIO if the above fails to read 1417 * ret could be -EIO if the above fails to read
1424 * metadata. 1418 * metadata.
@@ -1431,11 +1425,8 @@ next_slot:
1431 WARN_ON_ONCE(nolock); 1425 WARN_ON_ONCE(nolock);
1432 goto out_check; 1426 goto out_check;
1433 } 1427 }
1434 if (!btrfs_inc_nocow_writers(fs_info, disk_bytenr)) { 1428 if (!btrfs_inc_nocow_writers(fs_info, disk_bytenr))
1435 if (!nolock)
1436 btrfs_end_write_no_snapshotting(root);
1437 goto out_check; 1429 goto out_check;
1438 }
1439 nocow = 1; 1430 nocow = 1;
1440 } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 1431 } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
1441 extent_end = found_key.offset + 1432 extent_end = found_key.offset +
@@ -1448,8 +1439,6 @@ next_slot:
1448out_check: 1439out_check:
1449 if (extent_end <= start) { 1440 if (extent_end <= start) {
1450 path->slots[0]++; 1441 path->slots[0]++;
1451 if (!nolock && nocow)
1452 btrfs_end_write_no_snapshotting(root);
1453 if (nocow) 1442 if (nocow)
1454 btrfs_dec_nocow_writers(fs_info, disk_bytenr); 1443 btrfs_dec_nocow_writers(fs_info, disk_bytenr);
1455 goto next_slot; 1444 goto next_slot;
@@ -1471,8 +1460,6 @@ out_check:
1471 end, page_started, nr_written, 1, 1460 end, page_started, nr_written, 1,
1472 NULL); 1461 NULL);
1473 if (ret) { 1462 if (ret) {
1474 if (!nolock && nocow)
1475 btrfs_end_write_no_snapshotting(root);
1476 if (nocow) 1463 if (nocow)
1477 btrfs_dec_nocow_writers(fs_info, 1464 btrfs_dec_nocow_writers(fs_info,
1478 disk_bytenr); 1465 disk_bytenr);
@@ -1492,8 +1479,6 @@ out_check:
1492 ram_bytes, BTRFS_COMPRESS_NONE, 1479 ram_bytes, BTRFS_COMPRESS_NONE,
1493 BTRFS_ORDERED_PREALLOC); 1480 BTRFS_ORDERED_PREALLOC);
1494 if (IS_ERR(em)) { 1481 if (IS_ERR(em)) {
1495 if (!nolock && nocow)
1496 btrfs_end_write_no_snapshotting(root);
1497 if (nocow) 1482 if (nocow)
1498 btrfs_dec_nocow_writers(fs_info, 1483 btrfs_dec_nocow_writers(fs_info,
1499 disk_bytenr); 1484 disk_bytenr);
@@ -1532,8 +1517,6 @@ out_check:
1532 EXTENT_CLEAR_DATA_RESV, 1517 EXTENT_CLEAR_DATA_RESV,
1533 PAGE_UNLOCK | PAGE_SET_PRIVATE2); 1518 PAGE_UNLOCK | PAGE_SET_PRIVATE2);
1534 1519
1535 if (!nolock && nocow)
1536 btrfs_end_write_no_snapshotting(root);
1537 cur_offset = extent_end; 1520 cur_offset = extent_end;
1538 1521
1539 /* 1522 /*
@@ -6639,6 +6622,8 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
6639 drop_inode = 1; 6622 drop_inode = 1;
6640 } else { 6623 } else {
6641 struct dentry *parent = dentry->d_parent; 6624 struct dentry *parent = dentry->d_parent;
6625 int ret;
6626
6642 err = btrfs_update_inode(trans, root, inode); 6627 err = btrfs_update_inode(trans, root, inode);
6643 if (err) 6628 if (err)
6644 goto fail; 6629 goto fail;
@@ -6652,7 +6637,12 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
6652 goto fail; 6637 goto fail;
6653 } 6638 }
6654 d_instantiate(dentry, inode); 6639 d_instantiate(dentry, inode);
6655 btrfs_log_new_name(trans, BTRFS_I(inode), NULL, parent); 6640 ret = btrfs_log_new_name(trans, BTRFS_I(inode), NULL, parent,
6641 true, NULL);
6642 if (ret == BTRFS_NEED_TRANS_COMMIT) {
6643 err = btrfs_commit_transaction(trans);
6644 trans = NULL;
6645 }
6656 } 6646 }
6657 6647
6658fail: 6648fail:
@@ -9388,14 +9378,21 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9388 u64 new_idx = 0; 9378 u64 new_idx = 0;
9389 u64 root_objectid; 9379 u64 root_objectid;
9390 int ret; 9380 int ret;
9391 int ret2;
9392 bool root_log_pinned = false; 9381 bool root_log_pinned = false;
9393 bool dest_log_pinned = false; 9382 bool dest_log_pinned = false;
9383 struct btrfs_log_ctx ctx_root;
9384 struct btrfs_log_ctx ctx_dest;
9385 bool sync_log_root = false;
9386 bool sync_log_dest = false;
9387 bool commit_transaction = false;
9394 9388
9395 /* we only allow rename subvolume link between subvolumes */ 9389 /* we only allow rename subvolume link between subvolumes */
9396 if (old_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest) 9390 if (old_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest)
9397 return -EXDEV; 9391 return -EXDEV;
9398 9392
9393 btrfs_init_log_ctx(&ctx_root, old_inode);
9394 btrfs_init_log_ctx(&ctx_dest, new_inode);
9395
9399 /* close the race window with snapshot create/destroy ioctl */ 9396 /* close the race window with snapshot create/destroy ioctl */
9400 if (old_ino == BTRFS_FIRST_FREE_OBJECTID) 9397 if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
9401 down_read(&fs_info->subvol_sem); 9398 down_read(&fs_info->subvol_sem);
@@ -9542,15 +9539,29 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9542 9539
9543 if (root_log_pinned) { 9540 if (root_log_pinned) {
9544 parent = new_dentry->d_parent; 9541 parent = new_dentry->d_parent;
9545 btrfs_log_new_name(trans, BTRFS_I(old_inode), BTRFS_I(old_dir), 9542 ret = btrfs_log_new_name(trans, BTRFS_I(old_inode),
9546 parent); 9543 BTRFS_I(old_dir), parent,
9544 false, &ctx_root);
9545 if (ret == BTRFS_NEED_LOG_SYNC)
9546 sync_log_root = true;
9547 else if (ret == BTRFS_NEED_TRANS_COMMIT)
9548 commit_transaction = true;
9549 ret = 0;
9547 btrfs_end_log_trans(root); 9550 btrfs_end_log_trans(root);
9548 root_log_pinned = false; 9551 root_log_pinned = false;
9549 } 9552 }
9550 if (dest_log_pinned) { 9553 if (dest_log_pinned) {
9551 parent = old_dentry->d_parent; 9554 if (!commit_transaction) {
9552 btrfs_log_new_name(trans, BTRFS_I(new_inode), BTRFS_I(new_dir), 9555 parent = old_dentry->d_parent;
9553 parent); 9556 ret = btrfs_log_new_name(trans, BTRFS_I(new_inode),
9557 BTRFS_I(new_dir), parent,
9558 false, &ctx_dest);
9559 if (ret == BTRFS_NEED_LOG_SYNC)
9560 sync_log_dest = true;
9561 else if (ret == BTRFS_NEED_TRANS_COMMIT)
9562 commit_transaction = true;
9563 ret = 0;
9564 }
9554 btrfs_end_log_trans(dest); 9565 btrfs_end_log_trans(dest);
9555 dest_log_pinned = false; 9566 dest_log_pinned = false;
9556 } 9567 }
@@ -9583,8 +9594,26 @@ out_fail:
9583 dest_log_pinned = false; 9594 dest_log_pinned = false;
9584 } 9595 }
9585 } 9596 }
9586 ret2 = btrfs_end_transaction(trans); 9597 if (!ret && sync_log_root && !commit_transaction) {
9587 ret = ret ? ret : ret2; 9598 ret = btrfs_sync_log(trans, BTRFS_I(old_inode)->root,
9599 &ctx_root);
9600 if (ret)
9601 commit_transaction = true;
9602 }
9603 if (!ret && sync_log_dest && !commit_transaction) {
9604 ret = btrfs_sync_log(trans, BTRFS_I(new_inode)->root,
9605 &ctx_dest);
9606 if (ret)
9607 commit_transaction = true;
9608 }
9609 if (commit_transaction) {
9610 ret = btrfs_commit_transaction(trans);
9611 } else {
9612 int ret2;
9613
9614 ret2 = btrfs_end_transaction(trans);
9615 ret = ret ? ret : ret2;
9616 }
9588out_notrans: 9617out_notrans:
9589 if (new_ino == BTRFS_FIRST_FREE_OBJECTID) 9618 if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
9590 up_read(&fs_info->subvol_sem); 9619 up_read(&fs_info->subvol_sem);
@@ -9661,6 +9690,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9661 int ret; 9690 int ret;
9662 u64 old_ino = btrfs_ino(BTRFS_I(old_inode)); 9691 u64 old_ino = btrfs_ino(BTRFS_I(old_inode));
9663 bool log_pinned = false; 9692 bool log_pinned = false;
9693 struct btrfs_log_ctx ctx;
9694 bool sync_log = false;
9695 bool commit_transaction = false;
9664 9696
9665 if (btrfs_ino(BTRFS_I(new_dir)) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) 9697 if (btrfs_ino(BTRFS_I(new_dir)) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)
9666 return -EPERM; 9698 return -EPERM;
@@ -9818,8 +9850,15 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9818 if (log_pinned) { 9850 if (log_pinned) {
9819 struct dentry *parent = new_dentry->d_parent; 9851 struct dentry *parent = new_dentry->d_parent;
9820 9852
9821 btrfs_log_new_name(trans, BTRFS_I(old_inode), BTRFS_I(old_dir), 9853 btrfs_init_log_ctx(&ctx, old_inode);
9822 parent); 9854 ret = btrfs_log_new_name(trans, BTRFS_I(old_inode),
9855 BTRFS_I(old_dir), parent,
9856 false, &ctx);
9857 if (ret == BTRFS_NEED_LOG_SYNC)
9858 sync_log = true;
9859 else if (ret == BTRFS_NEED_TRANS_COMMIT)
9860 commit_transaction = true;
9861 ret = 0;
9823 btrfs_end_log_trans(root); 9862 btrfs_end_log_trans(root);
9824 log_pinned = false; 9863 log_pinned = false;
9825 } 9864 }
@@ -9856,7 +9895,19 @@ out_fail:
9856 btrfs_end_log_trans(root); 9895 btrfs_end_log_trans(root);
9857 log_pinned = false; 9896 log_pinned = false;
9858 } 9897 }
9859 btrfs_end_transaction(trans); 9898 if (!ret && sync_log) {
9899 ret = btrfs_sync_log(trans, BTRFS_I(old_inode)->root, &ctx);
9900 if (ret)
9901 commit_transaction = true;
9902 }
9903 if (commit_transaction) {
9904 ret = btrfs_commit_transaction(trans);
9905 } else {
9906 int ret2;
9907
9908 ret2 = btrfs_end_transaction(trans);
9909 ret = ret ? ret : ret2;
9910 }
9860out_notrans: 9911out_notrans:
9861 if (old_ino == BTRFS_FIRST_FREE_OBJECTID) 9912 if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
9862 up_read(&fs_info->subvol_sem); 9913 up_read(&fs_info->subvol_sem);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 63600dc2ac4c..d60b6caf09e8 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -747,6 +747,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
747 struct btrfs_pending_snapshot *pending_snapshot; 747 struct btrfs_pending_snapshot *pending_snapshot;
748 struct btrfs_trans_handle *trans; 748 struct btrfs_trans_handle *trans;
749 int ret; 749 int ret;
750 bool snapshot_force_cow = false;
750 751
751 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) 752 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state))
752 return -EINVAL; 753 return -EINVAL;
@@ -763,6 +764,11 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
763 goto free_pending; 764 goto free_pending;
764 } 765 }
765 766
767 /*
768 * Force new buffered writes to reserve space even when NOCOW is
769 * possible. This is to avoid later writeback (running dealloc) to
770 * fallback to COW mode and unexpectedly fail with ENOSPC.
771 */
766 atomic_inc(&root->will_be_snapshotted); 772 atomic_inc(&root->will_be_snapshotted);
767 smp_mb__after_atomic(); 773 smp_mb__after_atomic();
768 /* wait for no snapshot writes */ 774 /* wait for no snapshot writes */
@@ -773,6 +779,14 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
773 if (ret) 779 if (ret)
774 goto dec_and_free; 780 goto dec_and_free;
775 781
782 /*
783 * All previous writes have started writeback in NOCOW mode, so now
784 * we force future writes to fallback to COW mode during snapshot
785 * creation.
786 */
787 atomic_inc(&root->snapshot_force_cow);
788 snapshot_force_cow = true;
789
776 btrfs_wait_ordered_extents(root, U64_MAX, 0, (u64)-1); 790 btrfs_wait_ordered_extents(root, U64_MAX, 0, (u64)-1);
777 791
778 btrfs_init_block_rsv(&pending_snapshot->block_rsv, 792 btrfs_init_block_rsv(&pending_snapshot->block_rsv,
@@ -837,6 +851,8 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
837fail: 851fail:
838 btrfs_subvolume_release_metadata(fs_info, &pending_snapshot->block_rsv); 852 btrfs_subvolume_release_metadata(fs_info, &pending_snapshot->block_rsv);
839dec_and_free: 853dec_and_free:
854 if (snapshot_force_cow)
855 atomic_dec(&root->snapshot_force_cow);
840 if (atomic_dec_and_test(&root->will_be_snapshotted)) 856 if (atomic_dec_and_test(&root->will_be_snapshotted))
841 wake_up_var(&root->will_be_snapshotted); 857 wake_up_var(&root->will_be_snapshotted);
842free_pending: 858free_pending:
@@ -3453,6 +3469,25 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 olen,
3453 3469
3454 same_lock_start = min_t(u64, loff, dst_loff); 3470 same_lock_start = min_t(u64, loff, dst_loff);
3455 same_lock_len = max_t(u64, loff, dst_loff) + len - same_lock_start; 3471 same_lock_len = max_t(u64, loff, dst_loff) + len - same_lock_start;
3472 } else {
3473 /*
3474 * If the source and destination inodes are different, the
3475 * source's range end offset matches the source's i_size, that
3476 * i_size is not a multiple of the sector size, and the
3477 * destination range does not go past the destination's i_size,
3478 * we must round down the length to the nearest sector size
3479 * multiple. If we don't do this adjustment we end replacing
3480 * with zeroes the bytes in the range that starts at the
3481 * deduplication range's end offset and ends at the next sector
3482 * size multiple.
3483 */
3484 if (loff + olen == i_size_read(src) &&
3485 dst_loff + len < i_size_read(dst)) {
3486 const u64 sz = BTRFS_I(src)->root->fs_info->sectorsize;
3487
3488 len = round_down(i_size_read(src), sz) - loff;
3489 olen = len;
3490 }
3456 } 3491 }
3457 3492
3458again: 3493again:
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 4353bb69bb86..d4917c0cddf5 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1019,10 +1019,9 @@ out_add_root:
1019 spin_unlock(&fs_info->qgroup_lock); 1019 spin_unlock(&fs_info->qgroup_lock);
1020 1020
1021 ret = btrfs_commit_transaction(trans); 1021 ret = btrfs_commit_transaction(trans);
1022 if (ret) { 1022 trans = NULL;
1023 trans = NULL; 1023 if (ret)
1024 goto out_free_path; 1024 goto out_free_path;
1025 }
1026 1025
1027 ret = qgroup_rescan_init(fs_info, 0, 1); 1026 ret = qgroup_rescan_init(fs_info, 0, 1);
1028 if (!ret) { 1027 if (!ret) {
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1650dc44a5e3..3c2ae0e4f25a 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -6025,14 +6025,25 @@ void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans,
6025 * Call this after adding a new name for a file and it will properly 6025 * Call this after adding a new name for a file and it will properly
6026 * update the log to reflect the new name. 6026 * update the log to reflect the new name.
6027 * 6027 *
6028 * It will return zero if all goes well, and it will return 1 if a 6028 * @ctx can not be NULL when @sync_log is false, and should be NULL when it's
6029 * full transaction commit is required. 6029 * true (because it's not used).
6030 *
6031 * Return value depends on whether @sync_log is true or false.
6032 * When true: returns BTRFS_NEED_TRANS_COMMIT if the transaction needs to be
6033 * committed by the caller, and BTRFS_DONT_NEED_TRANS_COMMIT
6034 * otherwise.
6035 * When false: returns BTRFS_DONT_NEED_LOG_SYNC if the caller does not need to
6036 * to sync the log, BTRFS_NEED_LOG_SYNC if it needs to sync the log,
6037 * or BTRFS_NEED_TRANS_COMMIT if the transaction needs to be
6038 * committed (without attempting to sync the log).
6030 */ 6039 */
6031int btrfs_log_new_name(struct btrfs_trans_handle *trans, 6040int btrfs_log_new_name(struct btrfs_trans_handle *trans,
6032 struct btrfs_inode *inode, struct btrfs_inode *old_dir, 6041 struct btrfs_inode *inode, struct btrfs_inode *old_dir,
6033 struct dentry *parent) 6042 struct dentry *parent,
6043 bool sync_log, struct btrfs_log_ctx *ctx)
6034{ 6044{
6035 struct btrfs_fs_info *fs_info = trans->fs_info; 6045 struct btrfs_fs_info *fs_info = trans->fs_info;
6046 int ret;
6036 6047
6037 /* 6048 /*
6038 * this will force the logging code to walk the dentry chain 6049 * this will force the logging code to walk the dentry chain
@@ -6047,9 +6058,34 @@ int btrfs_log_new_name(struct btrfs_trans_handle *trans,
6047 */ 6058 */
6048 if (inode->logged_trans <= fs_info->last_trans_committed && 6059 if (inode->logged_trans <= fs_info->last_trans_committed &&
6049 (!old_dir || old_dir->logged_trans <= fs_info->last_trans_committed)) 6060 (!old_dir || old_dir->logged_trans <= fs_info->last_trans_committed))
6050 return 0; 6061 return sync_log ? BTRFS_DONT_NEED_TRANS_COMMIT :
6062 BTRFS_DONT_NEED_LOG_SYNC;
6063
6064 if (sync_log) {
6065 struct btrfs_log_ctx ctx2;
6066
6067 btrfs_init_log_ctx(&ctx2, &inode->vfs_inode);
6068 ret = btrfs_log_inode_parent(trans, inode, parent, 0, LLONG_MAX,
6069 LOG_INODE_EXISTS, &ctx2);
6070 if (ret == BTRFS_NO_LOG_SYNC)
6071 return BTRFS_DONT_NEED_TRANS_COMMIT;
6072 else if (ret)
6073 return BTRFS_NEED_TRANS_COMMIT;
6074
6075 ret = btrfs_sync_log(trans, inode->root, &ctx2);
6076 if (ret)
6077 return BTRFS_NEED_TRANS_COMMIT;
6078 return BTRFS_DONT_NEED_TRANS_COMMIT;
6079 }
6080
6081 ASSERT(ctx);
6082 ret = btrfs_log_inode_parent(trans, inode, parent, 0, LLONG_MAX,
6083 LOG_INODE_EXISTS, ctx);
6084 if (ret == BTRFS_NO_LOG_SYNC)
6085 return BTRFS_DONT_NEED_LOG_SYNC;
6086 else if (ret)
6087 return BTRFS_NEED_TRANS_COMMIT;
6051 6088
6052 return btrfs_log_inode_parent(trans, inode, parent, 0, LLONG_MAX, 6089 return BTRFS_NEED_LOG_SYNC;
6053 LOG_INODE_EXISTS, NULL);
6054} 6090}
6055 6091
diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
index 122e68b89a5a..7ab9bb88a639 100644
--- a/fs/btrfs/tree-log.h
+++ b/fs/btrfs/tree-log.h
@@ -71,8 +71,16 @@ void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
71 int for_rename); 71 int for_rename);
72void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans, 72void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans,
73 struct btrfs_inode *dir); 73 struct btrfs_inode *dir);
74/* Return values for btrfs_log_new_name() */
75enum {
76 BTRFS_DONT_NEED_TRANS_COMMIT,
77 BTRFS_NEED_TRANS_COMMIT,
78 BTRFS_DONT_NEED_LOG_SYNC,
79 BTRFS_NEED_LOG_SYNC,
80};
74int btrfs_log_new_name(struct btrfs_trans_handle *trans, 81int btrfs_log_new_name(struct btrfs_trans_handle *trans,
75 struct btrfs_inode *inode, struct btrfs_inode *old_dir, 82 struct btrfs_inode *inode, struct btrfs_inode *old_dir,
76 struct dentry *parent); 83 struct dentry *parent,
84 bool sync_log, struct btrfs_log_ctx *ctx);
77 85
78#endif 86#endif
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index da86706123ff..f4405e430da6 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4491,7 +4491,12 @@ again:
4491 4491
4492 /* Now btrfs_update_device() will change the on-disk size. */ 4492 /* Now btrfs_update_device() will change the on-disk size. */
4493 ret = btrfs_update_device(trans, device); 4493 ret = btrfs_update_device(trans, device);
4494 btrfs_end_transaction(trans); 4494 if (ret < 0) {
4495 btrfs_abort_transaction(trans, ret);
4496 btrfs_end_transaction(trans);
4497 } else {
4498 ret = btrfs_commit_transaction(trans);
4499 }
4495done: 4500done:
4496 btrfs_free_path(path); 4501 btrfs_free_path(path);
4497 if (ret) { 4502 if (ret) {
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 43ca3b763875..eab1359d0553 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -602,6 +602,8 @@ static int extra_mon_dispatch(struct ceph_client *client, struct ceph_msg *msg)
602 602
603/* 603/*
604 * create a new fs client 604 * create a new fs client
605 *
606 * Success or not, this function consumes @fsopt and @opt.
605 */ 607 */
606static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt, 608static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
607 struct ceph_options *opt) 609 struct ceph_options *opt)
@@ -609,17 +611,20 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
609 struct ceph_fs_client *fsc; 611 struct ceph_fs_client *fsc;
610 int page_count; 612 int page_count;
611 size_t size; 613 size_t size;
612 int err = -ENOMEM; 614 int err;
613 615
614 fsc = kzalloc(sizeof(*fsc), GFP_KERNEL); 616 fsc = kzalloc(sizeof(*fsc), GFP_KERNEL);
615 if (!fsc) 617 if (!fsc) {
616 return ERR_PTR(-ENOMEM); 618 err = -ENOMEM;
619 goto fail;
620 }
617 621
618 fsc->client = ceph_create_client(opt, fsc); 622 fsc->client = ceph_create_client(opt, fsc);
619 if (IS_ERR(fsc->client)) { 623 if (IS_ERR(fsc->client)) {
620 err = PTR_ERR(fsc->client); 624 err = PTR_ERR(fsc->client);
621 goto fail; 625 goto fail;
622 } 626 }
627 opt = NULL; /* fsc->client now owns this */
623 628
624 fsc->client->extra_mon_dispatch = extra_mon_dispatch; 629 fsc->client->extra_mon_dispatch = extra_mon_dispatch;
625 fsc->client->osdc.abort_on_full = true; 630 fsc->client->osdc.abort_on_full = true;
@@ -677,6 +682,9 @@ fail_client:
677 ceph_destroy_client(fsc->client); 682 ceph_destroy_client(fsc->client);
678fail: 683fail:
679 kfree(fsc); 684 kfree(fsc);
685 if (opt)
686 ceph_destroy_options(opt);
687 destroy_mount_options(fsopt);
680 return ERR_PTR(err); 688 return ERR_PTR(err);
681} 689}
682 690
@@ -1042,8 +1050,6 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
1042 fsc = create_fs_client(fsopt, opt); 1050 fsc = create_fs_client(fsopt, opt);
1043 if (IS_ERR(fsc)) { 1051 if (IS_ERR(fsc)) {
1044 res = ERR_CAST(fsc); 1052 res = ERR_CAST(fsc);
1045 destroy_mount_options(fsopt);
1046 ceph_destroy_options(opt);
1047 goto out_final; 1053 goto out_final;
1048 } 1054 }
1049 1055
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index b380e0871372..a2b2355e7f01 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -105,9 +105,6 @@ convert_sfm_char(const __u16 src_char, char *target)
105 case SFM_LESSTHAN: 105 case SFM_LESSTHAN:
106 *target = '<'; 106 *target = '<';
107 break; 107 break;
108 case SFM_SLASH:
109 *target = '\\';
110 break;
111 case SFM_SPACE: 108 case SFM_SPACE:
112 *target = ' '; 109 *target = ' ';
113 break; 110 break;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index c832a8a1970a..7aa08dba4719 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2547,7 +2547,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
2547 if (tcon == NULL) 2547 if (tcon == NULL)
2548 return -ENOMEM; 2548 return -ENOMEM;
2549 2549
2550 snprintf(unc, sizeof(unc), "\\\\%s\\IPC$", ses->serverName); 2550 snprintf(unc, sizeof(unc), "\\\\%s\\IPC$", ses->server->hostname);
2551 2551
2552 /* cannot fail */ 2552 /* cannot fail */
2553 nls_codepage = load_nls_default(); 2553 nls_codepage = load_nls_default();
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index d32eaa4b2437..6e8765f44508 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -467,6 +467,8 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
467 oparms.cifs_sb = cifs_sb; 467 oparms.cifs_sb = cifs_sb;
468 oparms.desired_access = GENERIC_READ; 468 oparms.desired_access = GENERIC_READ;
469 oparms.create_options = CREATE_NOT_DIR; 469 oparms.create_options = CREATE_NOT_DIR;
470 if (backup_cred(cifs_sb))
471 oparms.create_options |= CREATE_OPEN_BACKUP_INTENT;
470 oparms.disposition = FILE_OPEN; 472 oparms.disposition = FILE_OPEN;
471 oparms.path = path; 473 oparms.path = path;
472 oparms.fid = &fid; 474 oparms.fid = &fid;
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index db0453660ff6..6a9c47541c53 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -248,16 +248,20 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
248 * MacOS server pads after SMB2.1 write response with 3 bytes 248 * MacOS server pads after SMB2.1 write response with 3 bytes
249 * of junk. Other servers match RFC1001 len to actual 249 * of junk. Other servers match RFC1001 len to actual
250 * SMB2/SMB3 frame length (header + smb2 response specific data) 250 * SMB2/SMB3 frame length (header + smb2 response specific data)
251 * Some windows servers do too when compounding is used. 251 * Some windows servers also pad up to 8 bytes when compounding.
252 * Log the server error (once), but allow it and continue 252 * If pad is longer than eight bytes, log the server behavior
253 * (once), since may indicate a problem but allow it and continue
253 * since the frame is parseable. 254 * since the frame is parseable.
254 */ 255 */
255 if (clc_len < len) { 256 if (clc_len < len) {
256 printk_once(KERN_WARNING 257 pr_warn_once(
257 "SMB2 server sent bad RFC1001 len %d not %d\n", 258 "srv rsp padded more than expected. Length %d not %d for cmd:%d mid:%llu\n",
258 len, clc_len); 259 len, clc_len, command, mid);
259 return 0; 260 return 0;
260 } 261 }
262 pr_warn_once(
263 "srv rsp too short, len %d not %d. cmd:%d mid:%llu\n",
264 len, clc_len, command, mid);
261 265
262 return 1; 266 return 1;
263 } 267 }
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 247a98e6c856..d954ce36b473 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -630,7 +630,10 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
630 oparms.tcon = tcon; 630 oparms.tcon = tcon;
631 oparms.desired_access = FILE_READ_ATTRIBUTES; 631 oparms.desired_access = FILE_READ_ATTRIBUTES;
632 oparms.disposition = FILE_OPEN; 632 oparms.disposition = FILE_OPEN;
633 oparms.create_options = 0; 633 if (backup_cred(cifs_sb))
634 oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
635 else
636 oparms.create_options = 0;
634 oparms.fid = &fid; 637 oparms.fid = &fid;
635 oparms.reconnect = false; 638 oparms.reconnect = false;
636 639
@@ -779,7 +782,10 @@ smb2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
779 oparms.tcon = tcon; 782 oparms.tcon = tcon;
780 oparms.desired_access = FILE_READ_EA; 783 oparms.desired_access = FILE_READ_EA;
781 oparms.disposition = FILE_OPEN; 784 oparms.disposition = FILE_OPEN;
782 oparms.create_options = 0; 785 if (backup_cred(cifs_sb))
786 oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
787 else
788 oparms.create_options = 0;
783 oparms.fid = &fid; 789 oparms.fid = &fid;
784 oparms.reconnect = false; 790 oparms.reconnect = false;
785 791
@@ -858,7 +864,10 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
858 oparms.tcon = tcon; 864 oparms.tcon = tcon;
859 oparms.desired_access = FILE_WRITE_EA; 865 oparms.desired_access = FILE_WRITE_EA;
860 oparms.disposition = FILE_OPEN; 866 oparms.disposition = FILE_OPEN;
861 oparms.create_options = 0; 867 if (backup_cred(cifs_sb))
868 oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
869 else
870 oparms.create_options = 0;
862 oparms.fid = &fid; 871 oparms.fid = &fid;
863 oparms.reconnect = false; 872 oparms.reconnect = false;
864 873
@@ -1453,7 +1462,10 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
1453 oparms.tcon = tcon; 1462 oparms.tcon = tcon;
1454 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA; 1463 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
1455 oparms.disposition = FILE_OPEN; 1464 oparms.disposition = FILE_OPEN;
1456 oparms.create_options = 0; 1465 if (backup_cred(cifs_sb))
1466 oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
1467 else
1468 oparms.create_options = 0;
1457 oparms.fid = fid; 1469 oparms.fid = fid;
1458 oparms.reconnect = false; 1470 oparms.reconnect = false;
1459 1471
@@ -1857,7 +1869,10 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
1857 oparms.tcon = tcon; 1869 oparms.tcon = tcon;
1858 oparms.desired_access = FILE_READ_ATTRIBUTES; 1870 oparms.desired_access = FILE_READ_ATTRIBUTES;
1859 oparms.disposition = FILE_OPEN; 1871 oparms.disposition = FILE_OPEN;
1860 oparms.create_options = 0; 1872 if (backup_cred(cifs_sb))
1873 oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
1874 else
1875 oparms.create_options = 0;
1861 oparms.fid = &fid; 1876 oparms.fid = &fid;
1862 oparms.reconnect = false; 1877 oparms.reconnect = false;
1863 1878
@@ -3639,7 +3654,7 @@ struct smb_version_values smb21_values = {
3639struct smb_version_values smb3any_values = { 3654struct smb_version_values smb3any_values = {
3640 .version_string = SMB3ANY_VERSION_STRING, 3655 .version_string = SMB3ANY_VERSION_STRING,
3641 .protocol_id = SMB302_PROT_ID, /* doesn't matter, send protocol array */ 3656 .protocol_id = SMB302_PROT_ID, /* doesn't matter, send protocol array */
3642 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION, 3657 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION | SMB2_GLOBAL_CAP_DIRECTORY_LEASING,
3643 .large_lock_type = 0, 3658 .large_lock_type = 0,
3644 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 3659 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3645 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 3660 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
@@ -3660,7 +3675,7 @@ struct smb_version_values smb3any_values = {
3660struct smb_version_values smbdefault_values = { 3675struct smb_version_values smbdefault_values = {
3661 .version_string = SMBDEFAULT_VERSION_STRING, 3676 .version_string = SMBDEFAULT_VERSION_STRING,
3662 .protocol_id = SMB302_PROT_ID, /* doesn't matter, send protocol array */ 3677 .protocol_id = SMB302_PROT_ID, /* doesn't matter, send protocol array */
3663 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION, 3678 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION | SMB2_GLOBAL_CAP_DIRECTORY_LEASING,
3664 .large_lock_type = 0, 3679 .large_lock_type = 0,
3665 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 3680 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3666 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 3681 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
@@ -3681,7 +3696,7 @@ struct smb_version_values smbdefault_values = {
3681struct smb_version_values smb30_values = { 3696struct smb_version_values smb30_values = {
3682 .version_string = SMB30_VERSION_STRING, 3697 .version_string = SMB30_VERSION_STRING,
3683 .protocol_id = SMB30_PROT_ID, 3698 .protocol_id = SMB30_PROT_ID,
3684 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION, 3699 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION | SMB2_GLOBAL_CAP_DIRECTORY_LEASING,
3685 .large_lock_type = 0, 3700 .large_lock_type = 0,
3686 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 3701 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3687 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 3702 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
@@ -3702,7 +3717,7 @@ struct smb_version_values smb30_values = {
3702struct smb_version_values smb302_values = { 3717struct smb_version_values smb302_values = {
3703 .version_string = SMB302_VERSION_STRING, 3718 .version_string = SMB302_VERSION_STRING,
3704 .protocol_id = SMB302_PROT_ID, 3719 .protocol_id = SMB302_PROT_ID,
3705 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION, 3720 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION | SMB2_GLOBAL_CAP_DIRECTORY_LEASING,
3706 .large_lock_type = 0, 3721 .large_lock_type = 0,
3707 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 3722 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3708 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 3723 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
@@ -3723,7 +3738,7 @@ struct smb_version_values smb302_values = {
3723struct smb_version_values smb311_values = { 3738struct smb_version_values smb311_values = {
3724 .version_string = SMB311_VERSION_STRING, 3739 .version_string = SMB311_VERSION_STRING,
3725 .protocol_id = SMB311_PROT_ID, 3740 .protocol_id = SMB311_PROT_ID,
3726 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION, 3741 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION | SMB2_GLOBAL_CAP_DIRECTORY_LEASING,
3727 .large_lock_type = 0, 3742 .large_lock_type = 0,
3728 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, 3743 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
3729 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, 3744 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5740aa809be6..c08acfc77abc 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2178,6 +2178,9 @@ SMB2_open_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, __u8 *oplock,
2178 if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) || 2178 if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) ||
2179 *oplock == SMB2_OPLOCK_LEVEL_NONE) 2179 *oplock == SMB2_OPLOCK_LEVEL_NONE)
2180 req->RequestedOplockLevel = *oplock; 2180 req->RequestedOplockLevel = *oplock;
2181 else if (!(server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING) &&
2182 (oparms->create_options & CREATE_NOT_FILE))
2183 req->RequestedOplockLevel = *oplock; /* no srv lease support */
2181 else { 2184 else {
2182 rc = add_lease_context(server, iov, &n_iov, 2185 rc = add_lease_context(server, iov, &n_iov,
2183 oparms->fid->lease_key, oplock); 2186 oparms->fid->lease_key, oplock);
diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c
index 03b8ba933eb2..235b959fc2b3 100644
--- a/fs/nilfs2/alloc.c
+++ b/fs/nilfs2/alloc.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * alloc.c - NILFS dat/inode allocator 3 * alloc.c - NILFS dat/inode allocator
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Originally written by Koji Sato. 7 * Originally written by Koji Sato.
17 * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji. 8 * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji.
18 */ 9 */
diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h
index 05149e606a78..0303c3968cee 100644
--- a/fs/nilfs2/alloc.h
+++ b/fs/nilfs2/alloc.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * alloc.h - persistent object (dat entry/disk inode) allocator/deallocator 3 * alloc.h - persistent object (dat entry/disk inode) allocator/deallocator
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Originally written by Koji Sato. 7 * Originally written by Koji Sato.
17 * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji. 8 * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji.
18 */ 9 */
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 01fb1831ca25..fb5a9a8a13cf 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * bmap.c - NILFS block mapping. 3 * bmap.c - NILFS block mapping.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h
index 2b6ffbe5997a..2c63858e81c9 100644
--- a/fs/nilfs2/bmap.h
+++ b/fs/nilfs2/bmap.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * bmap.h - NILFS block mapping. 3 * bmap.h - NILFS block mapping.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index dec98cab729d..ebb24a314f43 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * btnode.c - NILFS B-tree node cache 3 * btnode.c - NILFS B-tree node cache
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Originally written by Seiji Kihara. 7 * Originally written by Seiji Kihara.
17 * Fully revised by Ryusuke Konishi for stabilization and simplification. 8 * Fully revised by Ryusuke Konishi for stabilization and simplification.
18 * 9 *
diff --git a/fs/nilfs2/btnode.h b/fs/nilfs2/btnode.h
index 4e8aaa1aeb65..0f88dbc9bcb3 100644
--- a/fs/nilfs2/btnode.h
+++ b/fs/nilfs2/btnode.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * btnode.h - NILFS B-tree node cache 3 * btnode.h - NILFS B-tree node cache
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Seiji Kihara. 7 * Written by Seiji Kihara.
17 * Revised by Ryusuke Konishi. 8 * Revised by Ryusuke Konishi.
18 */ 9 */
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 16a7a67a11c9..23e043eca237 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * btree.c - NILFS B-tree. 3 * btree.c - NILFS B-tree.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/btree.h b/fs/nilfs2/btree.h
index 2184e47fa4bf..d1421b646ce4 100644
--- a/fs/nilfs2/btree.h
+++ b/fs/nilfs2/btree.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * btree.h - NILFS B-tree. 3 * btree.h - NILFS B-tree.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index a15a1601e931..8d41311b5db4 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * cpfile.c - NILFS checkpoint file. 3 * cpfile.c - NILFS checkpoint file.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/cpfile.h b/fs/nilfs2/cpfile.h
index 6eca972f9673..6336222df24a 100644
--- a/fs/nilfs2/cpfile.h
+++ b/fs/nilfs2/cpfile.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * cpfile.h - NILFS checkpoint file. 3 * cpfile.h - NILFS checkpoint file.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index dffedb2f8817..6f4066636be9 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * dat.c - NILFS disk address translation. 3 * dat.c - NILFS disk address translation.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/dat.h b/fs/nilfs2/dat.h
index 57dc6cf466d0..b17ee34580ae 100644
--- a/fs/nilfs2/dat.h
+++ b/fs/nilfs2/dat.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * dat.h - NILFS disk address translation. 3 * dat.h - NILFS disk address translation.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index 582831ab3eb9..81394e22d0a0 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * dir.c - NILFS directory entry operations 3 * dir.c - NILFS directory entry operations
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Modified for NILFS by Amagai Yoshiji. 7 * Modified for NILFS by Amagai Yoshiji.
17 */ 8 */
18/* 9/*
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
index 96e3ed0d9652..533e24ea3a88 100644
--- a/fs/nilfs2/direct.c
+++ b/fs/nilfs2/direct.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * direct.c - NILFS direct block pointer. 3 * direct.c - NILFS direct block pointer.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/direct.h b/fs/nilfs2/direct.h
index cfe85e848bba..ec9a23c77994 100644
--- a/fs/nilfs2/direct.h
+++ b/fs/nilfs2/direct.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * direct.h - NILFS direct block pointer. 3 * direct.h - NILFS direct block pointer.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index 7da0fac71dc2..64bc81363c6c 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * file.c - NILFS regular file handling primitives including fsync(). 3 * file.c - NILFS regular file handling primitives including fsync().
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Amagai Yoshiji and Ryusuke Konishi. 7 * Written by Amagai Yoshiji and Ryusuke Konishi.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c
index 853a831dcde0..aa3c328ee189 100644
--- a/fs/nilfs2/gcinode.c
+++ b/fs/nilfs2/gcinode.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * gcinode.c - dummy inodes to buffer blocks for garbage collection 3 * gcinode.c - dummy inodes to buffer blocks for garbage collection
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Seiji Kihara, Amagai Yoshiji, and Ryusuke Konishi. 7 * Written by Seiji Kihara, Amagai Yoshiji, and Ryusuke Konishi.
17 * Revised by Ryusuke Konishi. 8 * Revised by Ryusuke Konishi.
18 * 9 *
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c
index b8fa45c20c63..4140d232cadc 100644
--- a/fs/nilfs2/ifile.c
+++ b/fs/nilfs2/ifile.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * ifile.c - NILFS inode file 3 * ifile.c - NILFS inode file
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Amagai Yoshiji. 7 * Written by Amagai Yoshiji.
17 * Revised by Ryusuke Konishi. 8 * Revised by Ryusuke Konishi.
18 * 9 *
diff --git a/fs/nilfs2/ifile.h b/fs/nilfs2/ifile.h
index 188b94fe0ec5..a1e1e5711a05 100644
--- a/fs/nilfs2/ifile.h
+++ b/fs/nilfs2/ifile.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * ifile.h - NILFS inode file 3 * ifile.h - NILFS inode file
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Amagai Yoshiji. 7 * Written by Amagai Yoshiji.
17 * Revised by Ryusuke Konishi. 8 * Revised by Ryusuke Konishi.
18 * 9 *
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 6a612d832e7d..671085512e0f 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * inode.c - NILFS inode operations. 3 * inode.c - NILFS inode operations.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 1d2c3d7711fe..9b96d79eea6c 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * ioctl.c - NILFS ioctl operations. 3 * ioctl.c - NILFS ioctl operations.
3 * 4 *
4 * Copyright (C) 2007, 2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2007, 2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index c6bc1033e7d2..700870a92bc4 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * mdt.c - meta data file for NILFS 3 * mdt.c - meta data file for NILFS
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/mdt.h b/fs/nilfs2/mdt.h
index 3f67f3932097..e77aea4bb921 100644
--- a/fs/nilfs2/mdt.h
+++ b/fs/nilfs2/mdt.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * mdt.h - NILFS meta data file prototype and definitions 3 * mdt.h - NILFS meta data file prototype and definitions
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index dd52d3f82e8d..9fe6d4ab74f0 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * namei.c - NILFS pathname lookup operations. 3 * namei.c - NILFS pathname lookup operations.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Modified for NILFS by Amagai Yoshiji and Ryusuke Konishi. 7 * Modified for NILFS by Amagai Yoshiji and Ryusuke Konishi.
17 */ 8 */
18/* 9/*
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 33f8c8fc96e8..a2f247b6a209 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * nilfs.h - NILFS local header file. 3 * nilfs.h - NILFS local header file.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato and Ryusuke Konishi. 7 * Written by Koji Sato and Ryusuke Konishi.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 4cb850a6f1c2..329a056b73b1 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * page.c - buffer/page management specific to NILFS 3 * page.c - buffer/page management specific to NILFS
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi and Seiji Kihara. 7 * Written by Ryusuke Konishi and Seiji Kihara.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h
index f3687c958fa8..62b9bb469e92 100644
--- a/fs/nilfs2/page.h
+++ b/fs/nilfs2/page.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * page.h - buffer/page management specific to NILFS 3 * page.h - buffer/page management specific to NILFS
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi and Seiji Kihara. 7 * Written by Ryusuke Konishi and Seiji Kihara.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index 5139efed1888..140b663e91c7 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * recovery.c - NILFS recovery logic 3 * recovery.c - NILFS recovery logic
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 68cb9e4740b4..20c479b5e41b 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * segbuf.c - NILFS segment buffer 3 * segbuf.c - NILFS segment buffer
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/nilfs2/segbuf.h b/fs/nilfs2/segbuf.h
index 10e16935fff6..9bea1bd59041 100644
--- a/fs/nilfs2/segbuf.h
+++ b/fs/nilfs2/segbuf.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * segbuf.h - NILFS Segment buffer prototypes and definitions 3 * segbuf.h - NILFS Segment buffer prototypes and definitions
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 0953635e7d48..445eef41bfaf 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * segment.c - NILFS segment constructor. 3 * segment.c - NILFS segment constructor.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h
index 04634e3e3d58..f5cf5308f3fc 100644
--- a/fs/nilfs2/segment.h
+++ b/fs/nilfs2/segment.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * segment.h - NILFS Segment constructor prototypes and definitions 3 * segment.h - NILFS Segment constructor prototypes and definitions
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c
index c7fa139d50e8..bf3f8f05c89b 100644
--- a/fs/nilfs2/sufile.c
+++ b/fs/nilfs2/sufile.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * sufile.c - NILFS segment usage file. 3 * sufile.c - NILFS segment usage file.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 * Revised by Ryusuke Konishi. 8 * Revised by Ryusuke Konishi.
18 */ 9 */
diff --git a/fs/nilfs2/sufile.h b/fs/nilfs2/sufile.h
index 673a891350f4..c4e2c7a7add1 100644
--- a/fs/nilfs2/sufile.h
+++ b/fs/nilfs2/sufile.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * sufile.h - NILFS segment usage file. 3 * sufile.h - NILFS segment usage file.
3 * 4 *
4 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Koji Sato. 7 * Written by Koji Sato.
17 */ 8 */
18 9
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 1b9067cf4511..26290aa1023f 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * super.c - NILFS module and super block management. 3 * super.c - NILFS module and super block management.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 */ 8 */
18/* 9/*
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 4b25837e7724..e60be7bb55b0 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -1,19 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * sysfs.c - sysfs support implementation. 3 * sysfs.c - sysfs support implementation.
3 * 4 *
4 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation.
5 * Copyright (C) 2014 HGST, Inc., a Western Digital Company. 6 * Copyright (C) 2014 HGST, Inc., a Western Digital Company.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com> 8 * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>
18 */ 9 */
19 10
diff --git a/fs/nilfs2/sysfs.h b/fs/nilfs2/sysfs.h
index 648cedf9c06e..d001eb862dae 100644
--- a/fs/nilfs2/sysfs.h
+++ b/fs/nilfs2/sysfs.h
@@ -1,19 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * sysfs.h - sysfs support declarations. 3 * sysfs.h - sysfs support declarations.
3 * 4 *
4 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation.
5 * Copyright (C) 2014 HGST, Inc., a Western Digital Company. 6 * Copyright (C) 2014 HGST, Inc., a Western Digital Company.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com> 8 * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>
18 */ 9 */
19 10
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 1a85317e83f0..484785cdf96e 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -1,18 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * the_nilfs.c - the_nilfs shared structure. 3 * the_nilfs.c - the_nilfs shared structure.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index 36da1779f976..380a543c5b19 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -1,18 +1,9 @@
1/* SPDX-License-Identifier: GPL-2.0+ */
1/* 2/*
2 * the_nilfs.h - the_nilfs shared structure. 3 * the_nilfs.h - the_nilfs shared structure.
3 * 4 *
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Written by Ryusuke Konishi. 7 * Written by Ryusuke Konishi.
17 * 8 *
18 */ 9 */
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index f174397b63a0..ababdbfab537 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -351,16 +351,9 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
351 351
352 iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu); 352 iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
353 353
354 if ((mask & FS_MODIFY) || 354 iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
355 (test_mask & to_tell->i_fsnotify_mask)) { 355 fsnotify_first_mark(&to_tell->i_fsnotify_marks);
356 iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] = 356 if (mnt) {
357 fsnotify_first_mark(&to_tell->i_fsnotify_marks);
358 }
359
360 if (mnt && ((mask & FS_MODIFY) ||
361 (test_mask & mnt->mnt_fsnotify_mask))) {
362 iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
363 fsnotify_first_mark(&to_tell->i_fsnotify_marks);
364 iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] = 357 iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] =
365 fsnotify_first_mark(&mnt->mnt_fsnotify_marks); 358 fsnotify_first_mark(&mnt->mnt_fsnotify_marks);
366 } 359 }
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 34aec30e06c7..6d766a19f2bb 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -56,6 +56,7 @@ struct blkcg {
56 struct list_head all_blkcgs_node; 56 struct list_head all_blkcgs_node;
57#ifdef CONFIG_CGROUP_WRITEBACK 57#ifdef CONFIG_CGROUP_WRITEBACK
58 struct list_head cgwb_list; 58 struct list_head cgwb_list;
59 refcount_t cgwb_refcnt;
59#endif 60#endif
60}; 61};
61 62
@@ -89,7 +90,6 @@ struct blkg_policy_data {
89 /* the blkg and policy id this per-policy data belongs to */ 90 /* the blkg and policy id this per-policy data belongs to */
90 struct blkcg_gq *blkg; 91 struct blkcg_gq *blkg;
91 int plid; 92 int plid;
92 bool offline;
93}; 93};
94 94
95/* 95/*
@@ -387,6 +387,49 @@ static inline struct blkcg *cpd_to_blkcg(struct blkcg_policy_data *cpd)
387 return cpd ? cpd->blkcg : NULL; 387 return cpd ? cpd->blkcg : NULL;
388} 388}
389 389
390extern void blkcg_destroy_blkgs(struct blkcg *blkcg);
391
392#ifdef CONFIG_CGROUP_WRITEBACK
393
394/**
395 * blkcg_cgwb_get - get a reference for blkcg->cgwb_list
396 * @blkcg: blkcg of interest
397 *
398 * This is used to track the number of active wb's related to a blkcg.
399 */
400static inline void blkcg_cgwb_get(struct blkcg *blkcg)
401{
402 refcount_inc(&blkcg->cgwb_refcnt);
403}
404
405/**
406 * blkcg_cgwb_put - put a reference for @blkcg->cgwb_list
407 * @blkcg: blkcg of interest
408 *
409 * This is used to track the number of active wb's related to a blkcg.
410 * When this count goes to zero, all active wb has finished so the
411 * blkcg can continue destruction by calling blkcg_destroy_blkgs().
412 * This work may occur in cgwb_release_workfn() on the cgwb_release
413 * workqueue.
414 */
415static inline void blkcg_cgwb_put(struct blkcg *blkcg)
416{
417 if (refcount_dec_and_test(&blkcg->cgwb_refcnt))
418 blkcg_destroy_blkgs(blkcg);
419}
420
421#else
422
423static inline void blkcg_cgwb_get(struct blkcg *blkcg) { }
424
425static inline void blkcg_cgwb_put(struct blkcg *blkcg)
426{
427 /* wb isn't being accounted, so trigger destruction right away */
428 blkcg_destroy_blkgs(blkcg);
429}
430
431#endif
432
390/** 433/**
391 * blkg_path - format cgroup path of blkg 434 * blkg_path - format cgroup path of blkg
392 * @blkg: blkg of interest 435 * @blkg: blkg of interest
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 834e6461a690..d44a78362942 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -526,6 +526,7 @@ struct hid_input {
526 const char *name; 526 const char *name;
527 bool registered; 527 bool registered;
528 struct list_head reports; /* the list of reports */ 528 struct list_head reports; /* the list of reports */
529 unsigned int application; /* application usage for this input */
529}; 530};
530 531
531enum hid_type { 532enum hid_type {
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 5d738804e3d6..a5a3cfc3c2fa 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -258,8 +258,8 @@ extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot);
258extern int persistent_clock_is_local; 258extern int persistent_clock_is_local;
259 259
260extern void read_persistent_clock64(struct timespec64 *ts); 260extern void read_persistent_clock64(struct timespec64 *ts);
261void read_persistent_clock_and_boot_offset(struct timespec64 *wall_clock, 261void read_persistent_wall_and_boot_offset(struct timespec64 *wall_clock,
262 struct timespec64 *boot_offset); 262 struct timespec64 *boot_offset);
263extern int update_persistent_clock64(struct timespec64 now); 263extern int update_persistent_clock64(struct timespec64 now);
264 264
265/* 265/*
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 7f2e16e76ac4..041f7e56a289 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -158,8 +158,10 @@ extern void syscall_unregfunc(void);
158 * For rcuidle callers, use srcu since sched-rcu \ 158 * For rcuidle callers, use srcu since sched-rcu \
159 * doesn't work from the idle path. \ 159 * doesn't work from the idle path. \
160 */ \ 160 */ \
161 if (rcuidle) \ 161 if (rcuidle) { \
162 idx = srcu_read_lock_notrace(&tracepoint_srcu); \ 162 idx = srcu_read_lock_notrace(&tracepoint_srcu); \
163 rcu_irq_enter_irqson(); \
164 } \
163 \ 165 \
164 it_func_ptr = rcu_dereference_raw((tp)->funcs); \ 166 it_func_ptr = rcu_dereference_raw((tp)->funcs); \
165 \ 167 \
@@ -171,8 +173,10 @@ extern void syscall_unregfunc(void);
171 } while ((++it_func_ptr)->func); \ 173 } while ((++it_func_ptr)->func); \
172 } \ 174 } \
173 \ 175 \
174 if (rcuidle) \ 176 if (rcuidle) { \
177 rcu_irq_exit_irqson(); \
175 srcu_read_unlock_notrace(&tracepoint_srcu, idx);\ 178 srcu_read_unlock_notrace(&tracepoint_srcu, idx);\
179 } \
176 \ 180 \
177 preempt_enable_notrace(); \ 181 preempt_enable_notrace(); \
178 } while (0) 182 } while (0)
diff --git a/include/net/netfilter/nf_conntrack_timeout.h b/include/net/netfilter/nf_conntrack_timeout.h
index d5f62cc6c2ae..3394d75e1c80 100644
--- a/include/net/netfilter/nf_conntrack_timeout.h
+++ b/include/net/netfilter/nf_conntrack_timeout.h
@@ -30,7 +30,7 @@ struct nf_conn_timeout {
30}; 30};
31 31
32static inline unsigned int * 32static inline unsigned int *
33nf_ct_timeout_data(struct nf_conn_timeout *t) 33nf_ct_timeout_data(const struct nf_conn_timeout *t)
34{ 34{
35 struct nf_ct_timeout *timeout; 35 struct nf_ct_timeout *timeout;
36 36
diff --git a/include/net/tls.h b/include/net/tls.h
index d5c683e8bb22..0a769cf2f5f3 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -171,15 +171,14 @@ struct cipher_context {
171 char *rec_seq; 171 char *rec_seq;
172}; 172};
173 173
174union tls_crypto_context {
175 struct tls_crypto_info info;
176 struct tls12_crypto_info_aes_gcm_128 aes_gcm_128;
177};
178
174struct tls_context { 179struct tls_context {
175 union { 180 union tls_crypto_context crypto_send;
176 struct tls_crypto_info crypto_send; 181 union tls_crypto_context crypto_recv;
177 struct tls12_crypto_info_aes_gcm_128 crypto_send_aes_gcm_128;
178 };
179 union {
180 struct tls_crypto_info crypto_recv;
181 struct tls12_crypto_info_aes_gcm_128 crypto_recv_aes_gcm_128;
182 };
183 182
184 struct list_head list; 183 struct list_head list;
185 struct net_device *netdev; 184 struct net_device *netdev;
@@ -367,8 +366,8 @@ static inline void tls_fill_prepend(struct tls_context *ctx,
367 * size KTLS_DTLS_HEADER_SIZE + KTLS_DTLS_NONCE_EXPLICIT_SIZE 366 * size KTLS_DTLS_HEADER_SIZE + KTLS_DTLS_NONCE_EXPLICIT_SIZE
368 */ 367 */
369 buf[0] = record_type; 368 buf[0] = record_type;
370 buf[1] = TLS_VERSION_MINOR(ctx->crypto_send.version); 369 buf[1] = TLS_VERSION_MINOR(ctx->crypto_send.info.version);
371 buf[2] = TLS_VERSION_MAJOR(ctx->crypto_send.version); 370 buf[2] = TLS_VERSION_MAJOR(ctx->crypto_send.info.version);
372 /* we can use IV for nonce explicit according to spec */ 371 /* we can use IV for nonce explicit according to spec */
373 buf[3] = pkt_len >> 8; 372 buf[3] = pkt_len >> 8;
374 buf[4] = pkt_len & 0xFF; 373 buf[4] = pkt_len & 0xFF;
diff --git a/include/uapi/linux/keyctl.h b/include/uapi/linux/keyctl.h
index 7b8c9e19bad1..910cc4334b21 100644
--- a/include/uapi/linux/keyctl.h
+++ b/include/uapi/linux/keyctl.h
@@ -65,7 +65,7 @@
65 65
66/* keyctl structures */ 66/* keyctl structures */
67struct keyctl_dh_params { 67struct keyctl_dh_params {
68 __s32 private; 68 __s32 dh_private;
69 __s32 prime; 69 __s32 prime;
70 __s32 base; 70 __s32 base;
71}; 71};
diff --git a/ipc/shm.c b/ipc/shm.c
index b0eb3757ab89..4cd402e4cfeb 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -199,6 +199,7 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
199 } 199 }
200 200
201 ipc_unlock_object(ipcp); 201 ipc_unlock_object(ipcp);
202 ipcp = ERR_PTR(-EIDRM);
202err: 203err:
203 rcu_read_unlock(); 204 rcu_read_unlock();
204 /* 205 /*
diff --git a/kernel/cpu.c b/kernel/cpu.c
index aa7fe85ad62e..0097acec1c71 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -607,15 +607,15 @@ static void cpuhp_thread_fun(unsigned int cpu)
607 bool bringup = st->bringup; 607 bool bringup = st->bringup;
608 enum cpuhp_state state; 608 enum cpuhp_state state;
609 609
610 if (WARN_ON_ONCE(!st->should_run))
611 return;
612
610 /* 613 /*
611 * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures 614 * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures
612 * that if we see ->should_run we also see the rest of the state. 615 * that if we see ->should_run we also see the rest of the state.
613 */ 616 */
614 smp_mb(); 617 smp_mb();
615 618
616 if (WARN_ON_ONCE(!st->should_run))
617 return;
618
619 cpuhp_lock_acquire(bringup); 619 cpuhp_lock_acquire(bringup);
620 620
621 if (st->single) { 621 if (st->single) {
@@ -916,7 +916,8 @@ static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
916 ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL); 916 ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL);
917 if (ret) { 917 if (ret) {
918 st->target = prev_state; 918 st->target = prev_state;
919 undo_cpu_down(cpu, st); 919 if (st->state < prev_state)
920 undo_cpu_down(cpu, st);
920 break; 921 break;
921 } 922 }
922 } 923 }
@@ -969,7 +970,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
969 * to do the further cleanups. 970 * to do the further cleanups.
970 */ 971 */
971 ret = cpuhp_down_callbacks(cpu, st, target); 972 ret = cpuhp_down_callbacks(cpu, st, target);
972 if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) { 973 if (ret && st->state == CPUHP_TEARDOWN_CPU && st->state < prev_state) {
973 cpuhp_reset_state(st, prev_state); 974 cpuhp_reset_state(st, prev_state);
974 __cpuhp_kick_ap(st); 975 __cpuhp_kick_ap(st);
975 } 976 }
diff --git a/kernel/fork.c b/kernel/fork.c
index d896e9ca38b0..f0b58479534f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -550,8 +550,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
550 goto out; 550 goto out;
551 } 551 }
552 /* a new mm has just been created */ 552 /* a new mm has just been created */
553 arch_dup_mmap(oldmm, mm); 553 retval = arch_dup_mmap(oldmm, mm);
554 retval = 0;
555out: 554out:
556 up_write(&mm->mmap_sem); 555 up_write(&mm->mmap_sem);
557 flush_tlb_mm(oldmm); 556 flush_tlb_mm(oldmm);
diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index a0a74c533e4b..0913b4d385de 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -306,12 +306,12 @@ static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args)
306 return printk_safe_log_store(s, fmt, args); 306 return printk_safe_log_store(s, fmt, args);
307} 307}
308 308
309void printk_nmi_enter(void) 309void notrace printk_nmi_enter(void)
310{ 310{
311 this_cpu_or(printk_context, PRINTK_NMI_CONTEXT_MASK); 311 this_cpu_or(printk_context, PRINTK_NMI_CONTEXT_MASK);
312} 312}
313 313
314void printk_nmi_exit(void) 314void notrace printk_nmi_exit(void)
315{ 315{
316 this_cpu_and(printk_context, ~PRINTK_NMI_CONTEXT_MASK); 316 this_cpu_and(printk_context, ~PRINTK_NMI_CONTEXT_MASK);
317} 317}
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index f74fb00d8064..0e6e97a01942 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -133,19 +133,40 @@ static void inline clocksource_watchdog_unlock(unsigned long *flags)
133 spin_unlock_irqrestore(&watchdog_lock, *flags); 133 spin_unlock_irqrestore(&watchdog_lock, *flags);
134} 134}
135 135
136static int clocksource_watchdog_kthread(void *data);
137static void __clocksource_change_rating(struct clocksource *cs, int rating);
138
136/* 139/*
137 * Interval: 0.5sec Threshold: 0.0625s 140 * Interval: 0.5sec Threshold: 0.0625s
138 */ 141 */
139#define WATCHDOG_INTERVAL (HZ >> 1) 142#define WATCHDOG_INTERVAL (HZ >> 1)
140#define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4) 143#define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4)
141 144
145static void clocksource_watchdog_work(struct work_struct *work)
146{
147 /*
148 * We cannot directly run clocksource_watchdog_kthread() here, because
149 * clocksource_select() calls timekeeping_notify() which uses
150 * stop_machine(). One cannot use stop_machine() from a workqueue() due
151 * lock inversions wrt CPU hotplug.
152 *
153 * Also, we only ever run this work once or twice during the lifetime
154 * of the kernel, so there is no point in creating a more permanent
155 * kthread for this.
156 *
157 * If kthread_run fails the next watchdog scan over the
158 * watchdog_list will find the unstable clock again.
159 */
160 kthread_run(clocksource_watchdog_kthread, NULL, "kwatchdog");
161}
162
142static void __clocksource_unstable(struct clocksource *cs) 163static void __clocksource_unstable(struct clocksource *cs)
143{ 164{
144 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); 165 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
145 cs->flags |= CLOCK_SOURCE_UNSTABLE; 166 cs->flags |= CLOCK_SOURCE_UNSTABLE;
146 167
147 /* 168 /*
148 * If the clocksource is registered clocksource_watchdog_work() will 169 * If the clocksource is registered clocksource_watchdog_kthread() will
149 * re-rate and re-select. 170 * re-rate and re-select.
150 */ 171 */
151 if (list_empty(&cs->list)) { 172 if (list_empty(&cs->list)) {
@@ -156,7 +177,7 @@ static void __clocksource_unstable(struct clocksource *cs)
156 if (cs->mark_unstable) 177 if (cs->mark_unstable)
157 cs->mark_unstable(cs); 178 cs->mark_unstable(cs);
158 179
159 /* kick clocksource_watchdog_work() */ 180 /* kick clocksource_watchdog_kthread() */
160 if (finished_booting) 181 if (finished_booting)
161 schedule_work(&watchdog_work); 182 schedule_work(&watchdog_work);
162} 183}
@@ -166,7 +187,7 @@ static void __clocksource_unstable(struct clocksource *cs)
166 * @cs: clocksource to be marked unstable 187 * @cs: clocksource to be marked unstable
167 * 188 *
168 * This function is called by the x86 TSC code to mark clocksources as unstable; 189 * This function is called by the x86 TSC code to mark clocksources as unstable;
169 * it defers demotion and re-selection to a work. 190 * it defers demotion and re-selection to a kthread.
170 */ 191 */
171void clocksource_mark_unstable(struct clocksource *cs) 192void clocksource_mark_unstable(struct clocksource *cs)
172{ 193{
@@ -391,9 +412,7 @@ static void clocksource_dequeue_watchdog(struct clocksource *cs)
391 } 412 }
392} 413}
393 414
394static void __clocksource_change_rating(struct clocksource *cs, int rating); 415static int __clocksource_watchdog_kthread(void)
395
396static int __clocksource_watchdog_work(void)
397{ 416{
398 struct clocksource *cs, *tmp; 417 struct clocksource *cs, *tmp;
399 unsigned long flags; 418 unsigned long flags;
@@ -418,12 +437,13 @@ static int __clocksource_watchdog_work(void)
418 return select; 437 return select;
419} 438}
420 439
421static void clocksource_watchdog_work(struct work_struct *work) 440static int clocksource_watchdog_kthread(void *data)
422{ 441{
423 mutex_lock(&clocksource_mutex); 442 mutex_lock(&clocksource_mutex);
424 if (__clocksource_watchdog_work()) 443 if (__clocksource_watchdog_kthread())
425 clocksource_select(); 444 clocksource_select();
426 mutex_unlock(&clocksource_mutex); 445 mutex_unlock(&clocksource_mutex);
446 return 0;
427} 447}
428 448
429static bool clocksource_is_watchdog(struct clocksource *cs) 449static bool clocksource_is_watchdog(struct clocksource *cs)
@@ -442,7 +462,7 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs)
442static void clocksource_select_watchdog(bool fallback) { } 462static void clocksource_select_watchdog(bool fallback) { }
443static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } 463static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { }
444static inline void clocksource_resume_watchdog(void) { } 464static inline void clocksource_resume_watchdog(void) { }
445static inline int __clocksource_watchdog_work(void) { return 0; } 465static inline int __clocksource_watchdog_kthread(void) { return 0; }
446static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } 466static bool clocksource_is_watchdog(struct clocksource *cs) { return false; }
447void clocksource_mark_unstable(struct clocksource *cs) { } 467void clocksource_mark_unstable(struct clocksource *cs) { }
448 468
@@ -810,7 +830,7 @@ static int __init clocksource_done_booting(void)
810 /* 830 /*
811 * Run the watchdog first to eliminate unstable clock sources 831 * Run the watchdog first to eliminate unstable clock sources
812 */ 832 */
813 __clocksource_watchdog_work(); 833 __clocksource_watchdog_kthread();
814 clocksource_select(); 834 clocksource_select();
815 mutex_unlock(&clocksource_mutex); 835 mutex_unlock(&clocksource_mutex);
816 return 0; 836 return 0;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 613316724c6a..4966c4fbe7f7 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1277,13 +1277,13 @@ config WARN_ALL_UNSEEDED_RANDOM
1277 time. This is really bad from a security perspective, and 1277 time. This is really bad from a security perspective, and
1278 so architecture maintainers really need to do what they can 1278 so architecture maintainers really need to do what they can
1279 to get the CRNG seeded sooner after the system is booted. 1279 to get the CRNG seeded sooner after the system is booted.
1280 However, since users can not do anything actionble to 1280 However, since users cannot do anything actionable to
1281 address this, by default the kernel will issue only a single 1281 address this, by default the kernel will issue only a single
1282 warning for the first use of unseeded randomness. 1282 warning for the first use of unseeded randomness.
1283 1283
1284 Say Y here if you want to receive warnings for all uses of 1284 Say Y here if you want to receive warnings for all uses of
1285 unseeded randomness. This will be of use primarily for 1285 unseeded randomness. This will be of use primarily for
1286 those developers interersted in improving the security of 1286 those developers interested in improving the security of
1287 Linux kernels running on their architecture (or 1287 Linux kernels running on their architecture (or
1288 subarchitecture). 1288 subarchitecture).
1289 1289
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index f5981e9d6ae2..8a8bb8796c6c 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -491,6 +491,7 @@ static void cgwb_release_workfn(struct work_struct *work)
491{ 491{
492 struct bdi_writeback *wb = container_of(work, struct bdi_writeback, 492 struct bdi_writeback *wb = container_of(work, struct bdi_writeback,
493 release_work); 493 release_work);
494 struct blkcg *blkcg = css_to_blkcg(wb->blkcg_css);
494 495
495 mutex_lock(&wb->bdi->cgwb_release_mutex); 496 mutex_lock(&wb->bdi->cgwb_release_mutex);
496 wb_shutdown(wb); 497 wb_shutdown(wb);
@@ -499,6 +500,9 @@ static void cgwb_release_workfn(struct work_struct *work)
499 css_put(wb->blkcg_css); 500 css_put(wb->blkcg_css);
500 mutex_unlock(&wb->bdi->cgwb_release_mutex); 501 mutex_unlock(&wb->bdi->cgwb_release_mutex);
501 502
503 /* triggers blkg destruction if cgwb_refcnt becomes zero */
504 blkcg_cgwb_put(blkcg);
505
502 fprop_local_destroy_percpu(&wb->memcg_completions); 506 fprop_local_destroy_percpu(&wb->memcg_completions);
503 percpu_ref_exit(&wb->refcnt); 507 percpu_ref_exit(&wb->refcnt);
504 wb_exit(wb); 508 wb_exit(wb);
@@ -597,6 +601,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
597 list_add_tail_rcu(&wb->bdi_node, &bdi->wb_list); 601 list_add_tail_rcu(&wb->bdi_node, &bdi->wb_list);
598 list_add(&wb->memcg_node, memcg_cgwb_list); 602 list_add(&wb->memcg_node, memcg_cgwb_list);
599 list_add(&wb->blkcg_node, blkcg_cgwb_list); 603 list_add(&wb->blkcg_node, blkcg_cgwb_list);
604 blkcg_cgwb_get(blkcg);
600 css_get(memcg_css); 605 css_get(memcg_css);
601 css_get(blkcg_css); 606 css_get(blkcg_css);
602 } 607 }
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index c3bc7e9c9a2a..533f9b00147d 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -821,11 +821,11 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr,
821 * but we need to be consistent with PTEs and architectures that 821 * but we need to be consistent with PTEs and architectures that
822 * can't support a 'special' bit. 822 * can't support a 'special' bit.
823 */ 823 */
824 BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); 824 BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) &&
825 !pfn_t_devmap(pfn));
825 BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == 826 BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) ==
826 (VM_PFNMAP|VM_MIXEDMAP)); 827 (VM_PFNMAP|VM_MIXEDMAP));
827 BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); 828 BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags));
828 BUG_ON(!pfn_t_devmap(pfn));
829 829
830 if (addr < vma->vm_start || addr >= vma->vm_end) 830 if (addr < vma->vm_start || addr >= vma->vm_end)
831 return VM_FAULT_SIGBUS; 831 return VM_FAULT_SIGBUS;
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 9a085d525bbc..17dd883198ae 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -2097,6 +2097,11 @@ static int __init kmemleak_late_init(void)
2097 2097
2098 kmemleak_initialized = 1; 2098 kmemleak_initialized = 1;
2099 2099
2100 dentry = debugfs_create_file("kmemleak", 0644, NULL, NULL,
2101 &kmemleak_fops);
2102 if (!dentry)
2103 pr_warn("Failed to create the debugfs kmemleak file\n");
2104
2100 if (kmemleak_error) { 2105 if (kmemleak_error) {
2101 /* 2106 /*
2102 * Some error occurred and kmemleak was disabled. There is a 2107 * Some error occurred and kmemleak was disabled. There is a
@@ -2108,10 +2113,6 @@ static int __init kmemleak_late_init(void)
2108 return -ENOMEM; 2113 return -ENOMEM;
2109 } 2114 }
2110 2115
2111 dentry = debugfs_create_file("kmemleak", 0644, NULL, NULL,
2112 &kmemleak_fops);
2113 if (!dentry)
2114 pr_warn("Failed to create the debugfs kmemleak file\n");
2115 mutex_lock(&scan_mutex); 2116 mutex_lock(&scan_mutex);
2116 start_scan_thread(); 2117 start_scan_thread();
2117 mutex_unlock(&scan_mutex); 2118 mutex_unlock(&scan_mutex);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4ead5a4817de..e79cb59552d9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1701,8 +1701,6 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int
1701 if (mem_cgroup_out_of_memory(memcg, mask, order)) 1701 if (mem_cgroup_out_of_memory(memcg, mask, order))
1702 return OOM_SUCCESS; 1702 return OOM_SUCCESS;
1703 1703
1704 WARN(1,"Memory cgroup charge failed because of no reclaimable memory! "
1705 "This looks like a misconfiguration or a kernel bug.");
1706 return OOM_FAILED; 1704 return OOM_FAILED;
1707} 1705}
1708 1706
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9eea6e809a4e..38d94b703e9d 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1333,7 +1333,8 @@ static unsigned long scan_movable_pages(unsigned long start, unsigned long end)
1333 if (__PageMovable(page)) 1333 if (__PageMovable(page))
1334 return pfn; 1334 return pfn;
1335 if (PageHuge(page)) { 1335 if (PageHuge(page)) {
1336 if (page_huge_active(page)) 1336 if (hugepage_migration_supported(page_hstate(page)) &&
1337 page_huge_active(page))
1337 return pfn; 1338 return pfn;
1338 else 1339 else
1339 pfn = round_up(pfn + 1, 1340 pfn = round_up(pfn + 1,
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index b5b25e4dcbbb..f10aa5360616 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -522,6 +522,7 @@ bool __oom_reap_task_mm(struct mm_struct *mm)
522 522
523 tlb_gather_mmu(&tlb, mm, start, end); 523 tlb_gather_mmu(&tlb, mm, start, end);
524 if (mmu_notifier_invalidate_range_start_nonblock(mm, start, end)) { 524 if (mmu_notifier_invalidate_range_start_nonblock(mm, start, end)) {
525 tlb_finish_mmu(&tlb, start, end);
525 ret = false; 526 ret = false;
526 continue; 527 continue;
527 } 528 }
@@ -1103,10 +1104,17 @@ bool out_of_memory(struct oom_control *oc)
1103 } 1104 }
1104 1105
1105 select_bad_process(oc); 1106 select_bad_process(oc);
1106 /* Found nothing?!?! Either we hang forever, or we panic. */ 1107 /* Found nothing?!?! */
1107 if (!oc->chosen && !is_sysrq_oom(oc) && !is_memcg_oom(oc)) { 1108 if (!oc->chosen) {
1108 dump_header(oc, NULL); 1109 dump_header(oc, NULL);
1109 panic("Out of memory and no killable processes...\n"); 1110 pr_warn("Out of memory and no killable processes...\n");
1111 /*
1112 * If we got here due to an actual allocation at the
1113 * system level, we cannot survive this and will enter
1114 * an endless loop in the allocator. Bail out now.
1115 */
1116 if (!is_sysrq_oom(oc) && !is_memcg_oom(oc))
1117 panic("System is deadlocked on memory\n");
1110 } 1118 }
1111 if (oc->chosen && oc->chosen != (void *)-1UL) 1119 if (oc->chosen && oc->chosen != (void *)-1UL)
1112 oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : 1120 oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" :
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 05e983f42316..89d2a2ab3fe6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7708,6 +7708,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
7708 * handle each tail page individually in migration. 7708 * handle each tail page individually in migration.
7709 */ 7709 */
7710 if (PageHuge(page)) { 7710 if (PageHuge(page)) {
7711
7712 if (!hugepage_migration_supported(page_hstate(page)))
7713 goto unmovable;
7714
7711 iter = round_up(iter + 1, 1<<compound_order(page)) - 1; 7715 iter = round_up(iter + 1, 1<<compound_order(page)) - 1;
7712 continue; 7716 continue;
7713 } 7717 }
diff --git a/mm/util.c b/mm/util.c
index d2890a407332..9e3ebd2ef65f 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -435,11 +435,14 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
435EXPORT_SYMBOL(kvmalloc_node); 435EXPORT_SYMBOL(kvmalloc_node);
436 436
437/** 437/**
438 * kvfree - free memory allocated with kvmalloc 438 * kvfree() - Free memory.
439 * @addr: pointer returned by kvmalloc 439 * @addr: Pointer to allocated memory.
440 * 440 *
441 * If the memory is allocated from vmalloc area it is freed with vfree(). 441 * kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().
442 * Otherwise kfree() is used. 442 * It is slightly more efficient to use kfree() or vfree() if you are certain
443 * that you know which one to use.
444 *
445 * Context: Any context except NMI.
443 */ 446 */
444void kvfree(const void *addr) 447void kvfree(const void *addr)
445{ 448{
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index aa19d86937af..91592fceeaad 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1180,6 +1180,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1180 lladdr = neigh->ha; 1180 lladdr = neigh->ha;
1181 } 1181 }
1182 1182
1183 /* Update confirmed timestamp for neighbour entry after we
1184 * received ARP packet even if it doesn't change IP to MAC binding.
1185 */
1186 if (new & NUD_CONNECTED)
1187 neigh->confirmed = jiffies;
1188
1183 /* If entry was valid and address is not changed, 1189 /* If entry was valid and address is not changed,
1184 do not change entry state, if new one is STALE. 1190 do not change entry state, if new one is STALE.
1185 */ 1191 */
@@ -1201,15 +1207,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1201 } 1207 }
1202 } 1208 }
1203 1209
1204 /* Update timestamps only once we know we will make a change to the 1210 /* Update timestamp only once we know we will make a change to the
1205 * neighbour entry. Otherwise we risk to move the locktime window with 1211 * neighbour entry. Otherwise we risk to move the locktime window with
1206 * noop updates and ignore relevant ARP updates. 1212 * noop updates and ignore relevant ARP updates.
1207 */ 1213 */
1208 if (new != old || lladdr != neigh->ha) { 1214 if (new != old || lladdr != neigh->ha)
1209 if (new & NUD_CONNECTED)
1210 neigh->confirmed = jiffies;
1211 neigh->updated = jiffies; 1215 neigh->updated = jiffies;
1212 }
1213 1216
1214 if (new != old) { 1217 if (new != old) {
1215 neigh_del_timer(neigh); 1218 neigh_del_timer(neigh);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 60c928894a78..63ce2283a456 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2810,7 +2810,7 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
2810 } 2810 }
2811 2811
2812 if (dev->rtnl_link_state == RTNL_LINK_INITIALIZED) { 2812 if (dev->rtnl_link_state == RTNL_LINK_INITIALIZED) {
2813 __dev_notify_flags(dev, old_flags, 0U); 2813 __dev_notify_flags(dev, old_flags, (old_flags ^ dev->flags));
2814 } else { 2814 } else {
2815 dev->rtnl_link_state = RTNL_LINK_INITIALIZED; 2815 dev->rtnl_link_state = RTNL_LINK_INITIALIZED;
2816 __dev_notify_flags(dev, old_flags, ~0U); 2816 __dev_notify_flags(dev, old_flags, ~0U);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index ae714aecc31c..8cce0e9ea08c 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -178,6 +178,9 @@ static void ipgre_err(struct sk_buff *skb, u32 info,
178 178
179 if (tpi->proto == htons(ETH_P_TEB)) 179 if (tpi->proto == htons(ETH_P_TEB))
180 itn = net_generic(net, gre_tap_net_id); 180 itn = net_generic(net, gre_tap_net_id);
181 else if (tpi->proto == htons(ETH_P_ERSPAN) ||
182 tpi->proto == htons(ETH_P_ERSPAN2))
183 itn = net_generic(net, erspan_net_id);
181 else 184 else
182 itn = net_generic(net, ipgre_net_id); 185 itn = net_generic(net, ipgre_net_id);
183 186
@@ -328,6 +331,8 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
328 ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error); 331 ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
329 return PACKET_RCVD; 332 return PACKET_RCVD;
330 } 333 }
334 return PACKET_REJECT;
335
331drop: 336drop:
332 kfree_skb(skb); 337 kfree_skb(skb);
333 return PACKET_RCVD; 338 return PACKET_RCVD;
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index d9504adc47b3..184bf2e0a1ed 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -106,6 +106,10 @@ config NF_NAT_IPV4
106 106
107if NF_NAT_IPV4 107if NF_NAT_IPV4
108 108
109config NF_NAT_MASQUERADE_IPV4
110 bool
111
112if NF_TABLES
109config NFT_CHAIN_NAT_IPV4 113config NFT_CHAIN_NAT_IPV4
110 depends on NF_TABLES_IPV4 114 depends on NF_TABLES_IPV4
111 tristate "IPv4 nf_tables nat chain support" 115 tristate "IPv4 nf_tables nat chain support"
@@ -115,9 +119,6 @@ config NFT_CHAIN_NAT_IPV4
115 packet transformations such as the source, destination address and 119 packet transformations such as the source, destination address and
116 source and destination ports. 120 source and destination ports.
117 121
118config NF_NAT_MASQUERADE_IPV4
119 bool
120
121config NFT_MASQ_IPV4 122config NFT_MASQ_IPV4
122 tristate "IPv4 masquerading support for nf_tables" 123 tristate "IPv4 masquerading support for nf_tables"
123 depends on NF_TABLES_IPV4 124 depends on NF_TABLES_IPV4
@@ -135,6 +136,7 @@ config NFT_REDIR_IPV4
135 help 136 help
136 This is the expression that provides IPv4 redirect support for 137 This is the expression that provides IPv4 redirect support for
137 nf_tables. 138 nf_tables.
139endif # NF_TABLES
138 140
139config NF_NAT_SNMP_BASIC 141config NF_NAT_SNMP_BASIC
140 tristate "Basic SNMP-ALG support" 142 tristate "Basic SNMP-ALG support"
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 4c2dd9f863f7..4cf2f7bb2802 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6367,8 +6367,8 @@ static bool tcp_syn_flood_action(const struct sock *sk,
6367 if (!queue->synflood_warned && 6367 if (!queue->synflood_warned &&
6368 net->ipv4.sysctl_tcp_syncookies != 2 && 6368 net->ipv4.sysctl_tcp_syncookies != 2 &&
6369 xchg(&queue->synflood_warned, 1) == 0) 6369 xchg(&queue->synflood_warned, 1) == 0)
6370 pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n", 6370 net_info_ratelimited("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n",
6371 proto, ntohs(tcp_hdr(skb)->dest), msg); 6371 proto, ntohs(tcp_hdr(skb)->dest), msg);
6372 6372
6373 return want_cookie; 6373 return want_cookie;
6374} 6374}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 18e00ce1719a..3eed045c65a5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4670,20 +4670,31 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4670 int iif, int type, u32 portid, u32 seq, 4670 int iif, int type, u32 portid, u32 seq,
4671 unsigned int flags) 4671 unsigned int flags)
4672{ 4672{
4673 struct rtmsg *rtm; 4673 struct rt6_info *rt6 = (struct rt6_info *)dst;
4674 struct rt6key *rt6_dst, *rt6_src;
4675 u32 *pmetrics, table, rt6_flags;
4674 struct nlmsghdr *nlh; 4676 struct nlmsghdr *nlh;
4677 struct rtmsg *rtm;
4675 long expires = 0; 4678 long expires = 0;
4676 u32 *pmetrics;
4677 u32 table;
4678 4679
4679 nlh = nlmsg_put(skb, portid, seq, type, sizeof(*rtm), flags); 4680 nlh = nlmsg_put(skb, portid, seq, type, sizeof(*rtm), flags);
4680 if (!nlh) 4681 if (!nlh)
4681 return -EMSGSIZE; 4682 return -EMSGSIZE;
4682 4683
4684 if (rt6) {
4685 rt6_dst = &rt6->rt6i_dst;
4686 rt6_src = &rt6->rt6i_src;
4687 rt6_flags = rt6->rt6i_flags;
4688 } else {
4689 rt6_dst = &rt->fib6_dst;
4690 rt6_src = &rt->fib6_src;
4691 rt6_flags = rt->fib6_flags;
4692 }
4693
4683 rtm = nlmsg_data(nlh); 4694 rtm = nlmsg_data(nlh);
4684 rtm->rtm_family = AF_INET6; 4695 rtm->rtm_family = AF_INET6;
4685 rtm->rtm_dst_len = rt->fib6_dst.plen; 4696 rtm->rtm_dst_len = rt6_dst->plen;
4686 rtm->rtm_src_len = rt->fib6_src.plen; 4697 rtm->rtm_src_len = rt6_src->plen;
4687 rtm->rtm_tos = 0; 4698 rtm->rtm_tos = 0;
4688 if (rt->fib6_table) 4699 if (rt->fib6_table)
4689 table = rt->fib6_table->tb6_id; 4700 table = rt->fib6_table->tb6_id;
@@ -4698,7 +4709,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4698 rtm->rtm_scope = RT_SCOPE_UNIVERSE; 4709 rtm->rtm_scope = RT_SCOPE_UNIVERSE;
4699 rtm->rtm_protocol = rt->fib6_protocol; 4710 rtm->rtm_protocol = rt->fib6_protocol;
4700 4711
4701 if (rt->fib6_flags & RTF_CACHE) 4712 if (rt6_flags & RTF_CACHE)
4702 rtm->rtm_flags |= RTM_F_CLONED; 4713 rtm->rtm_flags |= RTM_F_CLONED;
4703 4714
4704 if (dest) { 4715 if (dest) {
@@ -4706,7 +4717,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4706 goto nla_put_failure; 4717 goto nla_put_failure;
4707 rtm->rtm_dst_len = 128; 4718 rtm->rtm_dst_len = 128;
4708 } else if (rtm->rtm_dst_len) 4719 } else if (rtm->rtm_dst_len)
4709 if (nla_put_in6_addr(skb, RTA_DST, &rt->fib6_dst.addr)) 4720 if (nla_put_in6_addr(skb, RTA_DST, &rt6_dst->addr))
4710 goto nla_put_failure; 4721 goto nla_put_failure;
4711#ifdef CONFIG_IPV6_SUBTREES 4722#ifdef CONFIG_IPV6_SUBTREES
4712 if (src) { 4723 if (src) {
@@ -4714,12 +4725,12 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4714 goto nla_put_failure; 4725 goto nla_put_failure;
4715 rtm->rtm_src_len = 128; 4726 rtm->rtm_src_len = 128;
4716 } else if (rtm->rtm_src_len && 4727 } else if (rtm->rtm_src_len &&
4717 nla_put_in6_addr(skb, RTA_SRC, &rt->fib6_src.addr)) 4728 nla_put_in6_addr(skb, RTA_SRC, &rt6_src->addr))
4718 goto nla_put_failure; 4729 goto nla_put_failure;
4719#endif 4730#endif
4720 if (iif) { 4731 if (iif) {
4721#ifdef CONFIG_IPV6_MROUTE 4732#ifdef CONFIG_IPV6_MROUTE
4722 if (ipv6_addr_is_multicast(&rt->fib6_dst.addr)) { 4733 if (ipv6_addr_is_multicast(&rt6_dst->addr)) {
4723 int err = ip6mr_get_route(net, skb, rtm, portid); 4734 int err = ip6mr_get_route(net, skb, rtm, portid);
4724 4735
4725 if (err == 0) 4736 if (err == 0)
@@ -4754,7 +4765,14 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4754 /* For multipath routes, walk the siblings list and add 4765 /* For multipath routes, walk the siblings list and add
4755 * each as a nexthop within RTA_MULTIPATH. 4766 * each as a nexthop within RTA_MULTIPATH.
4756 */ 4767 */
4757 if (rt->fib6_nsiblings) { 4768 if (rt6) {
4769 if (rt6_flags & RTF_GATEWAY &&
4770 nla_put_in6_addr(skb, RTA_GATEWAY, &rt6->rt6i_gateway))
4771 goto nla_put_failure;
4772
4773 if (dst->dev && nla_put_u32(skb, RTA_OIF, dst->dev->ifindex))
4774 goto nla_put_failure;
4775 } else if (rt->fib6_nsiblings) {
4758 struct fib6_info *sibling, *next_sibling; 4776 struct fib6_info *sibling, *next_sibling;
4759 struct nlattr *mp; 4777 struct nlattr *mp;
4760 4778
@@ -4777,7 +4795,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4777 goto nla_put_failure; 4795 goto nla_put_failure;
4778 } 4796 }
4779 4797
4780 if (rt->fib6_flags & RTF_EXPIRES) { 4798 if (rt6_flags & RTF_EXPIRES) {
4781 expires = dst ? dst->expires : rt->expires; 4799 expires = dst ? dst->expires : rt->expires;
4782 expires -= jiffies; 4800 expires -= jiffies;
4783 } 4801 }
@@ -4785,7 +4803,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4785 if (rtnl_put_cacheinfo(skb, dst, 0, expires, dst ? dst->error : 0) < 0) 4803 if (rtnl_put_cacheinfo(skb, dst, 0, expires, dst ? dst->error : 0) < 0)
4786 goto nla_put_failure; 4804 goto nla_put_failure;
4787 4805
4788 if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->fib6_flags))) 4806 if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt6_flags)))
4789 goto nla_put_failure; 4807 goto nla_put_failure;
4790 4808
4791 4809
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 71709c104081..f61c306de1d0 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -771,13 +771,13 @@ config NETFILTER_XT_TARGET_CHECKSUM
771 depends on NETFILTER_ADVANCED 771 depends on NETFILTER_ADVANCED
772 ---help--- 772 ---help---
773 This option adds a `CHECKSUM' target, which can be used in the iptables mangle 773 This option adds a `CHECKSUM' target, which can be used in the iptables mangle
774 table. 774 table to work around buggy DHCP clients in virtualized environments.
775 775
776 You can use this target to compute and fill in the checksum in 776 Some old DHCP clients drop packets because they are not aware
777 a packet that lacks a checksum. This is particularly useful, 777 that the checksum would normally be offloaded to hardware and
778 if you need to work around old applications such as dhcp clients, 778 thus should be considered valid.
779 that do not work well with checksum offloads, but don't want to disable 779 This target can be used to fill in the checksum using iptables
780 checksum offload in your device. 780 when such packets are sent via a virtual network device.
781 781
782 To compile it as a module, choose M here. If unsure, say N. 782 To compile it as a module, choose M here. If unsure, say N.
783 783
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 9f14b0df6960..51c5d7eec0a3 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -776,9 +776,26 @@ static const struct nf_hook_ops ipv6_conntrack_ops[] = {
776}; 776};
777#endif 777#endif
778 778
779static int nf_ct_tcp_fixup(struct nf_conn *ct, void *_nfproto)
780{
781 u8 nfproto = (unsigned long)_nfproto;
782
783 if (nf_ct_l3num(ct) != nfproto)
784 return 0;
785
786 if (nf_ct_protonum(ct) == IPPROTO_TCP &&
787 ct->proto.tcp.state == TCP_CONNTRACK_ESTABLISHED) {
788 ct->proto.tcp.seen[0].td_maxwin = 0;
789 ct->proto.tcp.seen[1].td_maxwin = 0;
790 }
791
792 return 0;
793}
794
779static int nf_ct_netns_do_get(struct net *net, u8 nfproto) 795static int nf_ct_netns_do_get(struct net *net, u8 nfproto)
780{ 796{
781 struct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id); 797 struct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id);
798 bool fixup_needed = false;
782 int err = 0; 799 int err = 0;
783 800
784 mutex_lock(&nf_ct_proto_mutex); 801 mutex_lock(&nf_ct_proto_mutex);
@@ -798,6 +815,8 @@ static int nf_ct_netns_do_get(struct net *net, u8 nfproto)
798 ARRAY_SIZE(ipv4_conntrack_ops)); 815 ARRAY_SIZE(ipv4_conntrack_ops));
799 if (err) 816 if (err)
800 cnet->users4 = 0; 817 cnet->users4 = 0;
818 else
819 fixup_needed = true;
801 break; 820 break;
802#if IS_ENABLED(CONFIG_IPV6) 821#if IS_ENABLED(CONFIG_IPV6)
803 case NFPROTO_IPV6: 822 case NFPROTO_IPV6:
@@ -814,6 +833,8 @@ static int nf_ct_netns_do_get(struct net *net, u8 nfproto)
814 ARRAY_SIZE(ipv6_conntrack_ops)); 833 ARRAY_SIZE(ipv6_conntrack_ops));
815 if (err) 834 if (err)
816 cnet->users6 = 0; 835 cnet->users6 = 0;
836 else
837 fixup_needed = true;
817 break; 838 break;
818#endif 839#endif
819 default: 840 default:
@@ -822,6 +843,11 @@ static int nf_ct_netns_do_get(struct net *net, u8 nfproto)
822 } 843 }
823 out_unlock: 844 out_unlock:
824 mutex_unlock(&nf_ct_proto_mutex); 845 mutex_unlock(&nf_ct_proto_mutex);
846
847 if (fixup_needed)
848 nf_ct_iterate_cleanup_net(net, nf_ct_tcp_fixup,
849 (void *)(unsigned long)nfproto, 0, 0);
850
825 return err; 851 return err;
826} 852}
827 853
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index 8c58f96b59e7..f3f91ed2c21a 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -675,7 +675,7 @@ static int nlattr_to_dccp(struct nlattr *cda[], struct nf_conn *ct)
675} 675}
676#endif 676#endif
677 677
678#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 678#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
679 679
680#include <linux/netfilter/nfnetlink.h> 680#include <linux/netfilter/nfnetlink.h>
681#include <linux/netfilter/nfnetlink_cttimeout.h> 681#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -697,6 +697,8 @@ static int dccp_timeout_nlattr_to_obj(struct nlattr *tb[],
697 timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ; 697 timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ;
698 } 698 }
699 } 699 }
700
701 timeouts[CTA_TIMEOUT_DCCP_UNSPEC] = timeouts[CTA_TIMEOUT_DCCP_REQUEST];
700 return 0; 702 return 0;
701} 703}
702 704
@@ -726,7 +728,7 @@ dccp_timeout_nla_policy[CTA_TIMEOUT_DCCP_MAX+1] = {
726 [CTA_TIMEOUT_DCCP_CLOSING] = { .type = NLA_U32 }, 728 [CTA_TIMEOUT_DCCP_CLOSING] = { .type = NLA_U32 },
727 [CTA_TIMEOUT_DCCP_TIMEWAIT] = { .type = NLA_U32 }, 729 [CTA_TIMEOUT_DCCP_TIMEWAIT] = { .type = NLA_U32 },
728}; 730};
729#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 731#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
730 732
731#ifdef CONFIG_SYSCTL 733#ifdef CONFIG_SYSCTL
732/* template, data assigned later */ 734/* template, data assigned later */
@@ -827,6 +829,11 @@ static int dccp_init_net(struct net *net, u_int16_t proto)
827 dn->dccp_timeout[CT_DCCP_CLOSEREQ] = 64 * HZ; 829 dn->dccp_timeout[CT_DCCP_CLOSEREQ] = 64 * HZ;
828 dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ; 830 dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ;
829 dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL; 831 dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL;
832
833 /* timeouts[0] is unused, make it same as SYN_SENT so
834 * ->timeouts[0] contains 'new' timeout, like udp or icmp.
835 */
836 dn->dccp_timeout[CT_DCCP_NONE] = dn->dccp_timeout[CT_DCCP_REQUEST];
830 } 837 }
831 838
832 return dccp_kmemdup_sysctl_table(net, pn, dn); 839 return dccp_kmemdup_sysctl_table(net, pn, dn);
@@ -856,7 +863,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp4 = {
856 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, 863 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
857 .nla_policy = nf_ct_port_nla_policy, 864 .nla_policy = nf_ct_port_nla_policy,
858#endif 865#endif
859#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 866#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
860 .ctnl_timeout = { 867 .ctnl_timeout = {
861 .nlattr_to_obj = dccp_timeout_nlattr_to_obj, 868 .nlattr_to_obj = dccp_timeout_nlattr_to_obj,
862 .obj_to_nlattr = dccp_timeout_obj_to_nlattr, 869 .obj_to_nlattr = dccp_timeout_obj_to_nlattr,
@@ -864,7 +871,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp4 = {
864 .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, 871 .obj_size = sizeof(unsigned int) * CT_DCCP_MAX,
865 .nla_policy = dccp_timeout_nla_policy, 872 .nla_policy = dccp_timeout_nla_policy,
866 }, 873 },
867#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 874#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
868 .init_net = dccp_init_net, 875 .init_net = dccp_init_net,
869 .get_net_proto = dccp_get_net_proto, 876 .get_net_proto = dccp_get_net_proto,
870}; 877};
@@ -889,7 +896,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp6 = {
889 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, 896 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
890 .nla_policy = nf_ct_port_nla_policy, 897 .nla_policy = nf_ct_port_nla_policy,
891#endif 898#endif
892#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 899#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
893 .ctnl_timeout = { 900 .ctnl_timeout = {
894 .nlattr_to_obj = dccp_timeout_nlattr_to_obj, 901 .nlattr_to_obj = dccp_timeout_nlattr_to_obj,
895 .obj_to_nlattr = dccp_timeout_obj_to_nlattr, 902 .obj_to_nlattr = dccp_timeout_obj_to_nlattr,
@@ -897,7 +904,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp6 = {
897 .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, 904 .obj_size = sizeof(unsigned int) * CT_DCCP_MAX,
898 .nla_policy = dccp_timeout_nla_policy, 905 .nla_policy = dccp_timeout_nla_policy,
899 }, 906 },
900#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 907#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
901 .init_net = dccp_init_net, 908 .init_net = dccp_init_net,
902 .get_net_proto = dccp_get_net_proto, 909 .get_net_proto = dccp_get_net_proto,
903}; 910};
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index ac4a0b296dcd..1df3244ecd07 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -70,7 +70,7 @@ static bool generic_new(struct nf_conn *ct, const struct sk_buff *skb,
70 return ret; 70 return ret;
71} 71}
72 72
73#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 73#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
74 74
75#include <linux/netfilter/nfnetlink.h> 75#include <linux/netfilter/nfnetlink.h>
76#include <linux/netfilter/nfnetlink_cttimeout.h> 76#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -113,7 +113,7 @@ static const struct nla_policy
113generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = { 113generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = {
114 [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 }, 114 [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 },
115}; 115};
116#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 116#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
117 117
118#ifdef CONFIG_SYSCTL 118#ifdef CONFIG_SYSCTL
119static struct ctl_table generic_sysctl_table[] = { 119static struct ctl_table generic_sysctl_table[] = {
@@ -164,7 +164,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
164 .pkt_to_tuple = generic_pkt_to_tuple, 164 .pkt_to_tuple = generic_pkt_to_tuple,
165 .packet = generic_packet, 165 .packet = generic_packet,
166 .new = generic_new, 166 .new = generic_new,
167#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 167#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
168 .ctnl_timeout = { 168 .ctnl_timeout = {
169 .nlattr_to_obj = generic_timeout_nlattr_to_obj, 169 .nlattr_to_obj = generic_timeout_nlattr_to_obj,
170 .obj_to_nlattr = generic_timeout_obj_to_nlattr, 170 .obj_to_nlattr = generic_timeout_obj_to_nlattr,
@@ -172,7 +172,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
172 .obj_size = sizeof(unsigned int), 172 .obj_size = sizeof(unsigned int),
173 .nla_policy = generic_timeout_nla_policy, 173 .nla_policy = generic_timeout_nla_policy,
174 }, 174 },
175#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 175#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
176 .init_net = generic_init_net, 176 .init_net = generic_init_net,
177 .get_net_proto = generic_get_net_proto, 177 .get_net_proto = generic_get_net_proto,
178}; 178};
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
index d1632252bf5b..650eb4fba2c5 100644
--- a/net/netfilter/nf_conntrack_proto_gre.c
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -285,7 +285,7 @@ static void gre_destroy(struct nf_conn *ct)
285 nf_ct_gre_keymap_destroy(master); 285 nf_ct_gre_keymap_destroy(master);
286} 286}
287 287
288#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 288#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
289 289
290#include <linux/netfilter/nfnetlink.h> 290#include <linux/netfilter/nfnetlink.h>
291#include <linux/netfilter/nfnetlink_cttimeout.h> 291#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -334,7 +334,7 @@ gre_timeout_nla_policy[CTA_TIMEOUT_GRE_MAX+1] = {
334 [CTA_TIMEOUT_GRE_UNREPLIED] = { .type = NLA_U32 }, 334 [CTA_TIMEOUT_GRE_UNREPLIED] = { .type = NLA_U32 },
335 [CTA_TIMEOUT_GRE_REPLIED] = { .type = NLA_U32 }, 335 [CTA_TIMEOUT_GRE_REPLIED] = { .type = NLA_U32 },
336}; 336};
337#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 337#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
338 338
339static int gre_init_net(struct net *net, u_int16_t proto) 339static int gre_init_net(struct net *net, u_int16_t proto)
340{ 340{
@@ -367,7 +367,7 @@ static const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = {
367 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, 367 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
368 .nla_policy = nf_ct_port_nla_policy, 368 .nla_policy = nf_ct_port_nla_policy,
369#endif 369#endif
370#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 370#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
371 .ctnl_timeout = { 371 .ctnl_timeout = {
372 .nlattr_to_obj = gre_timeout_nlattr_to_obj, 372 .nlattr_to_obj = gre_timeout_nlattr_to_obj,
373 .obj_to_nlattr = gre_timeout_obj_to_nlattr, 373 .obj_to_nlattr = gre_timeout_obj_to_nlattr,
@@ -375,7 +375,7 @@ static const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = {
375 .obj_size = sizeof(unsigned int) * GRE_CT_MAX, 375 .obj_size = sizeof(unsigned int) * GRE_CT_MAX,
376 .nla_policy = gre_timeout_nla_policy, 376 .nla_policy = gre_timeout_nla_policy,
377 }, 377 },
378#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 378#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
379 .net_id = &proto_gre_net_id, 379 .net_id = &proto_gre_net_id,
380 .init_net = gre_init_net, 380 .init_net = gre_init_net,
381}; 381};
diff --git a/net/netfilter/nf_conntrack_proto_icmp.c b/net/netfilter/nf_conntrack_proto_icmp.c
index 036670b38282..43c7e1a217b9 100644
--- a/net/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/netfilter/nf_conntrack_proto_icmp.c
@@ -273,7 +273,7 @@ static unsigned int icmp_nlattr_tuple_size(void)
273} 273}
274#endif 274#endif
275 275
276#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 276#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
277 277
278#include <linux/netfilter/nfnetlink.h> 278#include <linux/netfilter/nfnetlink.h>
279#include <linux/netfilter/nfnetlink_cttimeout.h> 279#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -313,7 +313,7 @@ static const struct nla_policy
313icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = { 313icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = {
314 [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 }, 314 [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 },
315}; 315};
316#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 316#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
317 317
318#ifdef CONFIG_SYSCTL 318#ifdef CONFIG_SYSCTL
319static struct ctl_table icmp_sysctl_table[] = { 319static struct ctl_table icmp_sysctl_table[] = {
@@ -374,7 +374,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
374 .nlattr_to_tuple = icmp_nlattr_to_tuple, 374 .nlattr_to_tuple = icmp_nlattr_to_tuple,
375 .nla_policy = icmp_nla_policy, 375 .nla_policy = icmp_nla_policy,
376#endif 376#endif
377#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 377#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
378 .ctnl_timeout = { 378 .ctnl_timeout = {
379 .nlattr_to_obj = icmp_timeout_nlattr_to_obj, 379 .nlattr_to_obj = icmp_timeout_nlattr_to_obj,
380 .obj_to_nlattr = icmp_timeout_obj_to_nlattr, 380 .obj_to_nlattr = icmp_timeout_obj_to_nlattr,
@@ -382,7 +382,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
382 .obj_size = sizeof(unsigned int), 382 .obj_size = sizeof(unsigned int),
383 .nla_policy = icmp_timeout_nla_policy, 383 .nla_policy = icmp_timeout_nla_policy,
384 }, 384 },
385#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 385#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
386 .init_net = icmp_init_net, 386 .init_net = icmp_init_net,
387 .get_net_proto = icmp_get_net_proto, 387 .get_net_proto = icmp_get_net_proto,
388}; 388};
diff --git a/net/netfilter/nf_conntrack_proto_icmpv6.c b/net/netfilter/nf_conntrack_proto_icmpv6.c
index bed07b998a10..97e40f77d678 100644
--- a/net/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/netfilter/nf_conntrack_proto_icmpv6.c
@@ -274,7 +274,7 @@ static unsigned int icmpv6_nlattr_tuple_size(void)
274} 274}
275#endif 275#endif
276 276
277#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 277#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
278 278
279#include <linux/netfilter/nfnetlink.h> 279#include <linux/netfilter/nfnetlink.h>
280#include <linux/netfilter/nfnetlink_cttimeout.h> 280#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -314,7 +314,7 @@ static const struct nla_policy
314icmpv6_timeout_nla_policy[CTA_TIMEOUT_ICMPV6_MAX+1] = { 314icmpv6_timeout_nla_policy[CTA_TIMEOUT_ICMPV6_MAX+1] = {
315 [CTA_TIMEOUT_ICMPV6_TIMEOUT] = { .type = NLA_U32 }, 315 [CTA_TIMEOUT_ICMPV6_TIMEOUT] = { .type = NLA_U32 },
316}; 316};
317#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 317#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
318 318
319#ifdef CONFIG_SYSCTL 319#ifdef CONFIG_SYSCTL
320static struct ctl_table icmpv6_sysctl_table[] = { 320static struct ctl_table icmpv6_sysctl_table[] = {
@@ -373,7 +373,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 =
373 .nlattr_to_tuple = icmpv6_nlattr_to_tuple, 373 .nlattr_to_tuple = icmpv6_nlattr_to_tuple,
374 .nla_policy = icmpv6_nla_policy, 374 .nla_policy = icmpv6_nla_policy,
375#endif 375#endif
376#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 376#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
377 .ctnl_timeout = { 377 .ctnl_timeout = {
378 .nlattr_to_obj = icmpv6_timeout_nlattr_to_obj, 378 .nlattr_to_obj = icmpv6_timeout_nlattr_to_obj,
379 .obj_to_nlattr = icmpv6_timeout_obj_to_nlattr, 379 .obj_to_nlattr = icmpv6_timeout_obj_to_nlattr,
@@ -381,7 +381,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 =
381 .obj_size = sizeof(unsigned int), 381 .obj_size = sizeof(unsigned int),
382 .nla_policy = icmpv6_timeout_nla_policy, 382 .nla_policy = icmpv6_timeout_nla_policy,
383 }, 383 },
384#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 384#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
385 .init_net = icmpv6_init_net, 385 .init_net = icmpv6_init_net,
386 .get_net_proto = icmpv6_get_net_proto, 386 .get_net_proto = icmpv6_get_net_proto,
387}; 387};
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index 8d1e085fc14a..e4d738d34cd0 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -591,7 +591,7 @@ static int nlattr_to_sctp(struct nlattr *cda[], struct nf_conn *ct)
591} 591}
592#endif 592#endif
593 593
594#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 594#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
595 595
596#include <linux/netfilter/nfnetlink.h> 596#include <linux/netfilter/nfnetlink.h>
597#include <linux/netfilter/nfnetlink_cttimeout.h> 597#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -613,6 +613,8 @@ static int sctp_timeout_nlattr_to_obj(struct nlattr *tb[],
613 timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ; 613 timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ;
614 } 614 }
615 } 615 }
616
617 timeouts[CTA_TIMEOUT_SCTP_UNSPEC] = timeouts[CTA_TIMEOUT_SCTP_CLOSED];
616 return 0; 618 return 0;
617} 619}
618 620
@@ -644,7 +646,7 @@ sctp_timeout_nla_policy[CTA_TIMEOUT_SCTP_MAX+1] = {
644 [CTA_TIMEOUT_SCTP_HEARTBEAT_SENT] = { .type = NLA_U32 }, 646 [CTA_TIMEOUT_SCTP_HEARTBEAT_SENT] = { .type = NLA_U32 },
645 [CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED] = { .type = NLA_U32 }, 647 [CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED] = { .type = NLA_U32 },
646}; 648};
647#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 649#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
648 650
649 651
650#ifdef CONFIG_SYSCTL 652#ifdef CONFIG_SYSCTL
@@ -743,6 +745,11 @@ static int sctp_init_net(struct net *net, u_int16_t proto)
743 745
744 for (i = 0; i < SCTP_CONNTRACK_MAX; i++) 746 for (i = 0; i < SCTP_CONNTRACK_MAX; i++)
745 sn->timeouts[i] = sctp_timeouts[i]; 747 sn->timeouts[i] = sctp_timeouts[i];
748
749 /* timeouts[0] is unused, init it so ->timeouts[0] contains
750 * 'new' timeout, like udp or icmp.
751 */
752 sn->timeouts[0] = sctp_timeouts[SCTP_CONNTRACK_CLOSED];
746 } 753 }
747 754
748 return sctp_kmemdup_sysctl_table(pn, sn); 755 return sctp_kmemdup_sysctl_table(pn, sn);
@@ -773,7 +780,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = {
773 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, 780 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
774 .nla_policy = nf_ct_port_nla_policy, 781 .nla_policy = nf_ct_port_nla_policy,
775#endif 782#endif
776#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 783#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
777 .ctnl_timeout = { 784 .ctnl_timeout = {
778 .nlattr_to_obj = sctp_timeout_nlattr_to_obj, 785 .nlattr_to_obj = sctp_timeout_nlattr_to_obj,
779 .obj_to_nlattr = sctp_timeout_obj_to_nlattr, 786 .obj_to_nlattr = sctp_timeout_obj_to_nlattr,
@@ -781,7 +788,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = {
781 .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, 788 .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX,
782 .nla_policy = sctp_timeout_nla_policy, 789 .nla_policy = sctp_timeout_nla_policy,
783 }, 790 },
784#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 791#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
785 .init_net = sctp_init_net, 792 .init_net = sctp_init_net,
786 .get_net_proto = sctp_get_net_proto, 793 .get_net_proto = sctp_get_net_proto,
787}; 794};
@@ -806,7 +813,8 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = {
806 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, 813 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
807 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, 814 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
808 .nla_policy = nf_ct_port_nla_policy, 815 .nla_policy = nf_ct_port_nla_policy,
809#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 816#endif
817#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
810 .ctnl_timeout = { 818 .ctnl_timeout = {
811 .nlattr_to_obj = sctp_timeout_nlattr_to_obj, 819 .nlattr_to_obj = sctp_timeout_nlattr_to_obj,
812 .obj_to_nlattr = sctp_timeout_obj_to_nlattr, 820 .obj_to_nlattr = sctp_timeout_obj_to_nlattr,
@@ -814,8 +822,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = {
814 .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, 822 .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX,
815 .nla_policy = sctp_timeout_nla_policy, 823 .nla_policy = sctp_timeout_nla_policy,
816 }, 824 },
817#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 825#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
818#endif
819 .init_net = sctp_init_net, 826 .init_net = sctp_init_net,
820 .get_net_proto = sctp_get_net_proto, 827 .get_net_proto = sctp_get_net_proto,
821}; 828};
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index d80d322b9d8b..b4bdf9eda7b7 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -1279,7 +1279,7 @@ static unsigned int tcp_nlattr_tuple_size(void)
1279} 1279}
1280#endif 1280#endif
1281 1281
1282#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 1282#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
1283 1283
1284#include <linux/netfilter/nfnetlink.h> 1284#include <linux/netfilter/nfnetlink.h>
1285#include <linux/netfilter/nfnetlink_cttimeout.h> 1285#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -1301,6 +1301,7 @@ static int tcp_timeout_nlattr_to_obj(struct nlattr *tb[],
1301 timeouts[TCP_CONNTRACK_SYN_SENT] = 1301 timeouts[TCP_CONNTRACK_SYN_SENT] =
1302 ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_SENT]))*HZ; 1302 ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_SENT]))*HZ;
1303 } 1303 }
1304
1304 if (tb[CTA_TIMEOUT_TCP_SYN_RECV]) { 1305 if (tb[CTA_TIMEOUT_TCP_SYN_RECV]) {
1305 timeouts[TCP_CONNTRACK_SYN_RECV] = 1306 timeouts[TCP_CONNTRACK_SYN_RECV] =
1306 ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_RECV]))*HZ; 1307 ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_RECV]))*HZ;
@@ -1341,6 +1342,8 @@ static int tcp_timeout_nlattr_to_obj(struct nlattr *tb[],
1341 timeouts[TCP_CONNTRACK_UNACK] = 1342 timeouts[TCP_CONNTRACK_UNACK] =
1342 ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_UNACK]))*HZ; 1343 ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_UNACK]))*HZ;
1343 } 1344 }
1345
1346 timeouts[CTA_TIMEOUT_TCP_UNSPEC] = timeouts[CTA_TIMEOUT_TCP_SYN_SENT];
1344 return 0; 1347 return 0;
1345} 1348}
1346 1349
@@ -1391,7 +1394,7 @@ static const struct nla_policy tcp_timeout_nla_policy[CTA_TIMEOUT_TCP_MAX+1] = {
1391 [CTA_TIMEOUT_TCP_RETRANS] = { .type = NLA_U32 }, 1394 [CTA_TIMEOUT_TCP_RETRANS] = { .type = NLA_U32 },
1392 [CTA_TIMEOUT_TCP_UNACK] = { .type = NLA_U32 }, 1395 [CTA_TIMEOUT_TCP_UNACK] = { .type = NLA_U32 },
1393}; 1396};
1394#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 1397#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
1395 1398
1396#ifdef CONFIG_SYSCTL 1399#ifdef CONFIG_SYSCTL
1397static struct ctl_table tcp_sysctl_table[] = { 1400static struct ctl_table tcp_sysctl_table[] = {
@@ -1518,6 +1521,10 @@ static int tcp_init_net(struct net *net, u_int16_t proto)
1518 for (i = 0; i < TCP_CONNTRACK_TIMEOUT_MAX; i++) 1521 for (i = 0; i < TCP_CONNTRACK_TIMEOUT_MAX; i++)
1519 tn->timeouts[i] = tcp_timeouts[i]; 1522 tn->timeouts[i] = tcp_timeouts[i];
1520 1523
1524 /* timeouts[0] is unused, make it same as SYN_SENT so
1525 * ->timeouts[0] contains 'new' timeout, like udp or icmp.
1526 */
1527 tn->timeouts[0] = tcp_timeouts[TCP_CONNTRACK_SYN_SENT];
1521 tn->tcp_loose = nf_ct_tcp_loose; 1528 tn->tcp_loose = nf_ct_tcp_loose;
1522 tn->tcp_be_liberal = nf_ct_tcp_be_liberal; 1529 tn->tcp_be_liberal = nf_ct_tcp_be_liberal;
1523 tn->tcp_max_retrans = nf_ct_tcp_max_retrans; 1530 tn->tcp_max_retrans = nf_ct_tcp_max_retrans;
@@ -1551,7 +1558,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 =
1551 .nlattr_size = TCP_NLATTR_SIZE, 1558 .nlattr_size = TCP_NLATTR_SIZE,
1552 .nla_policy = nf_ct_port_nla_policy, 1559 .nla_policy = nf_ct_port_nla_policy,
1553#endif 1560#endif
1554#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 1561#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
1555 .ctnl_timeout = { 1562 .ctnl_timeout = {
1556 .nlattr_to_obj = tcp_timeout_nlattr_to_obj, 1563 .nlattr_to_obj = tcp_timeout_nlattr_to_obj,
1557 .obj_to_nlattr = tcp_timeout_obj_to_nlattr, 1564 .obj_to_nlattr = tcp_timeout_obj_to_nlattr,
@@ -1560,7 +1567,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 =
1560 TCP_CONNTRACK_TIMEOUT_MAX, 1567 TCP_CONNTRACK_TIMEOUT_MAX,
1561 .nla_policy = tcp_timeout_nla_policy, 1568 .nla_policy = tcp_timeout_nla_policy,
1562 }, 1569 },
1563#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 1570#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
1564 .init_net = tcp_init_net, 1571 .init_net = tcp_init_net,
1565 .get_net_proto = tcp_get_net_proto, 1572 .get_net_proto = tcp_get_net_proto,
1566}; 1573};
@@ -1586,7 +1593,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 =
1586 .nlattr_tuple_size = tcp_nlattr_tuple_size, 1593 .nlattr_tuple_size = tcp_nlattr_tuple_size,
1587 .nla_policy = nf_ct_port_nla_policy, 1594 .nla_policy = nf_ct_port_nla_policy,
1588#endif 1595#endif
1589#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 1596#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
1590 .ctnl_timeout = { 1597 .ctnl_timeout = {
1591 .nlattr_to_obj = tcp_timeout_nlattr_to_obj, 1598 .nlattr_to_obj = tcp_timeout_nlattr_to_obj,
1592 .obj_to_nlattr = tcp_timeout_obj_to_nlattr, 1599 .obj_to_nlattr = tcp_timeout_obj_to_nlattr,
@@ -1595,7 +1602,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 =
1595 TCP_CONNTRACK_TIMEOUT_MAX, 1602 TCP_CONNTRACK_TIMEOUT_MAX,
1596 .nla_policy = tcp_timeout_nla_policy, 1603 .nla_policy = tcp_timeout_nla_policy,
1597 }, 1604 },
1598#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 1605#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
1599 .init_net = tcp_init_net, 1606 .init_net = tcp_init_net,
1600 .get_net_proto = tcp_get_net_proto, 1607 .get_net_proto = tcp_get_net_proto,
1601}; 1608};
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 7a1b8988a931..3065fb8ef91b 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -171,7 +171,7 @@ static int udp_error(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
171 return NF_ACCEPT; 171 return NF_ACCEPT;
172} 172}
173 173
174#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 174#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
175 175
176#include <linux/netfilter/nfnetlink.h> 176#include <linux/netfilter/nfnetlink.h>
177#include <linux/netfilter/nfnetlink_cttimeout.h> 177#include <linux/netfilter/nfnetlink_cttimeout.h>
@@ -221,7 +221,7 @@ udp_timeout_nla_policy[CTA_TIMEOUT_UDP_MAX+1] = {
221 [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 }, 221 [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 },
222 [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 }, 222 [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 },
223}; 223};
224#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 224#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
225 225
226#ifdef CONFIG_SYSCTL 226#ifdef CONFIG_SYSCTL
227static struct ctl_table udp_sysctl_table[] = { 227static struct ctl_table udp_sysctl_table[] = {
@@ -292,7 +292,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 =
292 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, 292 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
293 .nla_policy = nf_ct_port_nla_policy, 293 .nla_policy = nf_ct_port_nla_policy,
294#endif 294#endif
295#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 295#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
296 .ctnl_timeout = { 296 .ctnl_timeout = {
297 .nlattr_to_obj = udp_timeout_nlattr_to_obj, 297 .nlattr_to_obj = udp_timeout_nlattr_to_obj,
298 .obj_to_nlattr = udp_timeout_obj_to_nlattr, 298 .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -300,7 +300,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 =
300 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, 300 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
301 .nla_policy = udp_timeout_nla_policy, 301 .nla_policy = udp_timeout_nla_policy,
302 }, 302 },
303#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 303#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
304 .init_net = udp_init_net, 304 .init_net = udp_init_net,
305 .get_net_proto = udp_get_net_proto, 305 .get_net_proto = udp_get_net_proto,
306}; 306};
@@ -321,7 +321,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 =
321 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, 321 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
322 .nla_policy = nf_ct_port_nla_policy, 322 .nla_policy = nf_ct_port_nla_policy,
323#endif 323#endif
324#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 324#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
325 .ctnl_timeout = { 325 .ctnl_timeout = {
326 .nlattr_to_obj = udp_timeout_nlattr_to_obj, 326 .nlattr_to_obj = udp_timeout_nlattr_to_obj,
327 .obj_to_nlattr = udp_timeout_obj_to_nlattr, 327 .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -329,7 +329,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 =
329 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, 329 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
330 .nla_policy = udp_timeout_nla_policy, 330 .nla_policy = udp_timeout_nla_policy,
331 }, 331 },
332#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 332#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
333 .init_net = udp_init_net, 333 .init_net = udp_init_net,
334 .get_net_proto = udp_get_net_proto, 334 .get_net_proto = udp_get_net_proto,
335}; 335};
@@ -350,7 +350,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 =
350 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, 350 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
351 .nla_policy = nf_ct_port_nla_policy, 351 .nla_policy = nf_ct_port_nla_policy,
352#endif 352#endif
353#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 353#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
354 .ctnl_timeout = { 354 .ctnl_timeout = {
355 .nlattr_to_obj = udp_timeout_nlattr_to_obj, 355 .nlattr_to_obj = udp_timeout_nlattr_to_obj,
356 .obj_to_nlattr = udp_timeout_obj_to_nlattr, 356 .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -358,7 +358,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 =
358 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, 358 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
359 .nla_policy = udp_timeout_nla_policy, 359 .nla_policy = udp_timeout_nla_policy,
360 }, 360 },
361#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 361#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
362 .init_net = udp_init_net, 362 .init_net = udp_init_net,
363 .get_net_proto = udp_get_net_proto, 363 .get_net_proto = udp_get_net_proto,
364}; 364};
@@ -379,7 +379,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 =
379 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, 379 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
380 .nla_policy = nf_ct_port_nla_policy, 380 .nla_policy = nf_ct_port_nla_policy,
381#endif 381#endif
382#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 382#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
383 .ctnl_timeout = { 383 .ctnl_timeout = {
384 .nlattr_to_obj = udp_timeout_nlattr_to_obj, 384 .nlattr_to_obj = udp_timeout_nlattr_to_obj,
385 .obj_to_nlattr = udp_timeout_obj_to_nlattr, 385 .obj_to_nlattr = udp_timeout_obj_to_nlattr,
@@ -387,10 +387,9 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 =
387 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, 387 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
388 .nla_policy = udp_timeout_nla_policy, 388 .nla_policy = udp_timeout_nla_policy,
389 }, 389 },
390#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ 390#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
391 .init_net = udp_init_net, 391 .init_net = udp_init_net,
392 .get_net_proto = udp_get_net_proto, 392 .get_net_proto = udp_get_net_proto,
393}; 393};
394EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udplite6); 394EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udplite6);
395#endif 395#endif
396#include <net/netfilter/nf_conntrack_timeout.h>
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 1dca5683f59f..2cfb173cd0b2 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4637,6 +4637,7 @@ static int nft_flush_set(const struct nft_ctx *ctx,
4637 } 4637 }
4638 set->ndeact++; 4638 set->ndeact++;
4639 4639
4640 nft_set_elem_deactivate(ctx->net, set, elem);
4640 nft_trans_elem_set(trans) = set; 4641 nft_trans_elem_set(trans) = set;
4641 nft_trans_elem(trans) = *elem; 4642 nft_trans_elem(trans) = *elem;
4642 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 4643 list_add_tail(&trans->list, &ctx->net->nft.commit_list);
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index d46a236cdf31..a30f8ba4b89a 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -489,8 +489,8 @@ err:
489 return err; 489 return err;
490} 490}
491 491
492static struct ctnl_timeout * 492static struct nf_ct_timeout *ctnl_timeout_find_get(struct net *net,
493ctnl_timeout_find_get(struct net *net, const char *name) 493 const char *name)
494{ 494{
495 struct ctnl_timeout *timeout, *matching = NULL; 495 struct ctnl_timeout *timeout, *matching = NULL;
496 496
@@ -509,7 +509,7 @@ ctnl_timeout_find_get(struct net *net, const char *name)
509 break; 509 break;
510 } 510 }
511err: 511err:
512 return matching; 512 return matching ? &matching->timeout : NULL;
513} 513}
514 514
515static void ctnl_timeout_put(struct nf_ct_timeout *t) 515static void ctnl_timeout_put(struct nf_ct_timeout *t)
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index ea4ba551abb2..d33094f4ec41 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -233,6 +233,7 @@ static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict)
233 int err; 233 int err;
234 234
235 if (verdict == NF_ACCEPT || 235 if (verdict == NF_ACCEPT ||
236 verdict == NF_REPEAT ||
236 verdict == NF_STOP) { 237 verdict == NF_STOP) {
237 rcu_read_lock(); 238 rcu_read_lock();
238 ct_hook = rcu_dereference(nf_ct_hook); 239 ct_hook = rcu_dereference(nf_ct_hook);
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index 26a8baebd072..5dd87748afa8 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -799,7 +799,7 @@ err:
799} 799}
800 800
801struct nft_ct_timeout_obj { 801struct nft_ct_timeout_obj {
802 struct nf_conn *tmpl; 802 struct nf_ct_timeout *timeout;
803 u8 l4proto; 803 u8 l4proto;
804}; 804};
805 805
@@ -809,26 +809,42 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj,
809{ 809{
810 const struct nft_ct_timeout_obj *priv = nft_obj_data(obj); 810 const struct nft_ct_timeout_obj *priv = nft_obj_data(obj);
811 struct nf_conn *ct = (struct nf_conn *)skb_nfct(pkt->skb); 811 struct nf_conn *ct = (struct nf_conn *)skb_nfct(pkt->skb);
812 struct sk_buff *skb = pkt->skb; 812 struct nf_conn_timeout *timeout;
813 const unsigned int *values;
814
815 if (priv->l4proto != pkt->tprot)
816 return;
813 817
814 if (ct || 818 if (!ct || nf_ct_is_template(ct) || nf_ct_is_confirmed(ct))
815 priv->l4proto != pkt->tprot)
816 return; 819 return;
817 820
818 nf_ct_set(skb, priv->tmpl, IP_CT_NEW); 821 timeout = nf_ct_timeout_find(ct);
822 if (!timeout) {
823 timeout = nf_ct_timeout_ext_add(ct, priv->timeout, GFP_ATOMIC);
824 if (!timeout) {
825 regs->verdict.code = NF_DROP;
826 return;
827 }
828 }
829
830 rcu_assign_pointer(timeout->timeout, priv->timeout);
831
832 /* adjust the timeout as per 'new' state. ct is unconfirmed,
833 * so the current timestamp must not be added.
834 */
835 values = nf_ct_timeout_data(timeout);
836 if (values)
837 nf_ct_refresh(ct, pkt->skb, values[0]);
819} 838}
820 839
821static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx, 840static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
822 const struct nlattr * const tb[], 841 const struct nlattr * const tb[],
823 struct nft_object *obj) 842 struct nft_object *obj)
824{ 843{
825 const struct nf_conntrack_zone *zone = &nf_ct_zone_dflt;
826 struct nft_ct_timeout_obj *priv = nft_obj_data(obj); 844 struct nft_ct_timeout_obj *priv = nft_obj_data(obj);
827 const struct nf_conntrack_l4proto *l4proto; 845 const struct nf_conntrack_l4proto *l4proto;
828 struct nf_conn_timeout *timeout_ext;
829 struct nf_ct_timeout *timeout; 846 struct nf_ct_timeout *timeout;
830 int l3num = ctx->family; 847 int l3num = ctx->family;
831 struct nf_conn *tmpl;
832 __u8 l4num; 848 __u8 l4num;
833 int ret; 849 int ret;
834 850
@@ -863,28 +879,14 @@ static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
863 879
864 timeout->l3num = l3num; 880 timeout->l3num = l3num;
865 timeout->l4proto = l4proto; 881 timeout->l4proto = l4proto;
866 tmpl = nf_ct_tmpl_alloc(ctx->net, zone, GFP_ATOMIC);
867 if (!tmpl) {
868 ret = -ENOMEM;
869 goto err_free_timeout;
870 }
871
872 timeout_ext = nf_ct_timeout_ext_add(tmpl, timeout, GFP_ATOMIC);
873 if (!timeout_ext) {
874 ret = -ENOMEM;
875 goto err_free_tmpl;
876 }
877 882
878 ret = nf_ct_netns_get(ctx->net, ctx->family); 883 ret = nf_ct_netns_get(ctx->net, ctx->family);
879 if (ret < 0) 884 if (ret < 0)
880 goto err_free_tmpl; 885 goto err_free_timeout;
881
882 priv->tmpl = tmpl;
883 886
887 priv->timeout = timeout;
884 return 0; 888 return 0;
885 889
886err_free_tmpl:
887 nf_ct_tmpl_free(tmpl);
888err_free_timeout: 890err_free_timeout:
889 kfree(timeout); 891 kfree(timeout);
890err_proto_put: 892err_proto_put:
@@ -896,22 +898,19 @@ static void nft_ct_timeout_obj_destroy(const struct nft_ctx *ctx,
896 struct nft_object *obj) 898 struct nft_object *obj)
897{ 899{
898 struct nft_ct_timeout_obj *priv = nft_obj_data(obj); 900 struct nft_ct_timeout_obj *priv = nft_obj_data(obj);
899 struct nf_conn_timeout *t = nf_ct_timeout_find(priv->tmpl); 901 struct nf_ct_timeout *timeout = priv->timeout;
900 struct nf_ct_timeout *timeout;
901 902
902 timeout = rcu_dereference_raw(t->timeout);
903 nf_ct_untimeout(ctx->net, timeout); 903 nf_ct_untimeout(ctx->net, timeout);
904 nf_ct_l4proto_put(timeout->l4proto); 904 nf_ct_l4proto_put(timeout->l4proto);
905 nf_ct_netns_put(ctx->net, ctx->family); 905 nf_ct_netns_put(ctx->net, ctx->family);
906 nf_ct_tmpl_free(priv->tmpl); 906 kfree(priv->timeout);
907} 907}
908 908
909static int nft_ct_timeout_obj_dump(struct sk_buff *skb, 909static int nft_ct_timeout_obj_dump(struct sk_buff *skb,
910 struct nft_object *obj, bool reset) 910 struct nft_object *obj, bool reset)
911{ 911{
912 const struct nft_ct_timeout_obj *priv = nft_obj_data(obj); 912 const struct nft_ct_timeout_obj *priv = nft_obj_data(obj);
913 const struct nf_conn_timeout *t = nf_ct_timeout_find(priv->tmpl); 913 const struct nf_ct_timeout *timeout = priv->timeout;
914 const struct nf_ct_timeout *timeout = rcu_dereference_raw(t->timeout);
915 struct nlattr *nest_params; 914 struct nlattr *nest_params;
916 int ret; 915 int ret;
917 916
diff --git a/net/netfilter/xt_CHECKSUM.c b/net/netfilter/xt_CHECKSUM.c
index 9f4151ec3e06..6c7aa6a0a0d2 100644
--- a/net/netfilter/xt_CHECKSUM.c
+++ b/net/netfilter/xt_CHECKSUM.c
@@ -16,6 +16,9 @@
16#include <linux/netfilter/x_tables.h> 16#include <linux/netfilter/x_tables.h>
17#include <linux/netfilter/xt_CHECKSUM.h> 17#include <linux/netfilter/xt_CHECKSUM.h>
18 18
19#include <linux/netfilter_ipv4/ip_tables.h>
20#include <linux/netfilter_ipv6/ip6_tables.h>
21
19MODULE_LICENSE("GPL"); 22MODULE_LICENSE("GPL");
20MODULE_AUTHOR("Michael S. Tsirkin <mst@redhat.com>"); 23MODULE_AUTHOR("Michael S. Tsirkin <mst@redhat.com>");
21MODULE_DESCRIPTION("Xtables: checksum modification"); 24MODULE_DESCRIPTION("Xtables: checksum modification");
@@ -25,7 +28,7 @@ MODULE_ALIAS("ip6t_CHECKSUM");
25static unsigned int 28static unsigned int
26checksum_tg(struct sk_buff *skb, const struct xt_action_param *par) 29checksum_tg(struct sk_buff *skb, const struct xt_action_param *par)
27{ 30{
28 if (skb->ip_summed == CHECKSUM_PARTIAL) 31 if (skb->ip_summed == CHECKSUM_PARTIAL && !skb_is_gso(skb))
29 skb_checksum_help(skb); 32 skb_checksum_help(skb);
30 33
31 return XT_CONTINUE; 34 return XT_CONTINUE;
@@ -34,6 +37,8 @@ checksum_tg(struct sk_buff *skb, const struct xt_action_param *par)
34static int checksum_tg_check(const struct xt_tgchk_param *par) 37static int checksum_tg_check(const struct xt_tgchk_param *par)
35{ 38{
36 const struct xt_CHECKSUM_info *einfo = par->targinfo; 39 const struct xt_CHECKSUM_info *einfo = par->targinfo;
40 const struct ip6t_ip6 *i6 = par->entryinfo;
41 const struct ipt_ip *i4 = par->entryinfo;
37 42
38 if (einfo->operation & ~XT_CHECKSUM_OP_FILL) { 43 if (einfo->operation & ~XT_CHECKSUM_OP_FILL) {
39 pr_info_ratelimited("unsupported CHECKSUM operation %x\n", 44 pr_info_ratelimited("unsupported CHECKSUM operation %x\n",
@@ -43,6 +48,21 @@ static int checksum_tg_check(const struct xt_tgchk_param *par)
43 if (!einfo->operation) 48 if (!einfo->operation)
44 return -EINVAL; 49 return -EINVAL;
45 50
51 switch (par->family) {
52 case NFPROTO_IPV4:
53 if (i4->proto == IPPROTO_UDP &&
54 (i4->invflags & XT_INV_PROTO) == 0)
55 return 0;
56 break;
57 case NFPROTO_IPV6:
58 if ((i6->flags & IP6T_F_PROTO) &&
59 i6->proto == IPPROTO_UDP &&
60 (i6->invflags & XT_INV_PROTO) == 0)
61 return 0;
62 break;
63 }
64
65 pr_warn_once("CHECKSUM should be avoided. If really needed, restrict with \"-p udp\" and only use in OUTPUT\n");
46 return 0; 66 return 0;
47} 67}
48 68
diff --git a/net/netfilter/xt_cluster.c b/net/netfilter/xt_cluster.c
index dfbdbb2fc0ed..51d0c257e7a5 100644
--- a/net/netfilter/xt_cluster.c
+++ b/net/netfilter/xt_cluster.c
@@ -125,6 +125,7 @@ xt_cluster_mt(const struct sk_buff *skb, struct xt_action_param *par)
125static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par) 125static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par)
126{ 126{
127 struct xt_cluster_match_info *info = par->matchinfo; 127 struct xt_cluster_match_info *info = par->matchinfo;
128 int ret;
128 129
129 if (info->total_nodes > XT_CLUSTER_NODES_MAX) { 130 if (info->total_nodes > XT_CLUSTER_NODES_MAX) {
130 pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n", 131 pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n",
@@ -135,7 +136,17 @@ static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par)
135 pr_info_ratelimited("node mask cannot exceed total number of nodes\n"); 136 pr_info_ratelimited("node mask cannot exceed total number of nodes\n");
136 return -EDOM; 137 return -EDOM;
137 } 138 }
138 return 0; 139
140 ret = nf_ct_netns_get(par->net, par->family);
141 if (ret < 0)
142 pr_info_ratelimited("cannot load conntrack support for proto=%u\n",
143 par->family);
144 return ret;
145}
146
147static void xt_cluster_mt_destroy(const struct xt_mtdtor_param *par)
148{
149 nf_ct_netns_put(par->net, par->family);
139} 150}
140 151
141static struct xt_match xt_cluster_match __read_mostly = { 152static struct xt_match xt_cluster_match __read_mostly = {
@@ -144,6 +155,7 @@ static struct xt_match xt_cluster_match __read_mostly = {
144 .match = xt_cluster_mt, 155 .match = xt_cluster_mt,
145 .checkentry = xt_cluster_mt_checkentry, 156 .checkentry = xt_cluster_mt_checkentry,
146 .matchsize = sizeof(struct xt_cluster_match_info), 157 .matchsize = sizeof(struct xt_cluster_match_info),
158 .destroy = xt_cluster_mt_destroy,
147 .me = THIS_MODULE, 159 .me = THIS_MODULE,
148}; 160};
149 161
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 9b16402f29af..3e7d259e5d8d 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -1057,7 +1057,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = {
1057static void *dl_seq_start(struct seq_file *s, loff_t *pos) 1057static void *dl_seq_start(struct seq_file *s, loff_t *pos)
1058 __acquires(htable->lock) 1058 __acquires(htable->lock)
1059{ 1059{
1060 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); 1060 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file));
1061 unsigned int *bucket; 1061 unsigned int *bucket;
1062 1062
1063 spin_lock_bh(&htable->lock); 1063 spin_lock_bh(&htable->lock);
@@ -1074,7 +1074,7 @@ static void *dl_seq_start(struct seq_file *s, loff_t *pos)
1074 1074
1075static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos) 1075static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
1076{ 1076{
1077 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); 1077 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file));
1078 unsigned int *bucket = v; 1078 unsigned int *bucket = v;
1079 1079
1080 *pos = ++(*bucket); 1080 *pos = ++(*bucket);
@@ -1088,7 +1088,7 @@ static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
1088static void dl_seq_stop(struct seq_file *s, void *v) 1088static void dl_seq_stop(struct seq_file *s, void *v)
1089 __releases(htable->lock) 1089 __releases(htable->lock)
1090{ 1090{
1091 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); 1091 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file));
1092 unsigned int *bucket = v; 1092 unsigned int *bucket = v;
1093 1093
1094 if (!IS_ERR(bucket)) 1094 if (!IS_ERR(bucket))
@@ -1130,7 +1130,7 @@ static void dl_seq_print(struct dsthash_ent *ent, u_int8_t family,
1130static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family, 1130static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family,
1131 struct seq_file *s) 1131 struct seq_file *s)
1132{ 1132{
1133 struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private)); 1133 struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->file));
1134 1134
1135 spin_lock(&ent->lock); 1135 spin_lock(&ent->lock);
1136 /* recalculate to show accurate numbers */ 1136 /* recalculate to show accurate numbers */
@@ -1145,7 +1145,7 @@ static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family,
1145static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family, 1145static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family,
1146 struct seq_file *s) 1146 struct seq_file *s)
1147{ 1147{
1148 struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private)); 1148 struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->file));
1149 1149
1150 spin_lock(&ent->lock); 1150 spin_lock(&ent->lock);
1151 /* recalculate to show accurate numbers */ 1151 /* recalculate to show accurate numbers */
@@ -1160,7 +1160,7 @@ static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family,
1160static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, 1160static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
1161 struct seq_file *s) 1161 struct seq_file *s)
1162{ 1162{
1163 struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private)); 1163 struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->file));
1164 1164
1165 spin_lock(&ent->lock); 1165 spin_lock(&ent->lock);
1166 /* recalculate to show accurate numbers */ 1166 /* recalculate to show accurate numbers */
@@ -1174,7 +1174,7 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
1174 1174
1175static int dl_seq_show_v2(struct seq_file *s, void *v) 1175static int dl_seq_show_v2(struct seq_file *s, void *v)
1176{ 1176{
1177 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); 1177 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file));
1178 unsigned int *bucket = (unsigned int *)v; 1178 unsigned int *bucket = (unsigned int *)v;
1179 struct dsthash_ent *ent; 1179 struct dsthash_ent *ent;
1180 1180
@@ -1188,7 +1188,7 @@ static int dl_seq_show_v2(struct seq_file *s, void *v)
1188 1188
1189static int dl_seq_show_v1(struct seq_file *s, void *v) 1189static int dl_seq_show_v1(struct seq_file *s, void *v)
1190{ 1190{
1191 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); 1191 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file));
1192 unsigned int *bucket = v; 1192 unsigned int *bucket = v;
1193 struct dsthash_ent *ent; 1193 struct dsthash_ent *ent;
1194 1194
@@ -1202,7 +1202,7 @@ static int dl_seq_show_v1(struct seq_file *s, void *v)
1202 1202
1203static int dl_seq_show(struct seq_file *s, void *v) 1203static int dl_seq_show(struct seq_file *s, void *v)
1204{ 1204{
1205 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); 1205 struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file));
1206 unsigned int *bucket = v; 1206 unsigned int *bucket = v;
1207 struct dsthash_ent *ent; 1207 struct dsthash_ent *ent;
1208 1208
diff --git a/net/rds/bind.c b/net/rds/bind.c
index 3ab55784b637..762d2c6788a3 100644
--- a/net/rds/bind.c
+++ b/net/rds/bind.c
@@ -76,11 +76,13 @@ struct rds_sock *rds_find_bound(const struct in6_addr *addr, __be16 port,
76 struct rds_sock *rs; 76 struct rds_sock *rs;
77 77
78 __rds_create_bind_key(key, addr, port, scope_id); 78 __rds_create_bind_key(key, addr, port, scope_id);
79 rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms); 79 rcu_read_lock();
80 rs = rhashtable_lookup(&bind_hash_table, key, ht_parms);
80 if (rs && !sock_flag(rds_rs_to_sk(rs), SOCK_DEAD)) 81 if (rs && !sock_flag(rds_rs_to_sk(rs), SOCK_DEAD))
81 rds_sock_addref(rs); 82 rds_sock_addref(rs);
82 else 83 else
83 rs = NULL; 84 rs = NULL;
85 rcu_read_unlock();
84 86
85 rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr, 87 rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr,
86 ntohs(port)); 88 ntohs(port));
@@ -235,6 +237,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
235 goto out; 237 goto out;
236 } 238 }
237 239
240 sock_set_flag(sk, SOCK_RCU_FREE);
238 ret = rds_add_bound(rs, binding_addr, &port, scope_id); 241 ret = rds_add_bound(rs, binding_addr, &port, scope_id);
239 if (ret) 242 if (ret)
240 goto out; 243 goto out;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 1a67af8a6e8c..0a75cb2e5e7b 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -1902,6 +1902,8 @@ replay:
1902 RTM_NEWCHAIN, false); 1902 RTM_NEWCHAIN, false);
1903 break; 1903 break;
1904 case RTM_DELCHAIN: 1904 case RTM_DELCHAIN:
1905 tfilter_notify_chain(net, skb, block, q, parent, n,
1906 chain, RTM_DELTFILTER);
1905 /* Flush the chain first as the user requested chain removal. */ 1907 /* Flush the chain first as the user requested chain removal. */
1906 tcf_chain_flush(chain); 1908 tcf_chain_flush(chain);
1907 /* In case the chain was successfully deleted, put a reference 1909 /* In case the chain was successfully deleted, put a reference
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 82f665728382..6376467e78f8 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -185,7 +185,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
185 return -ENOMEM; 185 return -ENOMEM;
186 186
187 buf->sk = msg->dst_sk; 187 buf->sk = msg->dst_sk;
188 __tipc_dump_start(&cb, msg->net); 188 if (__tipc_dump_start(&cb, msg->net)) {
189 kfree_skb(buf);
190 return -ENOMEM;
191 }
189 192
190 do { 193 do {
191 int rem; 194 int rem;
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 292742e50bfa..961b07d4d41c 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -686,7 +686,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
686 goto free_marker_record; 686 goto free_marker_record;
687 } 687 }
688 688
689 crypto_info = &ctx->crypto_send; 689 crypto_info = &ctx->crypto_send.info;
690 switch (crypto_info->cipher_type) { 690 switch (crypto_info->cipher_type) {
691 case TLS_CIPHER_AES_GCM_128: 691 case TLS_CIPHER_AES_GCM_128:
692 nonce_size = TLS_CIPHER_AES_GCM_128_IV_SIZE; 692 nonce_size = TLS_CIPHER_AES_GCM_128_IV_SIZE;
@@ -780,7 +780,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
780 780
781 ctx->priv_ctx_tx = offload_ctx; 781 ctx->priv_ctx_tx = offload_ctx;
782 rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_TX, 782 rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_TX,
783 &ctx->crypto_send, 783 &ctx->crypto_send.info,
784 tcp_sk(sk)->write_seq); 784 tcp_sk(sk)->write_seq);
785 if (rc) 785 if (rc)
786 goto release_netdev; 786 goto release_netdev;
@@ -862,7 +862,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
862 goto release_ctx; 862 goto release_ctx;
863 863
864 rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_RX, 864 rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_RX,
865 &ctx->crypto_recv, 865 &ctx->crypto_recv.info,
866 tcp_sk(sk)->copied_seq); 866 tcp_sk(sk)->copied_seq);
867 if (rc) { 867 if (rc) {
868 pr_err_ratelimited("%s: The netdev has refused to offload this socket\n", 868 pr_err_ratelimited("%s: The netdev has refused to offload this socket\n",
diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c
index 6102169239d1..450a6dbc5a88 100644
--- a/net/tls/tls_device_fallback.c
+++ b/net/tls/tls_device_fallback.c
@@ -320,7 +320,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx,
320 goto free_req; 320 goto free_req;
321 321
322 iv = buf; 322 iv = buf;
323 memcpy(iv, tls_ctx->crypto_send_aes_gcm_128.salt, 323 memcpy(iv, tls_ctx->crypto_send.aes_gcm_128.salt,
324 TLS_CIPHER_AES_GCM_128_SALT_SIZE); 324 TLS_CIPHER_AES_GCM_128_SALT_SIZE);
325 aad = buf + TLS_CIPHER_AES_GCM_128_SALT_SIZE + 325 aad = buf + TLS_CIPHER_AES_GCM_128_SALT_SIZE +
326 TLS_CIPHER_AES_GCM_128_IV_SIZE; 326 TLS_CIPHER_AES_GCM_128_IV_SIZE;
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 180b6640e531..523622dc74f8 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -241,6 +241,16 @@ static void tls_write_space(struct sock *sk)
241 ctx->sk_write_space(sk); 241 ctx->sk_write_space(sk);
242} 242}
243 243
244static void tls_ctx_free(struct tls_context *ctx)
245{
246 if (!ctx)
247 return;
248
249 memzero_explicit(&ctx->crypto_send, sizeof(ctx->crypto_send));
250 memzero_explicit(&ctx->crypto_recv, sizeof(ctx->crypto_recv));
251 kfree(ctx);
252}
253
244static void tls_sk_proto_close(struct sock *sk, long timeout) 254static void tls_sk_proto_close(struct sock *sk, long timeout)
245{ 255{
246 struct tls_context *ctx = tls_get_ctx(sk); 256 struct tls_context *ctx = tls_get_ctx(sk);
@@ -294,7 +304,7 @@ static void tls_sk_proto_close(struct sock *sk, long timeout)
294#else 304#else
295 { 305 {
296#endif 306#endif
297 kfree(ctx); 307 tls_ctx_free(ctx);
298 ctx = NULL; 308 ctx = NULL;
299 } 309 }
300 310
@@ -305,7 +315,7 @@ skip_tx_cleanup:
305 * for sk->sk_prot->unhash [tls_hw_unhash] 315 * for sk->sk_prot->unhash [tls_hw_unhash]
306 */ 316 */
307 if (free_ctx) 317 if (free_ctx)
308 kfree(ctx); 318 tls_ctx_free(ctx);
309} 319}
310 320
311static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval, 321static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
@@ -330,7 +340,7 @@ static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
330 } 340 }
331 341
332 /* get user crypto info */ 342 /* get user crypto info */
333 crypto_info = &ctx->crypto_send; 343 crypto_info = &ctx->crypto_send.info;
334 344
335 if (!TLS_CRYPTO_INFO_READY(crypto_info)) { 345 if (!TLS_CRYPTO_INFO_READY(crypto_info)) {
336 rc = -EBUSY; 346 rc = -EBUSY;
@@ -417,9 +427,9 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
417 } 427 }
418 428
419 if (tx) 429 if (tx)
420 crypto_info = &ctx->crypto_send; 430 crypto_info = &ctx->crypto_send.info;
421 else 431 else
422 crypto_info = &ctx->crypto_recv; 432 crypto_info = &ctx->crypto_recv.info;
423 433
424 /* Currently we don't support set crypto info more than one time */ 434 /* Currently we don't support set crypto info more than one time */
425 if (TLS_CRYPTO_INFO_READY(crypto_info)) { 435 if (TLS_CRYPTO_INFO_READY(crypto_info)) {
@@ -499,7 +509,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
499 goto out; 509 goto out;
500 510
501err_crypto_info: 511err_crypto_info:
502 memset(crypto_info, 0, sizeof(*crypto_info)); 512 memzero_explicit(crypto_info, sizeof(union tls_crypto_context));
503out: 513out:
504 return rc; 514 return rc;
505} 515}
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index e28a6ff25d96..9e918489f4fb 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1055,8 +1055,8 @@ static int tls_read_size(struct strparser *strp, struct sk_buff *skb)
1055 goto read_failure; 1055 goto read_failure;
1056 } 1056 }
1057 1057
1058 if (header[1] != TLS_VERSION_MINOR(tls_ctx->crypto_recv.version) || 1058 if (header[1] != TLS_VERSION_MINOR(tls_ctx->crypto_recv.info.version) ||
1059 header[2] != TLS_VERSION_MAJOR(tls_ctx->crypto_recv.version)) { 1059 header[2] != TLS_VERSION_MAJOR(tls_ctx->crypto_recv.info.version)) {
1060 ret = -EINVAL; 1060 ret = -EINVAL;
1061 goto read_failure; 1061 goto read_failure;
1062 } 1062 }
@@ -1136,7 +1136,6 @@ void tls_sw_free_resources_rx(struct sock *sk)
1136 1136
1137int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) 1137int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
1138{ 1138{
1139 char keyval[TLS_CIPHER_AES_GCM_128_KEY_SIZE];
1140 struct tls_crypto_info *crypto_info; 1139 struct tls_crypto_info *crypto_info;
1141 struct tls12_crypto_info_aes_gcm_128 *gcm_128_info; 1140 struct tls12_crypto_info_aes_gcm_128 *gcm_128_info;
1142 struct tls_sw_context_tx *sw_ctx_tx = NULL; 1141 struct tls_sw_context_tx *sw_ctx_tx = NULL;
@@ -1181,12 +1180,12 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
1181 1180
1182 if (tx) { 1181 if (tx) {
1183 crypto_init_wait(&sw_ctx_tx->async_wait); 1182 crypto_init_wait(&sw_ctx_tx->async_wait);
1184 crypto_info = &ctx->crypto_send; 1183 crypto_info = &ctx->crypto_send.info;
1185 cctx = &ctx->tx; 1184 cctx = &ctx->tx;
1186 aead = &sw_ctx_tx->aead_send; 1185 aead = &sw_ctx_tx->aead_send;
1187 } else { 1186 } else {
1188 crypto_init_wait(&sw_ctx_rx->async_wait); 1187 crypto_init_wait(&sw_ctx_rx->async_wait);
1189 crypto_info = &ctx->crypto_recv; 1188 crypto_info = &ctx->crypto_recv.info;
1190 cctx = &ctx->rx; 1189 cctx = &ctx->rx;
1191 aead = &sw_ctx_rx->aead_recv; 1190 aead = &sw_ctx_rx->aead_recv;
1192 } 1191 }
@@ -1265,9 +1264,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
1265 1264
1266 ctx->push_pending_record = tls_sw_push_pending_record; 1265 ctx->push_pending_record = tls_sw_push_pending_record;
1267 1266
1268 memcpy(keyval, gcm_128_info->key, TLS_CIPHER_AES_GCM_128_KEY_SIZE); 1267 rc = crypto_aead_setkey(*aead, gcm_128_info->key,
1269
1270 rc = crypto_aead_setkey(*aead, keyval,
1271 TLS_CIPHER_AES_GCM_128_KEY_SIZE); 1268 TLS_CIPHER_AES_GCM_128_KEY_SIZE);
1272 if (rc) 1269 if (rc)
1273 goto free_aead; 1270 goto free_aead;
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 5219280bf7ff..161b0224d6ae 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -380,6 +380,7 @@ our $Attribute = qr{
380 __noclone| 380 __noclone|
381 __deprecated| 381 __deprecated|
382 __read_mostly| 382 __read_mostly|
383 __ro_after_init|
383 __kprobes| 384 __kprobes|
384 $InitAttribute| 385 $InitAttribute|
385 ____cacheline_aligned| 386 ____cacheline_aligned|
@@ -3311,7 +3312,7 @@ sub process {
3311 # known declaration macros 3312 # known declaration macros
3312 $sline =~ /^\+\s+$declaration_macros/ || 3313 $sline =~ /^\+\s+$declaration_macros/ ||
3313 # start of struct or union or enum 3314 # start of struct or union or enum
3314 $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ || 3315 $sline =~ /^\+\s+(?:static\s+)?(?:const\s+)?(?:union|struct|enum|typedef)\b/ ||
3315 # start or end of block or continuation of declaration 3316 # start or end of block or continuation of declaration
3316 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ || 3317 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
3317 # bitfield continuation 3318 # bitfield continuation
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 999d585eaa73..e083bcae343f 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -11,13 +11,14 @@ DEPMOD=$1
11KERNELRELEASE=$2 11KERNELRELEASE=$2
12 12
13if ! test -r System.map ; then 13if ! test -r System.map ; then
14 echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
14 exit 0 15 exit 0
15fi 16fi
16 17
17if [ -z $(command -v $DEPMOD) ]; then 18if [ -z $(command -v $DEPMOD) ]; then
18 echo "'make modules_install' requires $DEPMOD. Please install it." >&2 19 echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2
19 echo "This is probably in the kmod package." >&2 20 echo "This is probably in the kmod package." >&2
20 exit 1 21 exit 0
21fi 22fi
22 23
23# older versions of depmod require the version string to start with three 24# older versions of depmod require the version string to start with three
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 4a7bd2192073..67ed9f6ccdf8 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -221,7 +221,6 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c
221 221
222# check if necessary packages are available, and configure build flags 222# check if necessary packages are available, and configure build flags
223define filechk_conf_cfg 223define filechk_conf_cfg
224 $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \
225 $(CONFIG_SHELL) $< 224 $(CONFIG_SHELL) $<
226endef 225endef
227 226
diff --git a/scripts/kconfig/check-pkgconfig.sh b/scripts/kconfig/check-pkgconfig.sh
deleted file mode 100644
index 7a1c40bfb58c..000000000000
--- a/scripts/kconfig/check-pkgconfig.sh
+++ /dev/null
@@ -1,8 +0,0 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# Check for pkg-config presence
4
5if [ -z $(command -v pkg-config) ]; then
6 echo "'make *config' requires 'pkg-config'. Please install it." 1>&2
7 exit 1
8fi
diff --git a/scripts/kconfig/gconf-cfg.sh b/scripts/kconfig/gconf-cfg.sh
index 533b3d8f8f08..480ecd8b9f41 100755
--- a/scripts/kconfig/gconf-cfg.sh
+++ b/scripts/kconfig/gconf-cfg.sh
@@ -3,6 +3,13 @@
3 3
4PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" 4PKG="gtk+-2.0 gmodule-2.0 libglade-2.0"
5 5
6if [ -z "$(command -v pkg-config)" ]; then
7 echo >&2 "*"
8 echo >&2 "* 'make gconfig' requires 'pkg-config'. Please install it."
9 echo >&2 "*"
10 exit 1
11fi
12
6if ! pkg-config --exists $PKG; then 13if ! pkg-config --exists $PKG; then
7 echo >&2 "*" 14 echo >&2 "*"
8 echo >&2 "* Unable to find the GTK+ installation. Please make sure that" 15 echo >&2 "* Unable to find the GTK+ installation. Please make sure that"
diff --git a/scripts/kconfig/mconf-cfg.sh b/scripts/kconfig/mconf-cfg.sh
index e6f9facd0077..c812872d7f9d 100755
--- a/scripts/kconfig/mconf-cfg.sh
+++ b/scripts/kconfig/mconf-cfg.sh
@@ -4,20 +4,23 @@
4PKG="ncursesw" 4PKG="ncursesw"
5PKG2="ncurses" 5PKG2="ncurses"
6 6
7if pkg-config --exists $PKG; then 7if [ -n "$(command -v pkg-config)" ]; then
8 echo cflags=\"$(pkg-config --cflags $PKG)\" 8 if pkg-config --exists $PKG; then
9 echo libs=\"$(pkg-config --libs $PKG)\" 9 echo cflags=\"$(pkg-config --cflags $PKG)\"
10 exit 0 10 echo libs=\"$(pkg-config --libs $PKG)\"
11fi 11 exit 0
12 fi
12 13
13if pkg-config --exists $PKG2; then 14 if pkg-config --exists $PKG2; then
14 echo cflags=\"$(pkg-config --cflags $PKG2)\" 15 echo cflags=\"$(pkg-config --cflags $PKG2)\"
15 echo libs=\"$(pkg-config --libs $PKG2)\" 16 echo libs=\"$(pkg-config --libs $PKG2)\"
16 exit 0 17 exit 0
18 fi
17fi 19fi
18 20
19# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses 21# Check the default paths in case pkg-config is not installed.
20# by pkg-config. 22# (Even if it is installed, some distributions such as openSUSE cannot
23# find ncurses by pkg-config.)
21if [ -f /usr/include/ncursesw/ncurses.h ]; then 24if [ -f /usr/include/ncursesw/ncurses.h ]; then
22 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" 25 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
23 echo libs=\"-lncursesw\" 26 echo libs=\"-lncursesw\"
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 83b5836615fb..143c05fec161 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -490,7 +490,6 @@ static void build_conf(struct menu *menu)
490 switch (prop->type) { 490 switch (prop->type) {
491 case P_MENU: 491 case P_MENU:
492 child_count++; 492 child_count++;
493 prompt = prompt;
494 if (single_menu_mode) { 493 if (single_menu_mode) {
495 item_make("%s%*c%s", 494 item_make("%s%*c%s",
496 menu->data ? "-->" : "++>", 495 menu->data ? "-->" : "++>",
diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
index 42f5ac73548e..001559ef0a60 100644
--- a/scripts/kconfig/nconf-cfg.sh
+++ b/scripts/kconfig/nconf-cfg.sh
@@ -4,20 +4,23 @@
4PKG="ncursesw menuw panelw" 4PKG="ncursesw menuw panelw"
5PKG2="ncurses menu panel" 5PKG2="ncurses menu panel"
6 6
7if pkg-config --exists $PKG; then 7if [ -n "$(command -v pkg-config)" ]; then
8 echo cflags=\"$(pkg-config --cflags $PKG)\" 8 if pkg-config --exists $PKG; then
9 echo libs=\"$(pkg-config --libs $PKG)\" 9 echo cflags=\"$(pkg-config --cflags $PKG)\"
10 exit 0 10 echo libs=\"$(pkg-config --libs $PKG)\"
11fi 11 exit 0
12 fi
12 13
13if pkg-config --exists $PKG2; then 14 if pkg-config --exists $PKG2; then
14 echo cflags=\"$(pkg-config --cflags $PKG2)\" 15 echo cflags=\"$(pkg-config --cflags $PKG2)\"
15 echo libs=\"$(pkg-config --libs $PKG2)\" 16 echo libs=\"$(pkg-config --libs $PKG2)\"
16 exit 0 17 exit 0
18 fi
17fi 19fi
18 20
19# Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses 21# Check the default paths in case pkg-config is not installed.
20# by pkg-config. 22# (Even if it is installed, some distributions such as openSUSE cannot
23# find ncurses by pkg-config.)
21if [ -f /usr/include/ncursesw/ncurses.h ]; then 24if [ -f /usr/include/ncursesw/ncurses.h ]; then
22 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" 25 echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
23 echo libs=\"-lncursesw -lmenuw -lpanelw\" 26 echo libs=\"-lncursesw -lmenuw -lpanelw\"
diff --git a/scripts/kconfig/qconf-cfg.sh b/scripts/kconfig/qconf-cfg.sh
index 0862e1562536..02ccc0ae1031 100755
--- a/scripts/kconfig/qconf-cfg.sh
+++ b/scripts/kconfig/qconf-cfg.sh
@@ -4,6 +4,13 @@
4PKG="Qt5Core Qt5Gui Qt5Widgets" 4PKG="Qt5Core Qt5Gui Qt5Widgets"
5PKG2="QtCore QtGui" 5PKG2="QtCore QtGui"
6 6
7if [ -z "$(command -v pkg-config)" ]; then
8 echo >&2 "*"
9 echo >&2 "* 'make xconfig' requires 'pkg-config'. Please install it."
10 echo >&2 "*"
11 exit 1
12fi
13
7if pkg-config --exists $PKG; then 14if pkg-config --exists $PKG; then
8 echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\" 15 echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\"
9 echo libs=\"$(pkg-config --libs $PKG)\" 16 echo libs=\"$(pkg-config --libs $PKG)\"
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index fe06e77c15eb..f599031260d5 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -389,6 +389,9 @@ if ($arch eq "x86_64") {
389 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$"; 389 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$";
390 $type = ".quad"; 390 $type = ".quad";
391 $alignment = 2; 391 $alignment = 2;
392} elsif ($arch eq "nds32") {
393 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_NDS32_HI20_RELA\\s+_mcount\$";
394 $alignment = 2;
392} else { 395} else {
393 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; 396 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
394} 397}
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 71f39410691b..79f7dd57d571 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -74,7 +74,7 @@ scm_version()
74 fi 74 fi
75 75
76 # Check for uncommitted changes 76 # Check for uncommitted changes
77 if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then 77 if git status -uno --porcelain | grep -qv '^.. scripts/package'; then
78 printf '%s' -dirty 78 printf '%s' -dirty
79 fi 79 fi
80 80
diff --git a/security/apparmor/secid.c b/security/apparmor/secid.c
index f2f22d00db18..4ccec1bcf6f5 100644
--- a/security/apparmor/secid.c
+++ b/security/apparmor/secid.c
@@ -79,7 +79,6 @@ int apparmor_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
79 struct aa_label *label = aa_secid_to_label(secid); 79 struct aa_label *label = aa_secid_to_label(secid);
80 int len; 80 int len;
81 81
82 AA_BUG(!secdata);
83 AA_BUG(!seclen); 82 AA_BUG(!seclen);
84 83
85 if (!label) 84 if (!label)
diff --git a/security/keys/dh.c b/security/keys/dh.c
index 711e89d8c415..3b602a1e27fa 100644
--- a/security/keys/dh.c
+++ b/security/keys/dh.c
@@ -300,7 +300,7 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params,
300 } 300 }
301 dh_inputs.g_size = dlen; 301 dh_inputs.g_size = dlen;
302 302
303 dlen = dh_data_from_key(pcopy.private, &dh_inputs.key); 303 dlen = dh_data_from_key(pcopy.dh_private, &dh_inputs.key);
304 if (dlen < 0) { 304 if (dlen < 0) {
305 ret = dlen; 305 ret = dlen;
306 goto out2; 306 goto out2;
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 69517e18ef07..08d5662039e3 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -129,7 +129,7 @@ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
129 runtime->avail = 0; 129 runtime->avail = 0;
130 else 130 else
131 runtime->avail = runtime->buffer_size; 131 runtime->avail = runtime->buffer_size;
132 runtime->buffer = kvmalloc(runtime->buffer_size, GFP_KERNEL); 132 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL);
133 if (!runtime->buffer) { 133 if (!runtime->buffer) {
134 kfree(runtime); 134 kfree(runtime);
135 return -ENOMEM; 135 return -ENOMEM;
@@ -655,7 +655,7 @@ static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime,
655 if (params->avail_min < 1 || params->avail_min > params->buffer_size) 655 if (params->avail_min < 1 || params->avail_min > params->buffer_size)
656 return -EINVAL; 656 return -EINVAL;
657 if (params->buffer_size != runtime->buffer_size) { 657 if (params->buffer_size != runtime->buffer_size) {
658 newbuf = kvmalloc(params->buffer_size, GFP_KERNEL); 658 newbuf = kvzalloc(params->buffer_size, GFP_KERNEL);
659 if (!newbuf) 659 if (!newbuf)
660 return -ENOMEM; 660 return -ENOMEM;
661 spin_lock_irq(&runtime->lock); 661 spin_lock_irq(&runtime->lock);
diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c
index 1bd27576db98..a835558ddbc9 100644
--- a/sound/hda/ext/hdac_ext_stream.c
+++ b/sound/hda/ext/hdac_ext_stream.c
@@ -146,7 +146,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple);
146 */ 146 */
147void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *stream) 147void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *stream)
148{ 148{
149 snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL, 0, AZX_PPLCCTL_RUN); 149 snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL,
150 AZX_PPLCCTL_RUN, AZX_PPLCCTL_RUN);
150} 151}
151EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_start); 152EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_start);
152 153
@@ -171,7 +172,8 @@ void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *stream)
171 172
172 snd_hdac_ext_link_stream_clear(stream); 173 snd_hdac_ext_link_stream_clear(stream);
173 174
174 snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL, 0, AZX_PPLCCTL_STRST); 175 snd_hdac_updatel(stream->pplc_addr, AZX_REG_PPLCCTL,
176 AZX_PPLCCTL_STRST, AZX_PPLCCTL_STRST);
175 udelay(3); 177 udelay(3);
176 timeout = 50; 178 timeout = 50;
177 do { 179 do {
@@ -242,7 +244,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_link_set_stream_id);
242void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, 244void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
243 int stream) 245 int stream)
244{ 246{
245 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, 0, (1 << stream)); 247 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 0);
246} 248}
247EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id); 249EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id);
248 250
@@ -415,7 +417,6 @@ void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *bus,
415 bool enable, int index) 417 bool enable, int index)
416{ 418{
417 u32 mask = 0; 419 u32 mask = 0;
418 u32 register_mask = 0;
419 420
420 if (!bus->spbcap) { 421 if (!bus->spbcap) {
421 dev_err(bus->dev, "Address of SPB capability is NULL\n"); 422 dev_err(bus->dev, "Address of SPB capability is NULL\n");
@@ -424,12 +425,8 @@ void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *bus,
424 425
425 mask |= (1 << index); 426 mask |= (1 << index);
426 427
427 register_mask = readl(bus->spbcap + AZX_REG_SPB_SPBFCCTL);
428
429 mask |= register_mask;
430
431 if (enable) 428 if (enable)
432 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, 0, mask); 429 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, mask);
433 else 430 else
434 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, 0); 431 snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, 0);
435} 432}
@@ -503,7 +500,6 @@ void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus,
503 bool enable, int index) 500 bool enable, int index)
504{ 501{
505 u32 mask = 0; 502 u32 mask = 0;
506 u32 register_mask = 0;
507 503
508 if (!bus->drsmcap) { 504 if (!bus->drsmcap) {
509 dev_err(bus->dev, "Address of DRSM capability is NULL\n"); 505 dev_err(bus->dev, "Address of DRSM capability is NULL\n");
@@ -512,12 +508,8 @@ void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus,
512 508
513 mask |= (1 << index); 509 mask |= (1 << index);
514 510
515 register_mask = readl(bus->drsmcap + AZX_REG_SPB_SPBFCCTL);
516
517 mask |= register_mask;
518
519 if (enable) 511 if (enable)
520 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, 0, mask); 512 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, mask);
521 else 513 else
522 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, 0); 514 snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, 0);
523} 515}
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 0a5085537034..26d348b47867 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -3935,7 +3935,8 @@ void snd_hda_bus_reset_codecs(struct hda_bus *bus)
3935 3935
3936 list_for_each_codec(codec, bus) { 3936 list_for_each_codec(codec, bus) {
3937 /* FIXME: maybe a better way needed for forced reset */ 3937 /* FIXME: maybe a better way needed for forced reset */
3938 cancel_delayed_work_sync(&codec->jackpoll_work); 3938 if (current_work() != &codec->jackpoll_work.work)
3939 cancel_delayed_work_sync(&codec->jackpoll_work);
3939#ifdef CONFIG_PM 3940#ifdef CONFIG_PM
3940 if (hda_codec_is_power_on(codec)) { 3941 if (hda_codec_is_power_on(codec)) {
3941 hda_call_codec_suspend(codec); 3942 hda_call_codec_suspend(codec);
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 56c4b3f8a01b..439b8a27488d 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -759,12 +759,18 @@ class DebugfsProvider(Provider):
759 if len(vms) == 0: 759 if len(vms) == 0:
760 self.do_read = False 760 self.do_read = False
761 761
762 self.paths = filter(lambda x: "{}-".format(pid) in x, vms) 762 self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms))
763 763
764 else: 764 else:
765 self.paths = [] 765 self.paths = []
766 self.do_read = True 766 self.do_read = True
767 self.reset() 767
768 def _verify_paths(self):
769 """Remove invalid paths"""
770 for path in self.paths:
771 if not os.path.exists(os.path.join(PATH_DEBUGFS_KVM, path)):
772 self.paths.remove(path)
773 continue
768 774
769 def read(self, reset=0, by_guest=0): 775 def read(self, reset=0, by_guest=0):
770 """Returns a dict with format:'file name / field -> current value'. 776 """Returns a dict with format:'file name / field -> current value'.
@@ -780,6 +786,7 @@ class DebugfsProvider(Provider):
780 # If no debugfs filtering support is available, then don't read. 786 # If no debugfs filtering support is available, then don't read.
781 if not self.do_read: 787 if not self.do_read:
782 return results 788 return results
789 self._verify_paths()
783 790
784 paths = self.paths 791 paths = self.paths
785 if self._pid == 0: 792 if self._pid == 0:
@@ -1096,15 +1103,16 @@ class Tui(object):
1096 pid = self.stats.pid_filter 1103 pid = self.stats.pid_filter
1097 self.screen.erase() 1104 self.screen.erase()
1098 gname = self.get_gname_from_pid(pid) 1105 gname = self.get_gname_from_pid(pid)
1106 self._gname = gname
1099 if gname: 1107 if gname:
1100 gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...' 1108 gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...'
1101 if len(gname) > MAX_GUEST_NAME_LEN 1109 if len(gname) > MAX_GUEST_NAME_LEN
1102 else gname)) 1110 else gname))
1103 if pid > 0: 1111 if pid > 0:
1104 self.screen.addstr(0, 0, 'kvm statistics - pid {0} {1}' 1112 self._headline = 'kvm statistics - pid {0} {1}'.format(pid, gname)
1105 .format(pid, gname), curses.A_BOLD)
1106 else: 1113 else:
1107 self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD) 1114 self._headline = 'kvm statistics - summary'
1115 self.screen.addstr(0, 0, self._headline, curses.A_BOLD)
1108 if self.stats.fields_filter: 1116 if self.stats.fields_filter:
1109 regex = self.stats.fields_filter 1117 regex = self.stats.fields_filter
1110 if len(regex) > MAX_REGEX_LEN: 1118 if len(regex) > MAX_REGEX_LEN:
@@ -1162,6 +1170,19 @@ class Tui(object):
1162 1170
1163 return sorted_items 1171 return sorted_items
1164 1172
1173 if not self._is_running_guest(self.stats.pid_filter):
1174 if self._gname:
1175 try: # ...to identify the guest by name in case it's back
1176 pids = self.get_pid_from_gname(self._gname)
1177 if len(pids) == 1:
1178 self._refresh_header(pids[0])
1179 self._update_pid(pids[0])
1180 return
1181 except:
1182 pass
1183 self._display_guest_dead()
1184 # leave final data on screen
1185 return
1165 row = 3 1186 row = 3
1166 self.screen.move(row, 0) 1187 self.screen.move(row, 0)
1167 self.screen.clrtobot() 1188 self.screen.clrtobot()
@@ -1184,6 +1205,7 @@ class Tui(object):
1184 # print events 1205 # print events
1185 tavg = 0 1206 tavg = 0
1186 tcur = 0 1207 tcur = 0
1208 guest_removed = False
1187 for key, values in get_sorted_events(self, stats): 1209 for key, values in get_sorted_events(self, stats):
1188 if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0): 1210 if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0):
1189 break 1211 break
@@ -1191,7 +1213,10 @@ class Tui(object):
1191 key = self.get_gname_from_pid(key) 1213 key = self.get_gname_from_pid(key)
1192 if not key: 1214 if not key:
1193 continue 1215 continue
1194 cur = int(round(values.delta / sleeptime)) if values.delta else '' 1216 cur = int(round(values.delta / sleeptime)) if values.delta else 0
1217 if cur < 0:
1218 guest_removed = True
1219 continue
1195 if key[0] != ' ': 1220 if key[0] != ' ':
1196 if values.delta: 1221 if values.delta:
1197 tcur += values.delta 1222 tcur += values.delta
@@ -1204,13 +1229,21 @@ class Tui(object):
1204 values.value * 100 / float(ltotal), cur)) 1229 values.value * 100 / float(ltotal), cur))
1205 row += 1 1230 row += 1
1206 if row == 3: 1231 if row == 3:
1207 self.screen.addstr(4, 1, 'No matching events reported yet') 1232 if guest_removed:
1233 self.screen.addstr(4, 1, 'Guest removed, updating...')
1234 else:
1235 self.screen.addstr(4, 1, 'No matching events reported yet')
1208 if row > 4: 1236 if row > 4:
1209 tavg = int(round(tcur / sleeptime)) if tcur > 0 else '' 1237 tavg = int(round(tcur / sleeptime)) if tcur > 0 else ''
1210 self.screen.addstr(row, 1, '%-40s %10d %8s' % 1238 self.screen.addstr(row, 1, '%-40s %10d %8s' %
1211 ('Total', total, tavg), curses.A_BOLD) 1239 ('Total', total, tavg), curses.A_BOLD)
1212 self.screen.refresh() 1240 self.screen.refresh()
1213 1241
1242 def _display_guest_dead(self):
1243 marker = ' Guest is DEAD '
1244 y = min(len(self._headline), 80 - len(marker))
1245 self.screen.addstr(0, y, marker, curses.A_BLINK | curses.A_STANDOUT)
1246
1214 def _show_msg(self, text): 1247 def _show_msg(self, text):
1215 """Display message centered text and exit on key press""" 1248 """Display message centered text and exit on key press"""
1216 hint = 'Press any key to continue' 1249 hint = 'Press any key to continue'
@@ -1219,10 +1252,10 @@ class Tui(object):
1219 (x, term_width) = self.screen.getmaxyx() 1252 (x, term_width) = self.screen.getmaxyx()
1220 row = 2 1253 row = 2
1221 for line in text: 1254 for line in text:
1222 start = (term_width - len(line)) / 2 1255 start = (term_width - len(line)) // 2
1223 self.screen.addstr(row, start, line) 1256 self.screen.addstr(row, start, line)
1224 row += 1 1257 row += 1
1225 self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint, 1258 self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint,
1226 curses.A_STANDOUT) 1259 curses.A_STANDOUT)
1227 self.screen.getkey() 1260 self.screen.getkey()
1228 1261
@@ -1319,6 +1352,12 @@ class Tui(object):
1319 msg = '"' + str(val) + '": Invalid value' 1352 msg = '"' + str(val) + '": Invalid value'
1320 self._refresh_header() 1353 self._refresh_header()
1321 1354
1355 def _is_running_guest(self, pid):
1356 """Check if pid is still a running process."""
1357 if not pid:
1358 return True
1359 return os.path.isdir(os.path.join('/proc/', str(pid)))
1360
1322 def _show_vm_selection_by_guest(self): 1361 def _show_vm_selection_by_guest(self):
1323 """Draws guest selection mask. 1362 """Draws guest selection mask.
1324 1363
@@ -1346,7 +1385,7 @@ class Tui(object):
1346 if not guest or guest == '0': 1385 if not guest or guest == '0':
1347 break 1386 break
1348 if guest.isdigit(): 1387 if guest.isdigit():
1349 if not os.path.isdir(os.path.join('/proc/', guest)): 1388 if not self._is_running_guest(guest):
1350 msg = '"' + guest + '": Not a running process' 1389 msg = '"' + guest + '": Not a running process'
1351 continue 1390 continue
1352 pid = int(guest) 1391 pid = int(guest)
diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
index 30cb0a0713ff..37908a83ddc2 100644
--- a/tools/vm/page-types.c
+++ b/tools/vm/page-types.c
@@ -159,12 +159,6 @@ static const char * const page_flag_names[] = {
159}; 159};
160 160
161 161
162static const char * const debugfs_known_mountpoints[] = {
163 "/sys/kernel/debug",
164 "/debug",
165 0,
166};
167
168/* 162/*
169 * data structures 163 * data structures
170 */ 164 */
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
index f82c2eaa859d..334b16db0ebb 100644
--- a/tools/vm/slabinfo.c
+++ b/tools/vm/slabinfo.c
@@ -30,8 +30,8 @@ struct slabinfo {
30 int alias; 30 int alias;
31 int refs; 31 int refs;
32 int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu; 32 int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu;
33 int hwcache_align, object_size, objs_per_slab; 33 unsigned int hwcache_align, object_size, objs_per_slab;
34 int sanity_checks, slab_size, store_user, trace; 34 unsigned int sanity_checks, slab_size, store_user, trace;
35 int order, poison, reclaim_account, red_zone; 35 int order, poison, reclaim_account, red_zone;
36 unsigned long partial, objects, slabs, objects_partial, objects_total; 36 unsigned long partial, objects, slabs, objects_partial, objects_total;
37 unsigned long alloc_fastpath, alloc_slowpath; 37 unsigned long alloc_fastpath, alloc_slowpath;
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index 91aaf73b00df..ed162a6c57c5 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -1817,18 +1817,6 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *dat
1817 return 0; 1817 return 0;
1818} 1818}
1819 1819
1820int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
1821{
1822 unsigned long end = hva + PAGE_SIZE;
1823
1824 if (!kvm->arch.pgd)
1825 return 0;
1826
1827 trace_kvm_unmap_hva(hva);
1828 handle_hva_to_gpa(kvm, hva, end, &kvm_unmap_hva_handler, NULL);
1829 return 0;
1830}
1831
1832int kvm_unmap_hva_range(struct kvm *kvm, 1820int kvm_unmap_hva_range(struct kvm *kvm,
1833 unsigned long start, unsigned long end) 1821 unsigned long start, unsigned long end)
1834{ 1822{
@@ -1860,13 +1848,20 @@ static int kvm_set_spte_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data
1860void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte) 1848void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
1861{ 1849{
1862 unsigned long end = hva + PAGE_SIZE; 1850 unsigned long end = hva + PAGE_SIZE;
1851 kvm_pfn_t pfn = pte_pfn(pte);
1863 pte_t stage2_pte; 1852 pte_t stage2_pte;
1864 1853
1865 if (!kvm->arch.pgd) 1854 if (!kvm->arch.pgd)
1866 return; 1855 return;
1867 1856
1868 trace_kvm_set_spte_hva(hva); 1857 trace_kvm_set_spte_hva(hva);
1869 stage2_pte = pfn_pte(pte_pfn(pte), PAGE_S2); 1858
1859 /*
1860 * We've moved a page around, probably through CoW, so let's treat it
1861 * just like a translation fault and clean the cache to the PoC.
1862 */
1863 clean_dcache_guest_page(pfn, PAGE_SIZE);
1864 stage2_pte = pfn_pte(pfn, PAGE_S2);
1870 handle_hva_to_gpa(kvm, hva, end, &kvm_set_spte_handler, &stage2_pte); 1865 handle_hva_to_gpa(kvm, hva, end, &kvm_set_spte_handler, &stage2_pte);
1871} 1866}
1872 1867
diff --git a/virt/kvm/arm/trace.h b/virt/kvm/arm/trace.h
index e53b596f483b..57b3edebbb40 100644
--- a/virt/kvm/arm/trace.h
+++ b/virt/kvm/arm/trace.h
@@ -134,21 +134,6 @@ TRACE_EVENT(kvm_mmio_emulate,
134 __entry->vcpu_pc, __entry->instr, __entry->cpsr) 134 __entry->vcpu_pc, __entry->instr, __entry->cpsr)
135); 135);
136 136
137TRACE_EVENT(kvm_unmap_hva,
138 TP_PROTO(unsigned long hva),
139 TP_ARGS(hva),
140
141 TP_STRUCT__entry(
142 __field( unsigned long, hva )
143 ),
144
145 TP_fast_assign(
146 __entry->hva = hva;
147 ),
148
149 TP_printk("mmu notifier unmap hva: %#08lx", __entry->hva)
150);
151
152TRACE_EVENT(kvm_unmap_hva_range, 137TRACE_EVENT(kvm_unmap_hva_range,
153 TP_PROTO(unsigned long start, unsigned long end), 138 TP_PROTO(unsigned long start, unsigned long end),
154 TP_ARGS(start, end), 139 TP_ARGS(start, end),