Merge tag 'staging-5.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 23 May 2020 17:57:55 +0000 (10:57 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 23 May 2020 17:57:55 +0000 (10:57 -0700)
Pull staging/iio fixes from Greg KH:
 "Here are some small staging and IIO driver fixes for 5.7-rc7

  Nothing major, just a collection of IIO driver fixes for reported
  issues, and a few small staging driver fixes that people have found.
  Full details are in the shortlog.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-5.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: wfx: unlock on error path
  staging: greybus: Fix uninitialized scalar variable
  staging: kpc2000: fix error return code in kp2000_pcie_probe()
  iio: sca3000: Remove an erroneous 'get_device()'
  iio: adc: stm32-dfsdm: fix device used to request dma
  iio: adc: stm32-adc: fix device used to request dma
  iio: adc: ti-ads8344: Fix channel selection
  staging: iio: ad2s1210: Fix SPI reading
  iio: dac: vf610: Fix an error handling path in 'vf610_dac_probe()'
  iio: imu: st_lsm6dsx: unlock on error in st_lsm6dsx_shub_write_raw()
  iio: chemical: atlas-sensor: correct DO-SM channels

462 files changed:
.mailmap
Documentation/core-api/printk-formats.rst
Documentation/devicetree/bindings/dma/fsl-edma.txt
Documentation/usb/raw-gadget.rst
MAINTAINERS
Makefile
arch/arc/configs/hsdk_defconfig
arch/arc/include/asm/dsp-impl.h
arch/arc/include/asm/entry-arcv2.h
arch/arc/kernel/Makefile
arch/arc/kernel/ptrace.c
arch/arc/kernel/setup.c
arch/arc/kernel/troubleshoot.c
arch/arc/kernel/unwind.c
arch/arc/plat-eznps/Kconfig
arch/arm/Kconfig
arch/arm/boot/dts/am574x-idk.dts
arch/arm/boot/dts/dra7.dtsi
arch/arm/boot/dts/imx27-phytec-phycard-s-rdk.dts
arch/arm/boot/dts/imx6dl-yapp4-ursa.dts
arch/arm/boot/dts/iwg20d-q7-dbcm-ca.dtsi
arch/arm/boot/dts/motorola-mapphone-common.dtsi
arch/arm/boot/dts/r7s9210.dtsi
arch/arm/boot/dts/r8a73a4.dtsi
arch/arm/boot/dts/r8a7740.dtsi
arch/arm/boot/dts/r8a7745-iwg22d-sodimm-dbhd-ca.dts
arch/arm/boot/dts/r8a7790-lager.dts
arch/arm/boot/dts/r8a7790-stout.dts
arch/arm/boot/dts/r8a7791-koelsch.dts
arch/arm/boot/dts/r8a7791-porter.dts
arch/arm/boot/dts/r8a7792-blanche.dts
arch/arm/boot/dts/r8a7792-wheat.dts
arch/arm/boot/dts/r8a7793-gose.dts
arch/arm/boot/dts/r8a7794-silk.dts
arch/arm/boot/dts/rk3036.dtsi
arch/arm/boot/dts/rk3228-evb.dts
arch/arm/boot/dts/rk3229-xms6.dts
arch/arm/boot/dts/rk322x.dtsi
arch/arm/boot/dts/rk3xxx.dtsi
arch/arm/configs/keystone_defconfig
arch/arm/configs/omap2plus_defconfig
arch/arm/mach-oxnas/platsmp.c
arch/arm64/Kconfig
arch/arm64/boot/dts/allwinner/sun50i-a64-pinetab.dts
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
arch/arm64/boot/dts/amlogic/meson-g12.dtsi
arch/arm64/boot/dts/amlogic/meson-g12b-khadas-vim3.dtsi
arch/arm64/boot/dts/amlogic/meson-g12b-ugoos-am6.dts
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
arch/arm64/boot/dts/freescale/imx8mm.dtsi
arch/arm64/boot/dts/freescale/imx8mn.dtsi
arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h
arch/arm64/boot/dts/freescale/imx8mp.dtsi
arch/arm64/boot/dts/freescale/imx8mq.dtsi
arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
arch/arm64/boot/dts/qcom/msm8996.dtsi
arch/arm64/boot/dts/qcom/sdm845-db845c.dts
arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
arch/arm64/boot/dts/renesas/r8a77970-eagle.dts
arch/arm64/boot/dts/renesas/r8a77970-v3msk.dts
arch/arm64/boot/dts/renesas/r8a77980-condor.dts
arch/arm64/boot/dts/renesas/r8a77980-v3hsk.dts
arch/arm64/boot/dts/renesas/r8a77980.dtsi
arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts
arch/arm64/boot/dts/renesas/r8a77995-draak.dts
arch/arm64/boot/dts/rockchip/px30.dtsi
arch/arm64/boot/dts/rockchip/rk3308.dtsi
arch/arm64/boot/dts/rockchip/rk3328-evb.dts
arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
arch/arm64/boot/dts/rockchip/rk3328.dtsi
arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts
arch/arm64/boot/dts/rockchip/rk3399.dtsi
arch/arm64/configs/defconfig
arch/arm64/include/asm/uaccess.h
arch/arm64/kernel/machine_kexec.c
arch/arm64/kernel/ptrace.c
arch/csky/Kconfig
arch/csky/Makefile
arch/csky/abiv1/inc/abi/entry.h
arch/csky/abiv2/inc/abi/entry.h
arch/csky/abiv2/mcount.S
arch/csky/include/asm/processor.h
arch/csky/include/asm/ptrace.h
arch/csky/include/asm/thread_info.h
arch/csky/include/asm/uaccess.h
arch/csky/kernel/Makefile
arch/csky/kernel/asm-offsets.c
arch/csky/kernel/dumpstack.c [deleted file]
arch/csky/kernel/entry.S
arch/csky/kernel/ftrace.c
arch/csky/kernel/perf_callchain.c
arch/csky/kernel/probes/uprobes.c
arch/csky/kernel/process.c
arch/csky/kernel/ptrace.c
arch/csky/kernel/stacktrace.c
arch/csky/lib/usercopy.c
arch/powerpc/Kconfig
arch/powerpc/include/asm/book3s/32/hash.h
arch/powerpc/include/asm/book3s/32/kup.h
arch/powerpc/include/asm/hw_irq.h
arch/powerpc/include/asm/uaccess.h
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/exceptions-64s.S
arch/powerpc/kernel/head_32.S
arch/powerpc/kernel/head_40x.S
arch/powerpc/kernel/ima_arch.c
arch/powerpc/kernel/syscall_64.c
arch/powerpc/kernel/vdso32/gettimeofday.S
arch/powerpc/mm/book3s32/hash_low.S
arch/riscv/Kconfig
arch/riscv/Kconfig.socs
arch/riscv/include/asm/mmio.h
arch/riscv/include/asm/mmiowb.h
arch/riscv/include/asm/perf_event.h
arch/riscv/include/asm/pgtable.h
arch/riscv/kernel/Makefile
arch/riscv/kernel/perf_event.c
arch/riscv/kernel/process.c
arch/riscv/kernel/stacktrace.c
arch/riscv/mm/init.c
arch/s390/include/asm/pci_io.h
arch/s390/kernel/machine_kexec_file.c
arch/s390/kernel/machine_kexec_reloc.c
arch/s390/mm/hugetlbpage.c
arch/s390/pci/pci_mmio.c
arch/um/drivers/vector_user.h
arch/um/include/asm/xor.h
arch/um/kernel/skas/syscall.c
arch/x86/Kconfig
arch/x86/hyperv/hv_init.c
arch/x86/include/asm/ftrace.h
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/stackprotector.h
arch/x86/kernel/ftrace.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/unwind_orc.c
arch/x86/kvm/hyperv.c
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c
arch/x86/mm/init_64.c
arch/x86/xen/smp_pv.c
drivers/acpi/ec.c
drivers/acpi/internal.h
drivers/acpi/sleep.c
drivers/block/null_blk_main.c
drivers/block/null_blk_zoned.c
drivers/char/ipmi/ipmi_ssif.c
drivers/clk/clk.c
drivers/clk/rockchip/clk-rk3228.c
drivers/clk/tegra/clk-tegra124.c
drivers/clk/ti/clk-33xx.c
drivers/clk/ti/clkctrl.c
drivers/clk/versatile/clk-impd1.c
drivers/dma/dmatest.c
drivers/dma/idxd/device.c
drivers/dma/idxd/irq.c
drivers/dma/owl-dma.c
drivers/dma/tegra210-adma.c
drivers/dma/ti/k3-udma.c
drivers/dma/xilinx/zynqmp_dma.c
drivers/gpio/gpio-pca953x.c
drivers/gpio/gpio-tegra.c
drivers/gpio/gpiolib.c
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_init.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_init.c
drivers/gpu/drm/amd/display/dc/dml/Makefile
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.h
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.h
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.h
drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.h
drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h
drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_helpers.h
drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.h
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c [deleted file]
drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h [deleted file]
drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
drivers/gpu/drm/amd/powerplay/amd_powerplay.c
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
drivers/gpu/drm/i915/display/intel_fbc.c
drivers/gpu/drm/i915/gem/i915_gem_domain.c
drivers/gpu/drm/i915/gt/intel_context_types.h
drivers/gpu/drm/i915/gt/intel_engine.h
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/gt/intel_engine_types.h
drivers/gpu/drm/i915/gt/intel_gt_irq.c
drivers/gpu/drm/i915/gt/intel_lrc.c
drivers/gpu/drm/i915/gt/selftest_lrc.c
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
drivers/gpu/drm/i915/gvt/display.c
drivers/gpu/drm/i915/gvt/scheduler.c
drivers/gpu/drm/i915/i915_gem_evict.c
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/i915_request.c
drivers/gpu/drm/i915/i915_scheduler.c
drivers/gpu/drm/i915/i915_scheduler.h
drivers/gpu/drm/i915/i915_scheduler_types.h
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/i915/selftests/i915_vma.c
drivers/gpu/drm/meson/meson_drv.c
drivers/gpu/drm/tegra/drm.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
drivers/gpu/host1x/dev.c
drivers/hwmon/da9052-hwmon.c
drivers/hwmon/drivetemp.c
drivers/hwmon/nct7904.c
drivers/i2c/algos/i2c-algo-pca.c
drivers/i2c/busses/i2c-altera.c
drivers/i2c/busses/i2c-at91-master.c
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-core-of.c
drivers/i2c/muxes/i2c-demux-pinctrl.c
drivers/infiniband/core/cache.c
drivers/infiniband/core/nldev.c
drivers/infiniband/core/rdma_core.c
drivers/infiniband/core/uverbs.h
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/core/uverbs_std_types_async_fd.c
drivers/infiniband/hw/cxgb4/cm.c
drivers/infiniband/hw/hfi1/user_sdma.c
drivers/infiniband/hw/i40iw/i40iw_cm.c
drivers/infiniband/hw/i40iw/i40iw_hw.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/sw/rxe/rxe_mmap.c
drivers/infiniband/sw/rxe/rxe_queue.c
drivers/iommu/amd_iommu.c
drivers/iommu/amd_iommu_init.c
drivers/iommu/iommu.c
drivers/mmc/core/block.c
drivers/mmc/core/queue.c
drivers/mmc/host/alcor.c
drivers/mmc/host/sdhci-acpi.c
drivers/mmc/host/sdhci-pci-gli.c
drivers/mtd/mtdcore.c
drivers/mtd/nand/raw/brcmnand/brcmnand.c
drivers/mtd/nand/spi/core.c
drivers/mtd/ubi/debug.c
drivers/net/bareudp.c
drivers/net/dsa/dsa_loop.c
drivers/net/ethernet/broadcom/Kconfig
drivers/net/ethernet/freescale/Kconfig
drivers/net/ethernet/freescale/dpaa/Kconfig
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
drivers/net/ethernet/hisilicon/Kconfig
drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
drivers/net/ethernet/huawei/hinic/hinic_main.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
drivers/net/ethernet/microchip/encx24j600.c
drivers/net/ethernet/netronome/nfp/abm/main.c
drivers/net/ethernet/pensando/ionic/ionic_lif.c
drivers/net/ethernet/pensando/ionic/ionic_main.c
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
drivers/net/ethernet/ti/Kconfig
drivers/net/ethernet/ti/Makefile
drivers/net/hamradio/bpqether.c
drivers/net/ipa/gsi_trans.c
drivers/net/ipa/ipa_cmd.c
drivers/net/ipa/ipa_smp2p.c
drivers/net/phy/broadcom.c
drivers/net/phy/phy.c
drivers/net/ppp/pppoe.c
drivers/net/usb/hso.c
drivers/net/virtio_net.c
drivers/nvme/host/pci.c
drivers/pinctrl/actions/pinctrl-s700.c
drivers/pinctrl/intel/pinctrl-baytrail.c
drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/intel/pinctrl-sunrisepoint.c
drivers/pinctrl/mediatek/pinctrl-paris.c
drivers/pinctrl/qcom/pinctrl-msm.c
drivers/s390/net/ism_drv.c
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/scsi_pm.c
drivers/target/target_core_transport.c
drivers/tty/serial/sifive.c
drivers/usb/cdns3/gadget.c
drivers/usb/core/devio.c
drivers/usb/core/hub.c
drivers/usb/dwc3/Kconfig
drivers/usb/dwc3/dwc3-pci.c
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/configfs.c
drivers/usb/gadget/legacy/audio.c
drivers/usb/gadget/legacy/cdc2.c
drivers/usb/gadget/legacy/inode.c
drivers/usb/gadget/legacy/ncm.c
drivers/usb/gadget/legacy/raw_gadget.c
drivers/usb/gadget/udc/atmel_usba_udc.c
drivers/usb/gadget/udc/net2272.c
drivers/usb/gadget/udc/tegra-xudc.c
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci-ring.c
drivers/usb/mtu3/mtu3_debugfs.c
drivers/usb/phy/phy-twl6030-usb.c
drivers/usb/typec/mux/intel_pmc_mux.c
drivers/vdpa/vdpa_sim/vdpa_sim.c
drivers/vhost/vhost.c
fs/afs/fsclient.c
fs/afs/yfsclient.c
fs/cachefiles/rdwr.c
fs/cifs/cifssmb.c
fs/cifs/file.c
fs/cifs/inode.c
fs/eventpoll.c
fs/exec.c
fs/exfat/file.c
fs/exfat/namei.c
fs/exfat/super.c
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/ioctl.c
fs/file.c
fs/gfs2/bmap.c
fs/gfs2/glock.c
fs/gfs2/inode.c
fs/gfs2/log.c
fs/gfs2/lops.c
fs/gfs2/meta_io.c
fs/gfs2/quota.c
fs/gfs2/quota.h
fs/gfs2/super.c
fs/gfs2/util.c
fs/io_uring.c
fs/nfs/fscache.c
fs/nfs/mount_clnt.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4state.c
fs/nfs/pagelist.c
fs/nfs/pnfs_nfs.c
fs/nfs/super.c
fs/nfs/write.c
fs/overlayfs/export.c
fs/overlayfs/inode.c
fs/splice.c
fs/ubifs/auth.c
fs/ubifs/file.c
fs/ubifs/replay.c
include/drm/drm_modes.h
include/linux/brcmphy.h
include/linux/compiler.h
include/linux/ftrace.h
include/linux/host1x.h
include/linux/i2c-mux.h
include/linux/i2c.h
include/linux/kvm_host.h
include/linux/lsm_hook_defs.h
include/linux/memcontrol.h
include/linux/ptp_clock_kernel.h
include/linux/skmsg.h
include/linux/sunrpc/gss_api.h
include/linux/sunrpc/gss_krb5.h
include/linux/sunrpc/xdr.h
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_flow_table.h
include/net/tcp.h
include/net/udp_tunnel.h
include/sound/rawmidi.h
include/uapi/linux/usb/raw_gadget.h
init/Kconfig
init/main.c
ipc/util.c
kernel/bpf/arraymap.c
kernel/bpf/syscall.c
kernel/bpf/verifier.c
kernel/fork.c
kernel/trace/bpf_trace.c
kernel/trace/ftrace_internal.h
kernel/trace/preemptirq_delay_test.c
kernel/trace/ring_buffer.c
kernel/umh.c
lib/test_printf.c
lib/vsprintf.c
mm/gup.c
mm/kasan/Makefile
mm/kasan/kasan.h
mm/mremap.c
net/core/dev.c
net/core/filter.c
net/core/netprio_cgroup.c
net/ipv4/cipso_ipv4.c
net/ipv4/ipmr.c
net/ipv4/route.c
net/ipv4/tcp.c
net/ipv4/tcp_bpf.c
net/ipv4/tcp_input.c
net/ipv6/calipso.c
net/ipv6/route.c
net/mptcp/protocol.c
net/mptcp/subflow.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_flow_table_core.c
net/netfilter/nf_flow_table_offload.c
net/netfilter/nft_set_rbtree.c
net/netlabel/netlabel_kapi.c
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/auth_gss/gss_krb5_crypto.c
net/sunrpc/auth_gss/gss_krb5_wrap.c
net/sunrpc/auth_gss/gss_mech_switch.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/clnt.c
net/sunrpc/xdr.c
net/tipc/socket.c
net/tipc/subscr.h
net/tipc/topsrv.c
samples/bpf/lwt_len_hist_user.c
security/apparmor/apparmorfs.c
security/apparmor/audit.c
security/apparmor/domain.c
security/integrity/evm/evm_crypto.c
security/integrity/evm/evm_main.c
security/integrity/evm/evm_secfs.c
security/integrity/ima/ima_crypto.c
security/integrity/ima/ima_fs.c
sound/core/pcm_lib.c
sound/core/rawmidi.c
sound/firewire/amdtp-stream-trace.h
sound/pci/hda/patch_realtek.c
sound/pci/ice1712/ice1712.c
sound/usb/mixer_maps.c
sound/usb/quirks-table.h
sound/usb/quirks.c
tools/bootconfig/main.c
tools/lib/bpf/bpf_tracing.h
tools/testing/selftests/bpf/prog_tests/mmap.c
tools/testing/selftests/bpf/progs/test_overhead.c
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/x86_64/debug_regs.c [new file with mode: 0644]
tools/testing/selftests/lkdtm/run.sh
tools/testing/selftests/net/mptcp/pm_netlink.sh
tools/testing/selftests/nsfs/pidns.c
virt/kvm/kvm_main.c

index db3754a..4f906b4 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -288,6 +288,8 @@ Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com>
 Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com>
 Takashi YOSHII <takashi.yoshii.zj@renesas.com>
 Will Deacon <will@kernel.org> <will.deacon@arm.com>
+Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de>
+Wolfram Sang <wsa@kernel.org> <w.sang@pengutronix.de>
 Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>
 Yusuke Goda <goda.yusuke@renesas.com>
 Gustavo Padovan <gustavo@las.ic.unicamp.br>
index 8ebe46b..5dfcc45 100644 (file)
@@ -112,6 +112,20 @@ used when printing stack backtraces. The specifier takes into
 consideration the effect of compiler optimisations which may occur
 when tail-calls are used and marked with the noreturn GCC attribute.
 
+Probed Pointers from BPF / tracing
+----------------------------------
+
+::
+
+       %pks    kernel string
+       %pus    user string
+
+The ``k`` and ``u`` specifiers are used for printing prior probed memory from
+either kernel memory (k) or user memory (u). The subsequent ``s`` specifier
+results in printing a string. For direct use in regular vsnprintf() the (k)
+and (u) annotation is ignored, however, when used out of BPF's bpf_trace_printk(),
+for example, it reads the memory it is pointing to without faulting.
+
 Kernel Pointers
 ---------------
 
index e77b08e..ee17547 100644 (file)
@@ -10,7 +10,8 @@ Required properties:
 - compatible :
        - "fsl,vf610-edma" for eDMA used similar to that on Vybrid vf610 SoC
        - "fsl,imx7ulp-edma" for eDMA2 used similar to that on i.mx7ulp
-       - "fsl,fsl,ls1028a-edma" for eDMA used similar to that on Vybrid vf610 SoC
+       - "fsl,ls1028a-edma" followed by "fsl,vf610-edma" for eDMA used on the
+         LS1028A SoC.
 - reg : Specifies base physical address(s) and size of the eDMA registers.
        The 1st region is eDMA control register's address and size.
        The 2nd and the 3rd regions are programmable channel multiplexing
index 9e78cb8..68d879a 100644 (file)
@@ -27,9 +27,8 @@ differences are:
 3. Raw Gadget provides a way to select a UDC device/driver to bind to,
    while GadgetFS currently binds to the first available UDC.
 
-4. Raw Gadget uses predictable endpoint names (handles) across different
-   UDCs (as long as UDCs have enough endpoints of each required transfer
-   type).
+4. Raw Gadget explicitly exposes information about endpoints addresses and
+   capabilities allowing a user to write UDC-agnostic gadgets.
 
 5. Raw Gadget has ioctl-based interface instead of a filesystem-based one.
 
@@ -50,12 +49,36 @@ The typical usage of Raw Gadget looks like:
    Raw Gadget and react to those depending on what kind of USB device
    needs to be emulated.
 
+Note, that some UDC drivers have fixed addresses assigned to endpoints, and
+therefore arbitrary endpoint addresses can't be used in the descriptors.
+Nevertheles, Raw Gadget provides a UDC-agnostic way to write USB gadgets.
+Once a USB_RAW_EVENT_CONNECT event is received via USB_RAW_IOCTL_EVENT_FETCH,
+the USB_RAW_IOCTL_EPS_INFO ioctl can be used to find out information about
+endpoints that the UDC driver has. Based on that information, the user must
+chose UDC endpoints that will be used for the gadget being emulated, and
+properly assign addresses in endpoint descriptors.
+
+You can find usage examples (along with a test suite) here:
+
+https://github.com/xairy/raw-gadget
+
+Internal details
+~~~~~~~~~~~~~~~~
+
+Currently every endpoint read/write ioctl submits a USB request and waits until
+its completion. This is the desired mode for coverage-guided fuzzing (as we'd
+like all USB request processing happen during the lifetime of a syscall),
+and must be kept in the implementation. (This might be slow for real world
+applications, thus the O_NONBLOCK improvement suggestion below.)
+
 Potential future improvements
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- Implement ioctl's for setting/clearing halt status on endpoints.
-
-- Reporting more events (suspend, resume, etc.) through
-  USB_RAW_IOCTL_EVENT_FETCH.
+- Report more events (suspend, resume, etc.) through USB_RAW_IOCTL_EVENT_FETCH.
 
 - Support O_NONBLOCK I/O.
+
+- Support USB 3 features (accept SS endpoint companion descriptor when
+  enabling endpoints; allow providing stream_id for bulk transfers).
+
+- Support ISO transfer features (expose frame_number for completed requests).
index 091ec22..6d60b8e 100644 (file)
@@ -5507,10 +5507,10 @@ F:      drivers/gpu/drm/vboxvideo/
 
 DRM DRIVER FOR VMWARE VIRTUAL GPU
 M:     "VMware Graphics" <linux-graphics-maintainer@vmware.com>
-M:     Thomas Hellstrom <thellstrom@vmware.com>
+M:     Roland Scheidegger <sroland@vmware.com>
 L:     dri-devel@lists.freedesktop.org
 S:     Supported
-T:     git git://people.freedesktop.org/~thomash/linux
+T:     git git://people.freedesktop.org/~sroland/linux
 F:     drivers/gpu/drm/vmwgfx/
 F:     include/uapi/drm/vmwgfx_drm.h
 
@@ -7941,7 +7941,7 @@ F:        Documentation/i2c/busses/i2c-parport.rst
 F:     drivers/i2c/busses/i2c-parport.c
 
 I2C SUBSYSTEM
-M:     Wolfram Sang <wsa@the-dreams.de>
+M:     Wolfram Sang <wsa@kernel.org>
 L:     linux-i2c@vger.kernel.org
 S:     Maintained
 W:     https://i2c.wiki.kernel.org/
@@ -10662,6 +10662,13 @@ L:     netdev@vger.kernel.org
 S:     Maintained
 F:     drivers/net/ethernet/mediatek/
 
+MEDIATEK I2C CONTROLLER DRIVER
+M:     Qii Wang <qii.wang@mediatek.com>
+L:     linux-i2c@vger.kernel.org
+S:     Maintained
+F:     Documentation/devicetree/bindings/i2c/i2c-mt65xx.txt
+F:     drivers/i2c/busses/i2c-mt65xx.c
+
 MEDIATEK JPEG DRIVER
 M:     Rick Chang <rick.chang@mediatek.com>
 M:     Bin Liu <bin.liu@mediatek.com>
@@ -11710,8 +11717,9 @@ F:      net/core/drop_monitor.c
 
 NETWORKING DRIVERS
 M:     "David S. Miller" <davem@davemloft.net>
+M:     Jakub Kicinski <kuba@kernel.org>
 L:     netdev@vger.kernel.org
-S:     Odd Fixes
+S:     Maintained
 W:     http://www.linuxfoundation.org/en/Net
 Q:     http://patchwork.ozlabs.org/project/netdev/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
@@ -14634,6 +14642,7 @@ F:      drivers/iommu/s390-iommu.c
 
 S390 IUCV NETWORK LAYER
 M:     Julian Wiedmann <jwi@linux.ibm.com>
+M:     Karsten Graul <kgraul@linux.ibm.com>
 M:     Ursula Braun <ubraun@linux.ibm.com>
 L:     linux-s390@vger.kernel.org
 S:     Supported
@@ -14644,6 +14653,7 @@ F:      net/iucv/
 
 S390 NETWORK DRIVERS
 M:     Julian Wiedmann <jwi@linux.ibm.com>
+M:     Karsten Graul <kgraul@linux.ibm.com>
 M:     Ursula Braun <ubraun@linux.ibm.com>
 L:     linux-s390@vger.kernel.org
 S:     Supported
index 11fe9b1..04f5662 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 5
 PATCHLEVEL = 7
 SUBLEVEL = 0
-EXTRAVERSION = -rc5
+EXTRAVERSION = -rc6
 NAME = Kleptomaniac Octopus
 
 # *DOCUMENTATION*
index 0974226..aa00007 100644 (file)
@@ -65,6 +65,7 @@ CONFIG_DRM_UDL=y
 CONFIG_DRM_ETNAVIV=y
 CONFIG_FB=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
 CONFIG_USB_OHCI_HCD=y
index e1aa212..cd5636d 100644 (file)
 
 /* clobbers r5 register */
 .macro DSP_EARLY_INIT
+#ifdef CONFIG_ISA_ARCV2
        lr      r5, [ARC_AUX_DSP_BUILD]
        bmsk    r5, r5, 7
        breq    r5, 0, 1f
        mov     r5, DSP_CTRL_DISABLED_ALL
        sr      r5, [ARC_AUX_DSP_CTRL]
 1:
+#endif
 .endm
 
 /* clobbers r10, r11 registers pair */
index ae0aa53..0ff4c06 100644 (file)
 
 #ifdef CONFIG_ARC_IRQ_NO_AUTOSAVE
        __RESTORE_REGFILE_HARD
+
+       ; SP points to PC/STAT32: hw restores them despite NO_AUTOSAVE
        add     sp, sp, SZ_PT_REGS - 8
 #else
        add     sp, sp, PT_r0
index 7553967..8c4fc4b 100644 (file)
@@ -3,9 +3,6 @@
 # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 #
 
-# Pass UTS_MACHINE for user_regset definition
-CFLAGS_ptrace.o                += -DUTS_MACHINE='"$(UTS_MACHINE)"'
-
 obj-y  := arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
 obj-y  += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
 obj-$(CONFIG_ISA_ARCOMPACT)            += entry-compact.o intc-compact.o
index d5f3fcf..f49a054 100644 (file)
@@ -253,7 +253,7 @@ static const struct user_regset arc_regsets[] = {
 };
 
 static const struct user_regset_view user_arc_view = {
-       .name           = UTS_MACHINE,
+       .name           = "arc",
        .e_machine      = EM_ARC_INUSE,
        .regsets        = arc_regsets,
        .n              = ARRAY_SIZE(arc_regsets)
index b2b1cb6..dad8a65 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/clocksource.h>
 #include <linux/console.h>
 #include <linux/module.h>
+#include <linux/sizes.h>
 #include <linux/cpu.h>
 #include <linux/of_clk.h>
 #include <linux/of_fdt.h>
@@ -424,12 +425,12 @@ static void arc_chk_core_config(void)
        if ((unsigned int)__arc_dccm_base != cpu->dccm.base_addr)
                panic("Linux built with incorrect DCCM Base address\n");
 
-       if (CONFIG_ARC_DCCM_SZ != cpu->dccm.sz)
+       if (CONFIG_ARC_DCCM_SZ * SZ_1K != cpu->dccm.sz)
                panic("Linux built with incorrect DCCM Size\n");
 #endif
 
 #ifdef CONFIG_ARC_HAS_ICCM
-       if (CONFIG_ARC_ICCM_SZ != cpu->iccm.sz)
+       if (CONFIG_ARC_ICCM_SZ * SZ_1K != cpu->iccm.sz)
                panic("Linux built with incorrect ICCM Size\n");
 #endif
 
index d299950..3393558 100644 (file)
@@ -191,10 +191,9 @@ void show_regs(struct pt_regs *regs)
        if (user_mode(regs))
                show_faulting_vma(regs->ret); /* faulting code, not data */
 
-       pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\n",
-               regs->event, current->thread.fault_address, regs->ret);
-
-       pr_info("STAT32: 0x%08lx", regs->status32);
+       pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\nSTAT: 0x%08lx",
+               regs->event, current->thread.fault_address, regs->ret,
+               regs->status32);
 
 #define STS_BIT(r, bit)        r->status32 & STATUS_##bit##_MASK ? #bit" " : ""
 
@@ -210,11 +209,10 @@ void show_regs(struct pt_regs *regs)
                        (regs->status32 & STATUS_U_MASK) ? "U " : "K ",
                        STS_BIT(regs, DE), STS_BIT(regs, AE));
 #endif
-       pr_cont("  BTA: 0x%08lx\n", regs->bta);
-       pr_info("BLK: %pS\n SP: 0x%08lx  FP: 0x%08lx\n",
-               (void *)regs->blink, regs->sp, regs->fp);
+       pr_cont("  BTA: 0x%08lx\n  SP: 0x%08lx  FP: 0x%08lx BLK: %pS\n",
+               regs->bta, regs->sp, regs->fp, (void *)regs->blink);
        pr_info("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
-              regs->lp_start, regs->lp_end, regs->lp_count);
+               regs->lp_start, regs->lp_end, regs->lp_count);
 
        /* print regs->r0 thru regs->r12
         * Sequential printing was generating horrible code
index 27ea64b..f87758a 100644 (file)
@@ -1178,11 +1178,9 @@ int arc_unwind(struct unwind_frame_info *frame)
 #endif
 
        /* update frame */
-#ifndef CONFIG_AS_CFI_SIGNAL_FRAME
        if (frame->call_frame
            && !UNW_DEFAULT_RA(state.regs[retAddrReg], state.dataAlign))
                frame->call_frame = 0;
-#endif
        cfa = FRAME_REG(state.cfa.reg, unsigned long) + state.cfa.offs;
        startLoc = min_t(unsigned long, UNW_SP(frame), cfa);
        endLoc = max_t(unsigned long, UNW_SP(frame), cfa);
index a931d0a..a645bca 100644 (file)
@@ -6,6 +6,7 @@
 
 menuconfig ARC_PLAT_EZNPS
        bool "\"EZchip\" ARC dev platform"
+       depends on ISA_ARCOMPACT
        select CPU_BIG_ENDIAN
        select CLKSRC_NPS if !PHYS_ADDR_T_64BIT
        select EZNPS_GIC
index 66a04f6..c77c93c 100644 (file)
@@ -12,6 +12,7 @@ config ARM
        select ARCH_HAS_KEEPINITRD
        select ARCH_HAS_KCOV
        select ARCH_HAS_MEMBARRIER_SYNC_CORE
+       select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
        select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
        select ARCH_HAS_PHYS_TO_DMA
        select ARCH_HAS_SETUP_DMA_OPS
index fa00880..85c95cc 100644 (file)
@@ -40,3 +40,7 @@
        status = "okay";
        dual_emac;
 };
+
+&m_can0 {
+       status = "disabled";
+};
index 4740989..7191ee6 100644 (file)
                        #address-cells = <1>;
                        ranges = <0x51000000 0x51000000 0x3000
                                  0x0        0x20000000 0x10000000>;
+                       dma-ranges;
                        /**
                         * To enable PCI endpoint mode, disable the pcie1_rc
                         * node and enable pcie1_ep mode.
                                device_type = "pci";
                                ranges = <0x81000000 0 0          0x03000 0 0x00010000
                                          0x82000000 0 0x20013000 0x13000 0 0xffed000>;
-                               dma-ranges = <0x02000000 0x0 0x00000000 0x00000000 0x1 0x00000000>;
                                bus-range = <0x00 0xff>;
                                #interrupt-cells = <1>;
                                num-lanes = <1>;
                        #address-cells = <1>;
                        ranges = <0x51800000 0x51800000 0x3000
                                  0x0        0x30000000 0x10000000>;
+                       dma-ranges;
                        status = "disabled";
                        pcie2_rc: pcie@51800000 {
                                reg = <0x51800000 0x2000>, <0x51802000 0x14c>, <0x1000 0x2000>;
                                device_type = "pci";
                                ranges = <0x81000000 0 0          0x03000 0 0x00010000
                                          0x82000000 0 0x30013000 0x13000 0 0xffed000>;
-                               dma-ranges = <0x02000000 0x0 0x00000000 0x00000000 0x1 0x00000000>;
                                bus-range = <0x00 0xff>;
                                #interrupt-cells = <1>;
                                num-lanes = <1>;
index 0cd75da..1886397 100644 (file)
@@ -75,8 +75,8 @@
        imx27-phycard-s-rdk {
                pinctrl_i2c1: i2c1grp {
                        fsl,pins = <
-                               MX27_PAD_I2C2_SDA__I2C2_SDA 0x0
-                               MX27_PAD_I2C2_SCL__I2C2_SCL 0x0
+                               MX27_PAD_I2C_DATA__I2C_DATA 0x0
+                               MX27_PAD_I2C_CLK__I2C_CLK 0x0
                        >;
                };
 
index 0d594e4..a1173bf 100644 (file)
@@ -38,7 +38,7 @@
 };
 
 &switch_ports {
-       /delete-node/ port@2;
+       /delete-node/ port@3;
 };
 
 &touchscreen {
index ede2e0c..e10f992 100644 (file)
@@ -72,8 +72,6 @@
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index 9067e0e..06fbffa 100644 (file)
 };
 
 &mmc3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&mmc3_pins>;
        vmmc-supply = <&wl12xx_vmmc>;
        /* uart2_tx.sdmmc3_dat1 pad as wakeirq */
        interrupts-extended = <&wakeupgen GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH
                >;
        };
 
+       /*
+        * Android uses PIN_OFF_INPUT_PULLDOWN | PIN_INPUT_PULLUP | MUX_MODE3
+        * for gpio_100, but the internal pull makes wlan flakey on some
+        * devices. Off mode value should be tested if we have off mode working
+        * later on.
+        */
+       mmc3_pins: pinmux_mmc3_pins {
+               pinctrl-single,pins = <
+               /* 0x4a10008e gpmc_wait2.gpio_100 d23 */
+               OMAP4_IOPAD(0x08e, PIN_INPUT | MUX_MODE3)
+
+               /* 0x4a100102 abe_mcbsp1_dx.sdmmc3_dat2 ab25 */
+               OMAP4_IOPAD(0x102, PIN_INPUT_PULLUP | MUX_MODE1)
+
+               /* 0x4a100104 abe_mcbsp1_fsx.sdmmc3_dat3 ac27 */
+               OMAP4_IOPAD(0x104, PIN_INPUT_PULLUP | MUX_MODE1)
+
+               /* 0x4a100118 uart2_cts.sdmmc3_clk ab26 */
+               OMAP4_IOPAD(0x118, PIN_INPUT | MUX_MODE1)
+
+               /* 0x4a10011a uart2_rts.sdmmc3_cmd ab27 */
+               OMAP4_IOPAD(0x11a, PIN_INPUT_PULLUP | MUX_MODE1)
+
+               /* 0x4a10011c uart2_rx.sdmmc3_dat0 aa25 */
+               OMAP4_IOPAD(0x11c, PIN_INPUT_PULLUP | MUX_MODE1)
+
+               /* 0x4a10011e uart2_tx.sdmmc3_dat1 aa26 */
+               OMAP4_IOPAD(0x11e, PIN_INPUT_PULLUP | MUX_MODE1)
+               >;
+       };
+
        /* gpmc_ncs0.gpio_50 */
        poweroff_gpio: pinmux_poweroff_pins {
                pinctrl-single,pins = <
 };
 
 /*
- * As uart1 is wired to mdm6600 with rts and cts, we can use the cts pin for
- * uart1 wakeirq.
+ * The uart1 port is wired to mdm6600 with rts and cts. The modem uses gpio_149
+ * for wake-up events for both the USB PHY and the UART. We can use gpio_149
+ * pad as the shared wakeirq for the UART rather than the RX or CTS pad as we
+ * have gpio_149 trigger before the UART transfer starts.
  */
 &uart1 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart1_pins>;
        interrupts-extended = <&wakeupgen GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH
-                              &omap4_pmx_core 0xfc>;
+                              &omap4_pmx_core 0x110>;
+       uart-has-rtscts;
+       current-speed = <115200>;
 };
 
 &uart3 {
index 72b7977..cace438 100644 (file)
                        reg = <0xe803b000 0x30>;
                        interrupts = <GIC_SPI 56 IRQ_TYPE_EDGE_RISING>;
                        clocks = <&cpg CPG_MOD 36>;
-                       clock-names = "ostm0";
                        power-domains = <&cpg>;
                        status = "disabled";
                };
                        reg = <0xe803c000 0x30>;
                        interrupts = <GIC_SPI 57 IRQ_TYPE_EDGE_RISING>;
                        clocks = <&cpg CPG_MOD 35>;
-                       clock-names = "ostm1";
                        power-domains = <&cpg>;
                        status = "disabled";
                };
                        reg = <0xe803d000 0x30>;
                        interrupts = <GIC_SPI 58 IRQ_TYPE_EDGE_RISING>;
                        clocks = <&cpg CPG_MOD 34>;
-                       clock-names = "ostm2";
                        power-domains = <&cpg>;
                        status = "disabled";
                };
index a5cd312..a3ba722 100644 (file)
        cmt1: timer@e6130000 {
                compatible = "renesas,r8a73a4-cmt1", "renesas,rcar-gen2-cmt1";
                reg = <0 0xe6130000 0 0x1004>;
-               interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
+               interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A73A4_CLK_CMT1>;
                clock-names = "fck";
                power-domains = <&pd_c5>;
index ebc1ff6..90feb2c 100644 (file)
                cpg_clocks: cpg_clocks@e6150000 {
                        compatible = "renesas,r8a7740-cpg-clocks";
                        reg = <0xe6150000 0x10000>;
-                       clocks = <&extal1_clk>, <&extalr_clk>;
+                       clocks = <&extal1_clk>, <&extal2_clk>, <&extalr_clk>;
                        #clock-cells = <1>;
                        clock-output-names = "system", "pllc0", "pllc1",
                                             "pllc2", "r",
index 92aa26b..b1f679d 100644 (file)
@@ -84,8 +84,6 @@
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index 69745de..bfe778c 100644 (file)
                        adi,input-depth = <8>;
                        adi,input-colorspace = "rgb";
                        adi,input-clock = "1x";
-                       adi,input-style = <1>;
-                       adi,input-justification = "evenly";
 
                        ports {
                                #address-cells = <1>;
index 4138efb..6a457bc 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index 687167b..fc74c6c 100644 (file)
                        adi,input-depth = <8>;
                        adi,input-colorspace = "rgb";
                        adi,input-clock = "1x";
-                       adi,input-style = <1>;
-                       adi,input-justification = "evenly";
 
                        ports {
                                #address-cells = <1>;
index a8e0335..114bf1c 100644 (file)
                        adi,input-depth = <8>;
                        adi,input-colorspace = "rgb";
                        adi,input-clock = "1x";
-                       adi,input-style = <1>;
-                       adi,input-justification = "evenly";
 
                        ports {
                                #address-cells = <1>;
index 248eb71..9368ac2 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index bd2a63b..ba2d2a5 100644 (file)
         */
        hdmi@3d {
                compatible = "adi,adv7513";
-               reg = <0x3d>, <0x2d>, <0x4d>, <0x5d>;
-               reg-names = "main", "cec", "edid", "packet";
+               reg = <0x3d>, <0x4d>, <0x2d>, <0x5d>;
+               reg-names = "main", "edid", "cec", "packet";
 
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
 
        hdmi@39 {
                compatible = "adi,adv7513";
-               reg = <0x39>, <0x29>, <0x49>, <0x59>;
-               reg-names = "main", "cec", "edid", "packet";
+               reg = <0x39>, <0x49>, <0x29>, <0x59>;
+               reg-names = "main", "edid", "cec", "packet";
 
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index cfe06a7..79baf06 100644 (file)
                        adi,input-depth = <8>;
                        adi,input-colorspace = "rgb";
                        adi,input-clock = "1x";
-                       adi,input-style = <1>;
-                       adi,input-justification = "evenly";
 
                        ports {
                                #address-cells = <1>;
index 9aaa96e..b8b0941 100644 (file)
                        adi,input-depth = <8>;
                        adi,input-colorspace = "rgb";
                        adi,input-clock = "1x";
-                       adi,input-style = <1>;
-                       adi,input-justification = "evenly";
 
                        ports {
                                #address-cells = <1>;
index 781ac75..d9a0c9a 100644 (file)
                assigned-clocks = <&cru SCLK_GPU>;
                assigned-clock-rates = <100000000>;
                clocks = <&cru SCLK_GPU>, <&cru SCLK_GPU>;
-               clock-names = "core", "bus";
+               clock-names = "bus", "core";
                resets = <&cru SRST_GPU>;
                status = "disabled";
        };
index 5670b33..aed879d 100644 (file)
@@ -46,7 +46,7 @@
                #address-cells = <1>;
                #size-cells = <0>;
 
-               phy: phy@0 {
+               phy: ethernet-phy@0 {
                        compatible = "ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22";
                        reg = <0>;
                        clocks = <&cru SCLK_MAC_PHY>;
index 679fc2b..933ef69 100644 (file)
                #address-cells = <1>;
                #size-cells = <0>;
 
-               phy: phy@0 {
+               phy: ethernet-phy@0 {
                        compatible = "ethernet-phy-id1234.d400",
                                     "ethernet-phy-ieee802.3-c22";
                        reg = <0>;
index 06172eb..5485a99 100644 (file)
                                  "pp1",
                                  "ppmmu1";
                clocks = <&cru ACLK_GPU>, <&cru ACLK_GPU>;
-               clock-names = "core", "bus";
+               clock-names = "bus", "core";
                resets = <&cru SRST_GPU_A>;
                status = "disabled";
        };
                        };
                };
 
-               spi-0 {
+               spi0 {
                        spi0_clk: spi0-clk {
                                rockchip,pins = <0 RK_PB1 2 &pcfg_pull_up>;
                        };
                        };
                };
 
-               spi-1 {
+               spi1 {
                        spi1_clk: spi1-clk {
                                rockchip,pins = <0 RK_PC7 2 &pcfg_pull_up>;
                        };
index f9fcb7e..d929b60 100644 (file)
@@ -84,7 +84,7 @@
                compatible = "arm,mali-400";
                reg = <0x10090000 0x10000>;
                clocks = <&cru ACLK_GPU>, <&cru ACLK_GPU>;
-               clock-names = "core", "bus";
+               clock-names = "bus", "core";
                assigned-clocks = <&cru ACLK_GPU>;
                assigned-clock-rates = <100000000>;
                resets = <&cru SRST_GPU>;
index 11e2211..84a3b05 100644 (file)
@@ -147,6 +147,7 @@ CONFIG_I2C_DAVINCI=y
 CONFIG_SPI=y
 CONFIG_SPI_DAVINCI=y
 CONFIG_SPI_SPIDEV=y
+CONFIG_PTP_1588_CLOCK=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
index 3cc3ca5..8b83d4a 100644 (file)
@@ -274,6 +274,7 @@ CONFIG_SPI_TI_QSPI=m
 CONFIG_HSI=m
 CONFIG_OMAP_SSI=m
 CONFIG_SSI_PROTOCOL=m
+CONFIG_PTP_1588_CLOCK=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_DEBUG_GPIO=y
 CONFIG_GPIO_SYSFS=y
index ab35275..f0a50b9 100644 (file)
@@ -27,7 +27,8 @@ static void __iomem *gic_cpu_ctrl;
 #define GIC_CPU_CTRL                   0x00
 #define GIC_CPU_CTRL_ENABLE            1
 
-int __init ox820_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int __init ox820_boot_secondary(unsigned int cpu,
+               struct task_struct *idle)
 {
        /*
         * Write the address of secondary startup into the
index 40fb05d..5d513f4 100644 (file)
@@ -20,6 +20,7 @@ config ARM64
        select ARCH_HAS_KCOV
        select ARCH_HAS_KEEPINITRD
        select ARCH_HAS_MEMBARRIER_SYNC_CORE
+       select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
        select ARCH_HAS_PTE_DEVMAP
        select ARCH_HAS_PTE_SPECIAL
        select ARCH_HAS_SETUP_DMA_OPS
index 316e8a4..dc4ab6b 100644 (file)
@@ -98,7 +98,7 @@
 };
 
 &codec_analog {
-       hpvcc-supply = <&reg_eldo1>;
+       cpvdd-supply = <&reg_eldo1>;
        status = "okay";
 };
 
index 31143fe..c26cc1f 100644 (file)
                };
        };
 
-       sound_spdif {
-               compatible = "simple-audio-card";
-               simple-audio-card,name = "On-board SPDIF";
-
-               simple-audio-card,cpu {
-                       sound-dai = <&spdif>;
-               };
-
-               simple-audio-card,codec {
-                       sound-dai = <&spdif_out>;
-               };
-       };
-
-       spdif_out: spdif-out {
-               #sound-dai-cells = <0>;
-               compatible = "linux,spdif-dit";
-       };
-
        timer {
                compatible = "arm,armv8-timer";
                allwinner,erratum-unknown1;
index 0882ea2..c0aef7d 100644 (file)
                                reg = <0x0 0xff400000 0x0 0x40000>;
                                interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&clkc CLKID_USB1_DDR_BRIDGE>;
-                               clock-names = "ddr";
+                               clock-names = "otg";
                                phys = <&usb2_phy1>;
                                phy-names = "usb2-phy";
                                dr_mode = "peripheral";
index 783e5a3..55d3902 100644 (file)
@@ -1,4 +1,3 @@
-
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
  * Copyright (c) 2019 BayLibre, SAS
index c33e85f..c6c8cae 100644 (file)
        clock-latency = <50000>;
 };
 
+&frddr_a {
+       status = "okay";
+};
+
 &frddr_b {
        status = "okay";
 };
index 325e448..06c5430 100644 (file)
 &usb {
        status = "okay";
        dr_mode = "host";
-       vbus-regulator = <&usb_pwr_en>;
+       vbus-supply = <&usb_pwr_en>;
 };
 
 &usb2_phy0 {
index 2a7f70b..13d0570 100644 (file)
 
                edma0: dma-controller@22c0000 {
                        #dma-cells = <2>;
-                       compatible = "fsl,ls1028a-edma";
+                       compatible = "fsl,ls1028a-edma", "fsl,vf610-edma";
                        reg = <0x0 0x22c0000 0x0 0x10000>,
                              <0x0 0x22d0000 0x0 0x10000>,
                              <0x0 0x22e0000 0x0 0x10000>;
index cc7152e..8829628 100644 (file)
 
                aips1: bus@30000000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x301f0000 0x10000>;
+                       reg = <0x30000000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x30000000 0x30000000 0x400000>;
 
                aips2: bus@30400000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x305f0000 0x10000>;
+                       reg = <0x30400000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x30400000 0x30400000 0x400000>;
 
                aips3: bus@30800000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x309f0000 0x10000>;
+                       reg = <0x30800000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x30800000 0x30800000 0x400000>,
 
                aips4: bus@32c00000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x32df0000 0x10000>;
+                       reg = <0x32c00000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x32c00000 0x32c00000 0x400000>;
index fa78f01..43971ab 100644 (file)
 
                aips1: bus@30000000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x301f0000 0x10000>;
+                       reg = <0x30000000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
 
                aips2: bus@30400000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x305f0000 0x10000>;
+                       reg = <0x30400000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
 
                aips3: bus@30800000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x309f0000 0x10000>;
+                       reg = <0x30800000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
                                reg = <0x30bd0000 0x10000>;
                                interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&clk IMX8MN_CLK_SDMA1_ROOT>,
-                                        <&clk IMX8MN_CLK_SDMA1_ROOT>;
+                                        <&clk IMX8MN_CLK_AHB>;
                                clock-names = "ipg", "ahb";
                                #dma-cells = <3>;
                                fsl,sdma-ram-script-name = "imx/sdma/sdma-imx7d.bin";
 
                aips4: bus@32c00000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x32df0000 0x10000>;
+                       reg = <0x32c00000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
index da78f89..319ab34 100644 (file)
 #define MX8MP_IOMUXC_ENET_TXC__SIM_M_HADDR22                         0x070 0x2D0 0x000 0x7 0x0
 #define MX8MP_IOMUXC_ENET_RX_CTL__ENET_QOS_RGMII_RX_CTL              0x074 0x2D4 0x000 0x0 0x0
 #define MX8MP_IOMUXC_ENET_RX_CTL__AUDIOMIX_SAI7_TX_SYNC              0x074 0x2D4 0x540 0x2 0x0
-#define MX8MP_IOMUXC_ENET_RX_CTL__AUDIOMIX_BIT_STREAM03              0x074 0x2D4 0x4CC 0x3 0x0
+#define MX8MP_IOMUXC_ENET_RX_CTL__AUDIOMIX_BIT_STREAM03              0x074 0x2D4 0x4CC 0x3 0x1
 #define MX8MP_IOMUXC_ENET_RX_CTL__GPIO1_IO24                         0x074 0x2D4 0x000 0x5 0x0
 #define MX8MP_IOMUXC_ENET_RX_CTL__USDHC3_DATA2                       0x074 0x2D4 0x618 0x6 0x0
 #define MX8MP_IOMUXC_ENET_RX_CTL__SIM_M_HADDR23                      0x074 0x2D4 0x000 0x7 0x0
 #define MX8MP_IOMUXC_ENET_RXC__CCM_ENET_QOS_CLOCK_GENERATE_RX_CLK    0x078 0x2D8 0x000 0x0 0x0
 #define MX8MP_IOMUXC_ENET_RXC__ENET_QOS_RX_ER                        0x078 0x2D8 0x000 0x1 0x0
 #define MX8MP_IOMUXC_ENET_RXC__AUDIOMIX_SAI7_TX_BCLK                 0x078 0x2D8 0x53C 0x2 0x0
-#define MX8MP_IOMUXC_ENET_RXC__AUDIOMIX_BIT_STREAM02                 0x078 0x2D8 0x4C8 0x3 0x0
+#define MX8MP_IOMUXC_ENET_RXC__AUDIOMIX_BIT_STREAM02                 0x078 0x2D8 0x4C8 0x3 0x1
 #define MX8MP_IOMUXC_ENET_RXC__GPIO1_IO25                            0x078 0x2D8 0x000 0x5 0x0
 #define MX8MP_IOMUXC_ENET_RXC__USDHC3_DATA3                          0x078 0x2D8 0x61C 0x6 0x0
 #define MX8MP_IOMUXC_ENET_RXC__SIM_M_HADDR24                         0x078 0x2D8 0x000 0x7 0x0
 #define MX8MP_IOMUXC_ENET_RD0__ENET_QOS_RGMII_RD0                    0x07C 0x2DC 0x000 0x0 0x0
 #define MX8MP_IOMUXC_ENET_RD0__AUDIOMIX_SAI7_RX_DATA00               0x07C 0x2DC 0x534 0x2 0x0
-#define MX8MP_IOMUXC_ENET_RD0__AUDIOMIX_BIT_STREAM01                 0x07C 0x2DC 0x4C4 0x3 0x0
+#define MX8MP_IOMUXC_ENET_RD0__AUDIOMIX_BIT_STREAM01                 0x07C 0x2DC 0x4C4 0x3 0x1
 #define MX8MP_IOMUXC_ENET_RD0__GPIO1_IO26                            0x07C 0x2DC 0x000 0x5 0x0
 #define MX8MP_IOMUXC_ENET_RD0__USDHC3_DATA4                          0x07C 0x2DC 0x620 0x6 0x0
 #define MX8MP_IOMUXC_ENET_RD0__SIM_M_HADDR25                         0x07C 0x2DC 0x000 0x7 0x0
 #define MX8MP_IOMUXC_ENET_RD1__ENET_QOS_RGMII_RD1                    0x080 0x2E0 0x000 0x0 0x0
 #define MX8MP_IOMUXC_ENET_RD1__AUDIOMIX_SAI7_RX_SYNC                 0x080 0x2E0 0x538 0x2 0x0
-#define MX8MP_IOMUXC_ENET_RD1__AUDIOMIX_BIT_STREAM00                 0x080 0x2E0 0x4C0 0x3 0x0
+#define MX8MP_IOMUXC_ENET_RD1__AUDIOMIX_BIT_STREAM00                 0x080 0x2E0 0x4C0 0x3 0x1
 #define MX8MP_IOMUXC_ENET_RD1__GPIO1_IO27                            0x080 0x2E0 0x000 0x5 0x0
 #define MX8MP_IOMUXC_ENET_RD1__USDHC3_RESET_B                        0x080 0x2E0 0x000 0x6 0x0
 #define MX8MP_IOMUXC_ENET_RD1__SIM_M_HADDR26                         0x080 0x2E0 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SD2_DATA0__I2C4_SDA                             0x0C8 0x328 0x5C0 0x2 0x1
 #define MX8MP_IOMUXC_SD2_DATA0__UART2_DCE_RX                         0x0C8 0x328 0x5F0 0x3 0x2
 #define MX8MP_IOMUXC_SD2_DATA0__UART2_DTE_TX                         0x0C8 0x328 0x000 0x3 0x0
-#define MX8MP_IOMUXC_SD2_DATA0__AUDIOMIX_BIT_STREAM00                0x0C8 0x328 0x4C0 0x4 0x1
+#define MX8MP_IOMUXC_SD2_DATA0__AUDIOMIX_BIT_STREAM00                0x0C8 0x328 0x4C0 0x4 0x2
 #define MX8MP_IOMUXC_SD2_DATA0__GPIO2_IO15                           0x0C8 0x328 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SD2_DATA0__CCMSRCGPCMIX_OBSERVE2                0x0C8 0x328 0x000 0x6 0x0
 #define MX8MP_IOMUXC_SD2_DATA0__OBSERVE_MUX_OUT02                    0x0C8 0x328 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3                         0x0D4 0x334 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SD2_DATA3__ECSPI2_MISO                          0x0D4 0x334 0x56C 0x2 0x0
 #define MX8MP_IOMUXC_SD2_DATA3__AUDIOMIX_SPDIF_IN                    0x0D4 0x334 0x544 0x3 0x1
-#define MX8MP_IOMUXC_SD2_DATA3__AUDIOMIX_BIT_STREAM03                0x0D4 0x334 0x4CC 0x4 0x1
+#define MX8MP_IOMUXC_SD2_DATA3__AUDIOMIX_BIT_STREAM03                0x0D4 0x334 0x4CC 0x4 0x2
 #define MX8MP_IOMUXC_SD2_DATA3__GPIO2_IO18                           0x0D4 0x334 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SD2_DATA3__CCMSRCGPCMIX_EARLY_RESET             0x0D4 0x334 0x000 0x6 0x0
 #define MX8MP_IOMUXC_SD2_RESET_B__USDHC2_RESET_B                     0x0D8 0x338 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI5_RXD0__AUDIOMIX_SAI1_TX_DATA02              0x134 0x394 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI5_RXD0__PWM2_OUT                             0x134 0x394 0x000 0x2 0x0
 #define MX8MP_IOMUXC_SAI5_RXD0__I2C5_SCL                             0x134 0x394 0x5C4 0x3 0x1
-#define MX8MP_IOMUXC_SAI5_RXD0__AUDIOMIX_BIT_STREAM00                0x134 0x394 0x4C0 0x4 0x2
+#define MX8MP_IOMUXC_SAI5_RXD0__AUDIOMIX_BIT_STREAM00                0x134 0x394 0x4C0 0x4 0x3
 #define MX8MP_IOMUXC_SAI5_RXD0__GPIO3_IO21                           0x134 0x394 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_SAI5_RX_DATA01              0x138 0x398 0x4FC 0x0 0x0
 #define MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_SAI1_TX_DATA03              0x138 0x398 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_SAI1_TX_SYNC                0x138 0x398 0x4D8 0x2 0x0
 #define MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_SAI5_TX_SYNC                0x138 0x398 0x510 0x3 0x0
-#define MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_BIT_STREAM01                0x138 0x398 0x4C4 0x4 0x2
+#define MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_BIT_STREAM01                0x138 0x398 0x4C4 0x4 0x3
 #define MX8MP_IOMUXC_SAI5_RXD1__GPIO3_IO22                           0x138 0x398 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI5_RXD1__CAN1_TX                              0x138 0x398 0x000 0x6 0x0
 #define MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_SAI5_RX_DATA02              0x13C 0x39C 0x500 0x0 0x0
 #define MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_SAI1_TX_DATA04              0x13C 0x39C 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_SAI1_TX_SYNC                0x13C 0x39C 0x4D8 0x2 0x1
 #define MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_SAI5_TX_BCLK                0x13C 0x39C 0x50C 0x3 0x0
-#define MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_BIT_STREAM02                0x13C 0x39C 0x4C8 0x4 0x2
+#define MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_BIT_STREAM02                0x13C 0x39C 0x4C8 0x4 0x3
 #define MX8MP_IOMUXC_SAI5_RXD2__GPIO3_IO23                           0x13C 0x39C 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI5_RXD2__CAN1_RX                              0x13C 0x39C 0x54C 0x6 0x0
 #define MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_SAI5_RX_DATA03              0x140 0x3A0 0x504 0x0 0x0
 #define MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_SAI1_TX_DATA05              0x140 0x3A0 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_SAI1_TX_SYNC                0x140 0x3A0 0x4D8 0x2 0x2
 #define MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_SAI5_TX_DATA00              0x140 0x3A0 0x000 0x3 0x0
-#define MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_BIT_STREAM03                0x140 0x3A0 0x4CC 0x4 0x2
+#define MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_BIT_STREAM03                0x140 0x3A0 0x4CC 0x4 0x3
 #define MX8MP_IOMUXC_SAI5_RXD3__GPIO3_IO24                           0x140 0x3A0 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI5_RXD3__CAN2_TX                              0x140 0x3A0 0x000 0x6 0x0
 #define MX8MP_IOMUXC_SAI5_MCLK__AUDIOMIX_SAI5_MCLK                   0x144 0x3A4 0x4F0 0x0 0x0
 #define MX8MP_IOMUXC_SAI1_RXD0__AUDIOMIX_SAI1_RX_DATA00              0x150 0x3B0 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI1_RXD0__AUDIOMIX_SAI5_RX_DATA00              0x150 0x3B0 0x4F8 0x1 0x1
 #define MX8MP_IOMUXC_SAI1_RXD0__AUDIOMIX_SAI1_TX_DATA01              0x150 0x3B0 0x000 0x2 0x0
-#define MX8MP_IOMUXC_SAI1_RXD0__AUDIOMIX_BIT_STREAM00                0x150 0x3B0 0x4C0 0x3 0x3
+#define MX8MP_IOMUXC_SAI1_RXD0__AUDIOMIX_BIT_STREAM00                0x150 0x3B0 0x4C0 0x3 0x4
 #define MX8MP_IOMUXC_SAI1_RXD0__ENET1_1588_EVENT1_IN                 0x150 0x3B0 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI1_RXD0__GPIO4_IO02                           0x150 0x3B0 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI1_RXD1__AUDIOMIX_SAI1_RX_DATA01              0x154 0x3B4 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI1_RXD1__AUDIOMIX_SAI5_RX_DATA01              0x154 0x3B4 0x4FC 0x1 0x1
-#define MX8MP_IOMUXC_SAI1_RXD1__AUDIOMIX_BIT_STREAM01                0x154 0x3B4 0x4C4 0x3 0x3
+#define MX8MP_IOMUXC_SAI1_RXD1__AUDIOMIX_BIT_STREAM01                0x154 0x3B4 0x4C4 0x3 0x4
 #define MX8MP_IOMUXC_SAI1_RXD1__ENET1_1588_EVENT1_OUT                0x154 0x3B4 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI1_RXD1__GPIO4_IO03                           0x154 0x3B4 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI1_RXD2__AUDIOMIX_SAI1_RX_DATA02              0x158 0x3B8 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI1_RXD2__AUDIOMIX_SAI5_RX_DATA02              0x158 0x3B8 0x500 0x1 0x1
-#define MX8MP_IOMUXC_SAI1_RXD2__AUDIOMIX_BIT_STREAM02                0x158 0x3B8 0x4C8 0x3 0x3
+#define MX8MP_IOMUXC_SAI1_RXD2__AUDIOMIX_BIT_STREAM02                0x158 0x3B8 0x4C8 0x3 0x4
 #define MX8MP_IOMUXC_SAI1_RXD2__ENET1_MDC                            0x158 0x3B8 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI1_RXD2__GPIO4_IO04                           0x158 0x3B8 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI1_RXD3__AUDIOMIX_SAI1_RX_DATA03              0x15C 0x3BC 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI1_RXD3__AUDIOMIX_SAI5_RX_DATA03              0x15C 0x3BC 0x504 0x1 0x1
-#define MX8MP_IOMUXC_SAI1_RXD3__AUDIOMIX_BIT_STREAM03                0x15C 0x3BC 0x4CC 0x3 0x3
+#define MX8MP_IOMUXC_SAI1_RXD3__AUDIOMIX_BIT_STREAM03                0x15C 0x3BC 0x4CC 0x3 0x4
 #define MX8MP_IOMUXC_SAI1_RXD3__ENET1_MDIO                           0x15C 0x3BC 0x57C 0x4 0x1
 #define MX8MP_IOMUXC_SAI1_RXD3__GPIO4_IO05                           0x15C 0x3BC 0x000 0x5 0x0
 #define MX8MP_IOMUXC_SAI1_RXD4__AUDIOMIX_SAI1_RX_DATA04              0x160 0x3C0 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI2_RXFS__UART1_DCE_TX                         0x19C 0x3FC 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI2_RXFS__UART1_DTE_RX                         0x19C 0x3FC 0x5E8 0x4 0x2
 #define MX8MP_IOMUXC_SAI2_RXFS__GPIO4_IO21                           0x19C 0x3FC 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI2_RXFS__AUDIOMIX_BIT_STREAM02                0x19C 0x3FC 0x4C8 0x6 0x4
+#define MX8MP_IOMUXC_SAI2_RXFS__AUDIOMIX_BIT_STREAM02                0x19C 0x3FC 0x4C8 0x6 0x5
 #define MX8MP_IOMUXC_SAI2_RXFS__SIM_M_HSIZE00                        0x19C 0x3FC 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI2_RXC__AUDIOMIX_SAI2_RX_BCLK                 0x1A0 0x400 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI2_RXC__AUDIOMIX_SAI5_TX_BCLK                 0x1A0 0x400 0x50C 0x1 0x2
 #define MX8MP_IOMUXC_SAI2_RXC__UART1_DCE_RX                          0x1A0 0x400 0x5E8 0x4 0x3
 #define MX8MP_IOMUXC_SAI2_RXC__UART1_DTE_TX                          0x1A0 0x400 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI2_RXC__GPIO4_IO22                            0x1A0 0x400 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI2_RXC__AUDIOMIX_BIT_STREAM01                 0x1A0 0x400 0x4C4 0x6 0x4
+#define MX8MP_IOMUXC_SAI2_RXC__AUDIOMIX_BIT_STREAM01                 0x1A0 0x400 0x4C4 0x6 0x5
 #define MX8MP_IOMUXC_SAI2_RXC__SIM_M_HSIZE01                         0x1A0 0x400 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI2_RXD0__AUDIOMIX_SAI2_RX_DATA00              0x1A4 0x404 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI2_RXD0__AUDIOMIX_SAI5_TX_DATA00              0x1A4 0x404 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI2_RXD0__UART1_DCE_RTS                        0x1A4 0x404 0x5E4 0x4 0x2
 #define MX8MP_IOMUXC_SAI2_RXD0__UART1_DTE_CTS                        0x1A4 0x404 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI2_RXD0__GPIO4_IO23                           0x1A4 0x404 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI2_RXD0__AUDIOMIX_BIT_STREAM03                0x1A4 0x404 0x4CC 0x6 0x4
+#define MX8MP_IOMUXC_SAI2_RXD0__AUDIOMIX_BIT_STREAM03                0x1A4 0x404 0x4CC 0x6 0x5
 #define MX8MP_IOMUXC_SAI2_RXD0__SIM_M_HSIZE02                        0x1A4 0x404 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_SAI2_TX_SYNC                0x1A8 0x408 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_SAI5_TX_DATA01              0x1A8 0x408 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI2_TXFS__UART1_DCE_CTS                        0x1A8 0x408 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI2_TXFS__UART1_DTE_RTS                        0x1A8 0x408 0x5E4 0x4 0x3
 #define MX8MP_IOMUXC_SAI2_TXFS__GPIO4_IO24                           0x1A8 0x408 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_BIT_STREAM02                0x1A8 0x408 0x4C8 0x6 0x5
+#define MX8MP_IOMUXC_SAI2_TXFS__AUDIOMIX_BIT_STREAM02                0x1A8 0x408 0x4C8 0x6 0x6
 #define MX8MP_IOMUXC_SAI2_TXFS__SIM_M_HWRITE                         0x1A8 0x408 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_SAI2_TX_BCLK                 0x1AC 0x40C 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_SAI5_TX_DATA02               0x1AC 0x40C 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI2_TXC__CAN1_RX                               0x1AC 0x40C 0x54C 0x3 0x1
 #define MX8MP_IOMUXC_SAI2_TXC__GPIO4_IO25                            0x1AC 0x40C 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_BIT_STREAM01                 0x1AC 0x40C 0x4C4 0x6 0x5
+#define MX8MP_IOMUXC_SAI2_TXC__AUDIOMIX_BIT_STREAM01                 0x1AC 0x40C 0x4C4 0x6 0x6
 #define MX8MP_IOMUXC_SAI2_TXC__SIM_M_HREADYOUT                       0x1AC 0x40C 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI2_TXD0__AUDIOMIX_SAI2_TX_DATA00              0x1B0 0x410 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI2_TXD0__AUDIOMIX_SAI5_TX_DATA03              0x1B0 0x410 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI3_RXFS__AUDIOMIX_SAI3_RX_DATA01              0x1B8 0x418 0x000 0x3 0x0
 #define MX8MP_IOMUXC_SAI3_RXFS__AUDIOMIX_SPDIF_IN                    0x1B8 0x418 0x544 0x4 0x2
 #define MX8MP_IOMUXC_SAI3_RXFS__GPIO4_IO28                           0x1B8 0x418 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI3_RXFS__AUDIOMIX_BIT_STREAM00                0x1B8 0x418 0x4C0 0x6 0x4
+#define MX8MP_IOMUXC_SAI3_RXFS__AUDIOMIX_BIT_STREAM00                0x1B8 0x418 0x4C0 0x6 0x5
 #define MX8MP_IOMUXC_SAI3_RXFS__TPSMP_HTRANS00                       0x1B8 0x418 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI3_RXC__AUDIOMIX_SAI3_RX_BCLK                 0x1BC 0x41C 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI3_RXC__AUDIOMIX_SAI2_RX_DATA02               0x1BC 0x41C 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI3_RXD__UART2_DCE_RTS                         0x1C0 0x420 0x5EC 0x4 0x3
 #define MX8MP_IOMUXC_SAI3_RXD__UART2_DTE_CTS                         0x1C0 0x420 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI3_RXD__GPIO4_IO30                            0x1C0 0x420 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI3_RXD__AUDIOMIX_BIT_STREAM01                 0x1C0 0x420 0x4C4 0x6 0x6
+#define MX8MP_IOMUXC_SAI3_RXD__AUDIOMIX_BIT_STREAM01                 0x1C0 0x420 0x4C4 0x6 0x7
 #define MX8MP_IOMUXC_SAI3_RXD__TPSMP_HDATA00                         0x1C0 0x420 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_SAI3_TX_SYNC                0x1C4 0x424 0x4EC 0x0 0x1
 #define MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_SAI2_TX_DATA01              0x1C4 0x424 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI3_TXFS__UART2_DCE_RX                         0x1C4 0x424 0x5F0 0x4 0x4
 #define MX8MP_IOMUXC_SAI3_TXFS__UART2_DTE_TX                         0x1C4 0x424 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI3_TXFS__GPIO4_IO31                           0x1C4 0x424 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_BIT_STREAM03                0x1C4 0x424 0x4CC 0x6 0x5
+#define MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_BIT_STREAM03                0x1C4 0x424 0x4CC 0x6 0x6
 #define MX8MP_IOMUXC_SAI3_TXFS__TPSMP_HDATA01                        0x1C4 0x424 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_SAI3_TX_BCLK                 0x1C8 0x428 0x4E8 0x0 0x1
 #define MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_SAI2_TX_DATA02               0x1C8 0x428 0x000 0x1 0x0
 #define MX8MP_IOMUXC_SAI3_TXC__UART2_DCE_TX                          0x1C8 0x428 0x000 0x4 0x0
 #define MX8MP_IOMUXC_SAI3_TXC__UART2_DTE_RX                          0x1C8 0x428 0x5F0 0x4 0x5
 #define MX8MP_IOMUXC_SAI3_TXC__GPIO5_IO00                            0x1C8 0x428 0x000 0x5 0x0
-#define MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_BIT_STREAM02                 0x1C8 0x428 0x4C8 0x6 0x6
+#define MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_BIT_STREAM02                 0x1C8 0x428 0x4C8 0x6 0x7
 #define MX8MP_IOMUXC_SAI3_TXC__TPSMP_HDATA02                         0x1C8 0x428 0x000 0x7 0x0
 #define MX8MP_IOMUXC_SAI3_TXD__AUDIOMIX_SAI3_TX_DATA00               0x1CC 0x42C 0x000 0x0 0x0
 #define MX8MP_IOMUXC_SAI3_TXD__AUDIOMIX_SAI2_TX_DATA03               0x1CC 0x42C 0x000 0x1 0x0
index 9b1616e..9f6ba76 100644 (file)
 
                aips1: bus@30000000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x301f0000 0x10000>;
+                       reg = <0x30000000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
 
                aips2: bus@30400000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x305f0000 0x400000>;
+                       reg = <0x30400000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
 
                aips3: bus@30800000 {
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x309f0000 0x400000>;
+                       reg = <0x30800000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges;
index 75b3842..bab8836 100644 (file)
 
                bus@30000000 { /* AIPS1 */
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x301f0000 0x10000>;
+                       reg = <0x30000000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x30000000 0x30000000 0x400000>;
 
                bus@30400000 { /* AIPS2 */
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x305f0000 0x10000>;
+                       reg = <0x30400000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x30400000 0x30400000 0x400000>;
 
                bus@30800000 { /* AIPS3 */
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x309f0000 0x10000>;
+                       reg = <0x30800000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x30800000 0x30800000 0x400000>,
 
                bus@32c00000 { /* AIPS4 */
                        compatible = "fsl,aips-bus", "simple-bus";
-                       reg = <0x32df0000 0x10000>;
+                       reg = <0x32c00000 0x400000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                        ranges = <0x32c00000 0x32c00000 0x400000>;
index af87350..c4abbcc 100644 (file)
        s11 {
                qcom,saw-leader;
                regulator-always-on;
-               regulator-min-microvolt = <1230000>;
-               regulator-max-microvolt = <1230000>;
+               regulator-min-microvolt = <980000>;
+               regulator-max-microvolt = <980000>;
        };
 };
 
        status = "okay";
 };
 
+&q6asmdai {
+       dai@0 {
+               reg = <0>;
+       };
+
+       dai@1 {
+               reg = <1>;
+       };
+
+       dai@2 {
+               reg = <2>;
+       };
+};
+
 &sound {
        compatible = "qcom,apq8096-sndcard";
        model = "DB820c";
-       audio-routing = "RX_BIAS", "MCLK";
+       audio-routing = "RX_BIAS", "MCLK",
+               "MM_DL1",  "MultiMedia1 Playback",
+               "MM_DL2",  "MultiMedia2 Playback",
+               "MultiMedia3 Capture", "MM_UL3";
 
        mm1-dai-link {
                link-name = "MultiMedia1";
index 14827ad..98634d5 100644 (file)
                                                reg = <APR_SVC_ASM>;
                                                q6asmdai: dais {
                                                        compatible = "qcom,q6asm-dais";
+                                                       #address-cells = <1>;
+                                                       #size-cells = <0>;
                                                        #sound-dai-cells = <1>;
                                                        iommus = <&lpass_q6_smmu 1>;
                                                };
index a2e0592..21fd6f8 100644 (file)
 &q6asmdai {
        dai@0 {
                reg = <0>;
-               direction = <2>;
        };
 
        dai@1 {
                reg = <1>;
-               direction = <2>;
        };
 
        dai@2 {
                reg = <2>;
-               direction = <1>;
        };
 
        dai@3 {
index 3b617a7..51a670a 100644 (file)
 &q6asmdai {
        dai@0 {
                reg = <0>;
-               direction = <2>;
        };
 
        dai@1 {
                reg = <1>;
-               direction = <1>;
        };
 };
 
index 2afb91e..ac2156a 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index d7c7b91..01c4ba0 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index 3dde028..ef8350a 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index adbfd8f..6dff046 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index e01b050..d672b32 100644 (file)
                ipmmu_vip0: mmu@e7b00000 {
                        compatible = "renesas,ipmmu-r8a77980";
                        reg = <0 0xe7b00000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 4>;
                        power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        #iommu-cells = <1>;
                };
                ipmmu_vip1: mmu@e7960000 {
                        compatible = "renesas,ipmmu-r8a77980";
                        reg = <0 0xe7960000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 11>;
                        power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        #iommu-cells = <1>;
                };
index 4fd2b14..dc24cec 100644 (file)
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index 67634cb..79c73a9 100644 (file)
 
        hdmi-encoder@39 {
                compatible = "adi,adv7511w";
-               reg = <0x39>, <0x3f>, <0x38>, <0x3c>;
-               reg-names = "main", "edid", "packet", "cec";
+               reg = <0x39>, <0x3f>, <0x3c>, <0x38>;
+               reg-names = "main", "edid", "cec", "packet";
                interrupt-parent = <&gpio1>;
                interrupts = <28 IRQ_TYPE_LEVEL_LOW>;
 
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
                adi,input-clock = "1x";
-               adi,input-style = <1>;
-               adi,input-justification = "evenly";
 
                ports {
                        #address-cells = <1>;
index f809dd6..adc9b8b 100644 (file)
        };
 
        arm-pmu {
-               compatible = "arm,cortex-a53-pmu";
+               compatible = "arm,cortex-a35-pmu";
                interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
index ac43bc3..ac7f694 100644 (file)
        };
 
        arm-pmu {
-               compatible = "arm,cortex-a53-pmu";
+               compatible = "arm,cortex-a35-pmu";
                interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
index 49c4b96..ac29c27 100644 (file)
 &gmac2phy {
        phy-supply = <&vcc_phy>;
        clock_in_out = "output";
-       assigned-clocks = <&cru SCLK_MAC2PHY_SRC>;
        assigned-clock-rate = <50000000>;
        assigned-clocks = <&cru SCLK_MAC2PHY>;
        assigned-clock-parents = <&cru SCLK_MAC2PHY_SRC>;
-
+       status = "okay";
 };
 
 &i2c1 {
        status = "okay";
 
-       rk805: rk805@18 {
+       rk805: pmic@18 {
                compatible = "rockchip,rk805";
                reg = <0x18>;
                interrupt-parent = <&gpio2>;
index bf3e546..ebf3eb2 100644 (file)
 &i2c1 {
        status = "okay";
 
-       rk805: rk805@18 {
+       rk805: pmic@18 {
                compatible = "rockchip,rk805";
                reg = <0x18>;
                interrupt-parent = <&gpio2>;
index 7e88d88..a4d591d 100644 (file)
        grf: syscon@ff100000 {
                compatible = "rockchip,rk3328-grf", "syscon", "simple-mfd";
                reg = <0x0 0xff100000 0x0 0x1000>;
-               #address-cells = <1>;
-               #size-cells = <1>;
 
                io_domains: io-domains {
                        compatible = "rockchip,rk3328-io-voltage-domain";
                };
 
                gmac2phy {
-                       fephyled_speed100: fephyled-speed100 {
-                               rockchip,pins = <0 RK_PD7 1 &pcfg_pull_none>;
-                       };
-
                        fephyled_speed10: fephyled-speed10 {
                                rockchip,pins = <0 RK_PD6 1 &pcfg_pull_none>;
                        };
                                rockchip,pins = <0 RK_PD6 2 &pcfg_pull_none>;
                        };
 
-                       fephyled_rxm0: fephyled-rxm0 {
-                               rockchip,pins = <0 RK_PD5 1 &pcfg_pull_none>;
-                       };
-
-                       fephyled_txm0: fephyled-txm0 {
-                               rockchip,pins = <0 RK_PD5 2 &pcfg_pull_none>;
-                       };
-
-                       fephyled_linkm0: fephyled-linkm0 {
-                               rockchip,pins = <0 RK_PD4 1 &pcfg_pull_none>;
-                       };
-
                        fephyled_rxm1: fephyled-rxm1 {
                                rockchip,pins = <2 RK_PD1 2 &pcfg_pull_none>;
                        };
index 5ea281b..c49982d 100644 (file)
                        "Speaker", "Speaker Amplifier OUTL",
                        "Speaker", "Speaker Amplifier OUTR";
 
-               simple-audio-card,hp-det-gpio = <&gpio0 RK_PB0 GPIO_ACTIVE_LOW>;
+               simple-audio-card,hp-det-gpio = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>;
                simple-audio-card,aux-devs = <&speaker_amp>;
                simple-audio-card,pin-switches = "Speaker";
 
        fusb0: fusb30x@22 {
                compatible = "fcs,fusb302";
                reg = <0x22>;
-               fcs,int_n = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
                pinctrl-names = "default";
                pinctrl-0 = <&fusb0_int_gpio>;
                vbus-supply = <&vbus_typec>;
 
        dc-charger {
                dc_det_gpio: dc-det-gpio {
-                       rockchip,pins = <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>;
+                       rockchip,pins = <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_up>;
                };
        };
 
        es8316 {
                hp_det_gpio: hp-det-gpio {
-                       rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_down>;
+                       rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>;
                };
        };
 
index 74f2c3d..1448f35 100644 (file)
                reset-names = "usb3-otg";
                status = "disabled";
 
-               usbdrd_dwc3_0: dwc3 {
+               usbdrd_dwc3_0: usb@fe800000 {
                        compatible = "snps,dwc3";
                        reg = <0x0 0xfe800000 0x0 0x100000>;
                        interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH 0>;
                reset-names = "usb3-otg";
                status = "disabled";
 
-               usbdrd_dwc3_1: dwc3 {
+               usbdrd_dwc3_1: usb@fe900000 {
                        compatible = "snps,dwc3";
                        reg = <0x0 0xfe900000 0x0 0x100000>;
                        interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH 0>;
        pmugrf: syscon@ff320000 {
                compatible = "rockchip,rk3399-pmugrf", "syscon", "simple-mfd";
                reg = <0x0 0xff320000 0x0 0x1000>;
-               #address-cells = <1>;
-               #size-cells = <1>;
 
                pmu_io_domains: io-domains {
                        compatible = "rockchip,rk3399-pmu-io-voltage-domain";
        gpu: gpu@ff9a0000 {
                compatible = "rockchip,rk3399-mali", "arm,mali-t860";
                reg = <0x0 0xff9a0000 0x0 0x10000>;
-               interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH 0>,
-                            <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH 0>,
-                            <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH 0>;
-               interrupt-names = "gpu", "job", "mmu";
+               interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH 0>,
+                            <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH 0>,
+                            <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH 0>;
+               interrupt-names = "job", "mmu", "gpu";
                clocks = <&cru ACLK_GPU>;
                #cooling-cells = <2>;
                power-domains = <&power RK3399_PD_GPU>;
index 24e534d..03d0189 100644 (file)
@@ -208,7 +208,7 @@ CONFIG_PCIE_QCOM=y
 CONFIG_PCIE_ARMADA_8K=y
 CONFIG_PCIE_KIRIN=y
 CONFIG_PCIE_HISI_STB=y
-CONFIG_PCIE_TEGRA194=m
+CONFIG_PCIE_TEGRA194_HOST=m
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_FW_LOADER_USER_HELPER=y
@@ -567,6 +567,7 @@ CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y
 CONFIG_MEDIA_SDR_SUPPORT=y
 CONFIG_MEDIA_CONTROLLER=y
 CONFIG_VIDEO_V4L2_SUBDEV_API=y
+CONFIG_MEDIA_PLATFORM_SUPPORT=y
 # CONFIG_DVB_NET is not set
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
@@ -610,8 +611,9 @@ CONFIG_DRM_MSM=m
 CONFIG_DRM_TEGRA=m
 CONFIG_DRM_PANEL_LVDS=m
 CONFIG_DRM_PANEL_SIMPLE=m
-CONFIG_DRM_DUMB_VGA_DAC=m
+CONFIG_DRM_SIMPLE_BRIDGE=m
 CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA=m
+CONFIG_DRM_DISPLAY_CONNECTOR=m
 CONFIG_DRM_SII902X=m
 CONFIG_DRM_THINE_THC63LVD1024=m
 CONFIG_DRM_TI_SN65DSI86=m
@@ -848,7 +850,8 @@ CONFIG_QCOM_APR=m
 CONFIG_ARCH_R8A774A1=y
 CONFIG_ARCH_R8A774B1=y
 CONFIG_ARCH_R8A774C0=y
-CONFIG_ARCH_R8A7795=y
+CONFIG_ARCH_R8A77950=y
+CONFIG_ARCH_R8A77951=y
 CONFIG_ARCH_R8A77960=y
 CONFIG_ARCH_R8A77961=y
 CONFIG_ARCH_R8A77965=y
index 32fc806..bc5c7b0 100644 (file)
@@ -304,7 +304,7 @@ do {                                                                        \
                __p = uaccess_mask_ptr(__p);                            \
                __raw_get_user((x), __p, (err));                        \
        } else {                                                        \
-               (x) = 0; (err) = -EFAULT;                               \
+               (x) = (__force __typeof__(x))0; (err) = -EFAULT;        \
        }                                                               \
 } while (0)
 
index 8e9c924..a0b144c 100644 (file)
@@ -177,6 +177,7 @@ void machine_kexec(struct kimage *kimage)
         * the offline CPUs. Therefore, we must use the __* variant here.
         */
        __flush_icache_range((uintptr_t)reboot_code_buffer,
+                            (uintptr_t)reboot_code_buffer +
                             arm64_relocate_new_kernel_size);
 
        /* Flush the kimage list and its buffers. */
index b3d3005..e7b0190 100644 (file)
@@ -1829,10 +1829,11 @@ static void tracehook_report_syscall(struct pt_regs *regs,
 
 int syscall_trace_enter(struct pt_regs *regs)
 {
-       if (test_thread_flag(TIF_SYSCALL_TRACE) ||
-               test_thread_flag(TIF_SYSCALL_EMU)) {
+       unsigned long flags = READ_ONCE(current_thread_info()->flags);
+
+       if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
                tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
-               if (!in_syscall(regs) || test_thread_flag(TIF_SYSCALL_EMU))
+               if (!in_syscall(regs) || (flags & _TIF_SYSCALL_EMU))
                        return -1;
        }
 
index 94545d5..bd31ab1 100644 (file)
@@ -8,6 +8,7 @@ config CSKY
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_USE_BUILTIN_BSWAP
        select ARCH_USE_QUEUED_RWLOCKS if NR_CPUS>2
+       select ARCH_WANT_FRAME_POINTERS if !CPU_CK610
        select COMMON_CLK
        select CLKSRC_MMIO
        select CSKY_MPINTC if CPU_CK860
@@ -38,6 +39,7 @@ config CSKY
        select HAVE_ARCH_TRACEHOOK
        select HAVE_ARCH_AUDITSYSCALL
        select HAVE_COPY_THREAD_TLS
+       select HAVE_DEBUG_BUGVERBOSE
        select HAVE_DYNAMIC_FTRACE
        select HAVE_DYNAMIC_FTRACE_WITH_REGS
        select HAVE_FUNCTION_TRACER
index fb1bbbd..37f593a 100644 (file)
@@ -47,7 +47,7 @@ ifeq ($(CSKYABI),abiv2)
 KBUILD_CFLAGS += -mno-stack-size
 endif
 
-ifdef CONFIG_STACKTRACE
+ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS += -mbacktrace
 endif
 
index 5056ebb..61d94ec 100644 (file)
         *   BA     Reserved  C   D   V
         */
        cprcr   r6, cpcr30
-       lsri    r6, 28
-       lsli    r6, 28
+       lsri    r6, 29
+       lsli    r6, 29
        addi    r6, 0xe
        cpwcr   r6, cpcr30
 
index a99aff5..ab63c41 100644 (file)
         */
        mfcr    r6, cr<30, 15> /* Get MSA0 */
 2:
-       lsri    r6, 28
-       lsli    r6, 28
+       lsri    r6, 29
+       lsli    r6, 29
        addi    r6, 0x1ce
        mtcr    r6, cr<30, 15> /* Set MSA0 */
 
index 9331c7e..911512b 100644 (file)
@@ -103,6 +103,8 @@ ENTRY(_mcount)
        mov     a0, lr
        subi    a0, 4
        ldw     a1, (sp, 24)
+       lrw     a2, function_trace_op
+       ldw     a2, (a2, 0)
 
        jsr     r26
 
index c6bcd7f..24442d8 100644 (file)
@@ -41,8 +41,7 @@ extern struct cpuinfo_csky cpu_data[];
 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
 
 struct thread_struct {
-       unsigned long  ksp;       /* kernel stack pointer */
-       unsigned long  sr;        /* saved status register */
+       unsigned long  sp;        /* kernel stack pointer */
        unsigned long  trap_no;   /* saved status register */
 
        /* FPU regs */
@@ -50,8 +49,7 @@ struct thread_struct {
 };
 
 #define INIT_THREAD  { \
-       .ksp = sizeof(init_stack) + (unsigned long) &init_stack, \
-       .sr = DEFAULT_PSR_VALUE, \
+       .sp = sizeof(init_stack) + (unsigned long) &init_stack, \
 }
 
 /*
index aae5aa9..bcfb707 100644 (file)
@@ -58,6 +58,16 @@ static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
        return regs->usp;
 }
 
+static inline unsigned long frame_pointer(struct pt_regs *regs)
+{
+       return regs->regs[4];
+}
+static inline void frame_pointer_set(struct pt_regs *regs,
+                                    unsigned long val)
+{
+       regs->regs[4] = val;
+}
+
 extern int regs_query_register_offset(const char *name);
 extern unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
                                                unsigned int n);
index 442feda..5c61e84 100644 (file)
@@ -38,7 +38,13 @@ struct thread_info {
 #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
 
 #define thread_saved_fp(tsk) \
-       ((unsigned long)(((struct switch_stack *)(tsk->thread.ksp))->r8))
+       ((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r8))
+
+#define thread_saved_sp(tsk) \
+       ((unsigned long)(tsk->thread.sp))
+
+#define thread_saved_lr(tsk) \
+       ((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15))
 
 static inline struct thread_info *current_thread_info(void)
 {
@@ -54,10 +60,10 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SIGPENDING         0       /* signal pending */
 #define TIF_NOTIFY_RESUME      1       /* callback before returning to user */
 #define TIF_NEED_RESCHED       2       /* rescheduling necessary */
-#define TIF_SYSCALL_TRACE      3       /* syscall trace active */
-#define TIF_SYSCALL_TRACEPOINT 4       /* syscall tracepoint instrumentation */
-#define TIF_SYSCALL_AUDIT      5       /* syscall auditing */
-#define TIF_UPROBE             6       /* uprobe breakpoint or singlestep */
+#define TIF_UPROBE             3       /* uprobe breakpoint or singlestep */
+#define TIF_SYSCALL_TRACE      4       /* syscall trace active */
+#define TIF_SYSCALL_TRACEPOINT 5       /* syscall tracepoint instrumentation */
+#define TIF_SYSCALL_AUDIT      6       /* syscall auditing */
 #define TIF_POLLING_NRFLAG     16      /* poll_idle() is TIF_NEED_RESCHED */
 #define TIF_MEMDIE             18      /* is terminating due to OOM killer */
 #define TIF_RESTORE_SIGMASK    20      /* restore signal mask in do_signal() */
index abefa12..1633ffe 100644 (file)
@@ -253,7 +253,7 @@ do {                                                                \
 
 extern int __get_user_bad(void);
 
-#define __copy_user(to, from, n)                       \
+#define ___copy_to_user(to, from, n)                   \
 do {                                                   \
        int w0, w1, w2, w3;                             \
        asm volatile(                                   \
@@ -288,31 +288,34 @@ do {                                                      \
        "       subi    %0, 4           \n"             \
        "       br      3b              \n"             \
        "5:     cmpnei  %0, 0           \n"  /* 1B */   \
-       "       bf      8f              \n"             \
+       "       bf      13f             \n"             \
        "       ldb     %3, (%2, 0)     \n"             \
        "6:     stb     %3, (%1, 0)     \n"             \
        "       addi    %2,  1          \n"             \
        "       addi    %1,  1          \n"             \
        "       subi    %0,  1          \n"             \
        "       br      5b              \n"             \
-       "7:     br      8f              \n"             \
+       "7:     subi    %0,  4          \n"             \
+       "8:     subi    %0,  4          \n"             \
+       "12:    subi    %0,  4          \n"             \
+       "       br      13f             \n"             \
        ".section __ex_table, \"a\"     \n"             \
        ".align   2                     \n"             \
-       ".long    2b, 7b                \n"             \
-       ".long    9b, 7b                \n"             \
-       ".long   10b, 7b                \n"             \
+       ".long    2b, 13f               \n"             \
+       ".long    4b, 13f               \n"             \
+       ".long    6b, 13f               \n"             \
+       ".long    9b, 12b               \n"             \
+       ".long   10b, 8b                \n"             \
        ".long   11b, 7b                \n"             \
-       ".long    4b, 7b                \n"             \
-       ".long    6b, 7b                \n"             \
        ".previous                      \n"             \
-       "8:                             \n"             \
+       "13:                            \n"             \
        : "=r"(n), "=r"(to), "=r"(from), "=r"(w0),      \
          "=r"(w1), "=r"(w2), "=r"(w3)                  \
        : "0"(n), "1"(to), "2"(from)                    \
        : "memory");                                    \
 } while (0)
 
-#define __copy_user_zeroing(to, from, n)               \
+#define ___copy_from_user(to, from, n)                 \
 do {                                                   \
        int tmp;                                        \
        int nsave;                                      \
@@ -355,22 +358,22 @@ do {                                                      \
        "       addi    %1,  1          \n"             \
        "       subi    %0,  1          \n"             \
        "       br      5b              \n"             \
-       "8:     mov     %3, %0          \n"             \
-       "       movi    %4, 0           \n"             \
-       "9:     stb     %4, (%1, 0)     \n"             \
-       "       addi    %1, 1           \n"             \
-       "       subi    %3, 1           \n"             \
-       "       cmpnei  %3, 0           \n"             \
-       "       bt      9b              \n"             \
-       "       br      7f              \n"             \
+       "8:     stw     %3, (%1, 0)     \n"             \
+       "       subi    %0, 4           \n"             \
+       "       bf      7f              \n"             \
+       "9:     subi    %0, 8           \n"             \
+       "       bf      7f              \n"             \
+       "13:    stw     %3, (%1, 8)     \n"             \
+       "       subi    %0, 12          \n"             \
+       "       bf      7f              \n"             \
        ".section __ex_table, \"a\"     \n"             \
        ".align   2                     \n"             \
-       ".long    2b, 8b                \n"             \
+       ".long    2b, 7f                \n"             \
+       ".long    4b, 7f                \n"             \
+       ".long    6b, 7f                \n"             \
        ".long   10b, 8b                \n"             \
-       ".long   11b, 8b                \n"             \
-       ".long   12b, 8b                \n"             \
-       ".long    4b, 8b                \n"             \
-       ".long    6b, 8b                \n"             \
+       ".long   11b, 9b                \n"             \
+       ".long   12b,13b                \n"             \
        ".previous                      \n"             \
        "7:                             \n"             \
        : "=r"(n), "=r"(to), "=r"(from), "=r"(nsave),   \
index fd6d9dc..37f37c0 100644 (file)
@@ -3,7 +3,7 @@ extra-y := head.o vmlinux.lds
 
 obj-y += entry.o atomic.o signal.o traps.o irq.o time.o vdso.o
 obj-y += power.o syscall.o syscall_table.o setup.o
-obj-y += process.o cpu-probe.o ptrace.o dumpstack.o
+obj-y += process.o cpu-probe.o ptrace.o stacktrace.o
 obj-y += probes/
 
 obj-$(CONFIG_MODULES)                  += module.o
index f8be348..1747986 100644 (file)
@@ -18,8 +18,7 @@ int main(void)
        DEFINE(TASK_ACTIVE_MM,    offsetof(struct task_struct, active_mm));
 
        /* offsets into the thread struct */
-       DEFINE(THREAD_KSP,        offsetof(struct thread_struct, ksp));
-       DEFINE(THREAD_SR,         offsetof(struct thread_struct, sr));
+       DEFINE(THREAD_KSP,        offsetof(struct thread_struct, sp));
        DEFINE(THREAD_FESR,       offsetof(struct thread_struct, user_fp.fesr));
        DEFINE(THREAD_FCR,        offsetof(struct thread_struct, user_fp.fcr));
        DEFINE(THREAD_FPREG,      offsetof(struct thread_struct, user_fp.vr));
diff --git a/arch/csky/kernel/dumpstack.c b/arch/csky/kernel/dumpstack.c
deleted file mode 100644 (file)
index d67f977..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
-
-#include <linux/ptrace.h>
-
-int kstack_depth_to_print = 48;
-
-void show_trace(unsigned long *stack)
-{
-       unsigned long *stack_end;
-       unsigned long *stack_start;
-       unsigned long *fp;
-       unsigned long addr;
-
-       addr = (unsigned long) stack & THREAD_MASK;
-       stack_start = (unsigned long *) addr;
-       stack_end = (unsigned long *) (addr + THREAD_SIZE);
-
-       fp = stack;
-       pr_info("\nCall Trace:");
-
-       while (fp > stack_start && fp < stack_end) {
-#ifdef CONFIG_STACKTRACE
-               addr    = fp[1];
-               fp      = (unsigned long *) fp[0];
-#else
-               addr    = *fp++;
-#endif
-               if (__kernel_text_address(addr))
-                       pr_cont("\n[<%08lx>] %pS", addr, (void *)addr);
-       }
-       pr_cont("\n");
-}
-
-void show_stack(struct task_struct *task, unsigned long *stack)
-{
-       if (!stack) {
-               if (task)
-                       stack = (unsigned long *)thread_saved_fp(task);
-               else
-#ifdef CONFIG_STACKTRACE
-                       asm volatile("mov %0, r8\n":"=r"(stack)::"memory");
-#else
-                       stack = (unsigned long *)&stack;
-#endif
-       }
-
-       show_trace(stack);
-}
index 3648195..3760397 100644 (file)
@@ -330,11 +330,6 @@ ENTRY(__switch_to)
        lrw     a3, TASK_THREAD
        addu    a3, a0
 
-       mfcr    a2, psr                 /* Save PSR value */
-       stw     a2, (a3, THREAD_SR)     /* Save PSR in task struct */
-       bclri   a2, 6                   /* Disable interrupts */
-       mtcr    a2, psr
-
        SAVE_SWITCH_STACK
 
        stw     sp, (a3, THREAD_KSP)
@@ -345,12 +340,9 @@ ENTRY(__switch_to)
 
        ldw     sp, (a3, THREAD_KSP)    /* Set next kernel sp */
 
-       ldw     a2, (a3, THREAD_SR)     /* Set next PSR */
-       mtcr    a2, psr
-
 #if  defined(__CSKYABIV2__)
-       addi    r7, a1, TASK_THREAD_INFO
-       ldw     tls, (r7, TINFO_TP_VALUE)
+       addi    a3, a1, TASK_THREAD_INFO
+       ldw     tls, (a3, TINFO_TP_VALUE)
 #endif
 
        RESTORE_SWITCH_STACK
index 44628e3..3c425b8 100644 (file)
@@ -202,6 +202,7 @@ int ftrace_disable_ftrace_graph_caller(void)
 #endif /* CONFIG_DYNAMIC_FTRACE */
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
+#ifdef CONFIG_DYNAMIC_FTRACE
 #ifndef CONFIG_CPU_HAS_ICACHE_INS
 struct ftrace_modify_param {
        int command;
@@ -231,6 +232,7 @@ void arch_ftrace_update_code(int command)
        stop_machine(__ftrace_modify_code, &param, cpu_online_mask);
 }
 #endif
+#endif /* CONFIG_DYNAMIC_FTRACE */
 
 /* _mcount is defined in abi's mcount.S */
 EXPORT_SYMBOL(_mcount);
index e68ff37..ab55e98 100644 (file)
@@ -12,12 +12,17 @@ struct stackframe {
 
 static int unwind_frame_kernel(struct stackframe *frame)
 {
-       if (kstack_end((void *)frame->fp))
+       unsigned long low = (unsigned long)task_stack_page(current);
+       unsigned long high = low + THREAD_SIZE;
+
+       if (unlikely(frame->fp < low || frame->fp > high))
                return -EPERM;
-       if (frame->fp & 0x3 || frame->fp < TASK_SIZE)
+
+       if (kstack_end((void *)frame->fp) || frame->fp & 0x3)
                return -EPERM;
 
        *frame = *(struct stackframe *)frame->fp;
+
        if (__kernel_text_address(frame->lr)) {
                int graph = 0;
 
index b3a56c2..1a9e096 100644 (file)
 
 #define UPROBE_TRAP_NR UINT_MAX
 
+bool is_swbp_insn(uprobe_opcode_t *insn)
+{
+       return (*insn & 0xffff) == UPROBE_SWBP_INSN;
+}
+
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
 {
        return instruction_pointer(regs);
index f7b231c..8b3fad0 100644 (file)
@@ -35,7 +35,7 @@ void flush_thread(void){}
  */
 unsigned long thread_saved_pc(struct task_struct *tsk)
 {
-       struct switch_stack *sw = (struct switch_stack *)tsk->thread.ksp;
+       struct switch_stack *sw = (struct switch_stack *)tsk->thread.sp;
 
        return sw->r15;
 }
@@ -56,8 +56,8 @@ int copy_thread_tls(unsigned long clone_flags,
        childstack = ((struct switch_stack *) childregs) - 1;
        memset(childstack, 0, sizeof(struct switch_stack));
 
-       /* setup ksp for switch_to !!! */
-       p->thread.ksp = (unsigned long)childstack;
+       /* setup thread.sp for switch_to !!! */
+       p->thread.sp = (unsigned long)childstack;
 
        if (unlikely(p->flags & PF_KTHREAD)) {
                memset(childregs, 0, sizeof(struct pt_regs));
@@ -98,37 +98,6 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *pr_regs)
        return 1;
 }
 
-unsigned long get_wchan(struct task_struct *p)
-{
-       unsigned long lr;
-       unsigned long *fp, *stack_start, *stack_end;
-       int count = 0;
-
-       if (!p || p == current || p->state == TASK_RUNNING)
-               return 0;
-
-       stack_start = (unsigned long *)end_of_stack(p);
-       stack_end = (unsigned long *)(task_stack_page(p) + THREAD_SIZE);
-
-       fp = (unsigned long *) thread_saved_fp(p);
-       do {
-               if (fp < stack_start || fp > stack_end)
-                       return 0;
-#ifdef CONFIG_STACKTRACE
-               lr = fp[1];
-               fp = (unsigned long *)fp[0];
-#else
-               lr = *fp++;
-#endif
-               if (!in_sched_functions(lr) &&
-                   __kernel_text_address(lr))
-                       return lr;
-       } while (count++ < 16);
-
-       return 0;
-}
-EXPORT_SYMBOL(get_wchan);
-
 #ifndef CONFIG_CPU_PM_NONE
 void arch_cpu_idle(void)
 {
index 21ac260..5a82230 100644 (file)
@@ -41,6 +41,9 @@ static void singlestep_disable(struct task_struct *tsk)
 
        regs = task_pt_regs(tsk);
        regs->sr = (regs->sr & TRACE_MODE_MASK) | TRACE_MODE_RUN;
+
+       /* Enable irq */
+       regs->sr |= BIT(6);
 }
 
 static void singlestep_enable(struct task_struct *tsk)
@@ -49,6 +52,9 @@ static void singlestep_enable(struct task_struct *tsk)
 
        regs = task_pt_regs(tsk);
        regs->sr = (regs->sr & TRACE_MODE_MASK) | TRACE_MODE_SI;
+
+       /* Disable irq */
+       regs->sr &= ~BIT(6);
 }
 
 /*
index fec777a..92809e1 100644 (file)
 // SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. */
 
 #include <linux/sched/debug.h>
 #include <linux/sched/task_stack.h>
 #include <linux/stacktrace.h>
 #include <linux/ftrace.h>
+#include <linux/ptrace.h>
 
-void save_stack_trace(struct stack_trace *trace)
+#ifdef CONFIG_FRAME_POINTER
+
+struct stackframe {
+       unsigned long fp;
+       unsigned long ra;
+};
+
+void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
+                            bool (*fn)(unsigned long, void *), void *arg)
 {
-       save_stack_trace_tsk(current, trace);
+       unsigned long fp, sp, pc;
+
+       if (regs) {
+               fp = frame_pointer(regs);
+               sp = user_stack_pointer(regs);
+               pc = instruction_pointer(regs);
+       } else if (task == NULL || task == current) {
+               const register unsigned long current_sp __asm__ ("sp");
+               const register unsigned long current_fp __asm__ ("r8");
+               fp = current_fp;
+               sp = current_sp;
+               pc = (unsigned long)walk_stackframe;
+       } else {
+               /* task blocked in __switch_to */
+               fp = thread_saved_fp(task);
+               sp = thread_saved_sp(task);
+               pc = thread_saved_lr(task);
+       }
+
+       for (;;) {
+               unsigned long low, high;
+               struct stackframe *frame;
+
+               if (unlikely(!__kernel_text_address(pc) || fn(pc, arg)))
+                       break;
+
+               /* Validate frame pointer */
+               low = sp;
+               high = ALIGN(sp, THREAD_SIZE);
+               if (unlikely(fp < low || fp > high || fp & 0x3))
+                       break;
+               /* Unwind stack frame */
+               frame = (struct stackframe *)fp;
+               sp = fp;
+               fp = frame->fp;
+               pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
+                                          (unsigned long *)(fp - 8));
+       }
 }
-EXPORT_SYMBOL_GPL(save_stack_trace);
 
-void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
+#else /* !CONFIG_FRAME_POINTER */
+
+static void notrace walk_stackframe(struct task_struct *task,
+       struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg)
 {
-       unsigned long *fp, *stack_start, *stack_end;
-       unsigned long addr;
-       int skip = trace->skip;
-       int savesched;
-       int graph_idx = 0;
+       unsigned long sp, pc;
+       unsigned long *ksp;
 
-       if (tsk == current) {
-               asm volatile("mov %0, r8\n":"=r"(fp));
-               savesched = 1;
+       if (regs) {
+               sp = user_stack_pointer(regs);
+               pc = instruction_pointer(regs);
+       } else if (task == NULL || task == current) {
+               const register unsigned long current_sp __asm__ ("sp");
+               sp = current_sp;
+               pc = (unsigned long)walk_stackframe;
        } else {
-               fp = (unsigned long *)thread_saved_fp(tsk);
-               savesched = 0;
+               /* task blocked in __switch_to */
+               sp = thread_saved_sp(task);
+               pc = thread_saved_lr(task);
        }
 
-       addr = (unsigned long) fp & THREAD_MASK;
-       stack_start = (unsigned long *) addr;
-       stack_end = (unsigned long *) (addr + THREAD_SIZE);
-
-       while (fp > stack_start && fp < stack_end) {
-               unsigned long lpp, fpp;
+       if (unlikely(sp & 0x3))
+               return;
 
-               fpp = fp[0];
-               lpp = fp[1];
-               if (!__kernel_text_address(lpp))
+       ksp = (unsigned long *)sp;
+       while (!kstack_end(ksp)) {
+               if (__kernel_text_address(pc) && unlikely(fn(pc, arg)))
                        break;
-               else
-                       lpp = ftrace_graph_ret_addr(tsk, &graph_idx, lpp, NULL);
-
-               if (savesched || !in_sched_functions(lpp)) {
-                       if (skip) {
-                               skip--;
-                       } else {
-                               trace->entries[trace->nr_entries++] = lpp;
-                               if (trace->nr_entries >= trace->max_entries)
-                                       break;
-                       }
-               }
-               fp = (unsigned long *)fpp;
+               pc = (*ksp++) - 0x4;
        }
 }
+#endif /* CONFIG_FRAME_POINTER */
+
+static bool print_trace_address(unsigned long pc, void *arg)
+{
+       print_ip_sym(pc);
+       return false;
+}
+
+void show_stack(struct task_struct *task, unsigned long *sp)
+{
+       pr_cont("Call Trace:\n");
+       walk_stackframe(task, NULL, print_trace_address, NULL);
+}
+
+static bool save_wchan(unsigned long pc, void *arg)
+{
+       if (!in_sched_functions(pc)) {
+               unsigned long *p = arg;
+               *p = pc;
+               return true;
+       }
+       return false;
+}
+
+unsigned long get_wchan(struct task_struct *task)
+{
+       unsigned long pc = 0;
+
+       if (likely(task && task != current && task->state != TASK_RUNNING))
+               walk_stackframe(task, NULL, save_wchan, &pc);
+       return pc;
+}
+
+#ifdef CONFIG_STACKTRACE
+static bool __save_trace(unsigned long pc, void *arg, bool nosched)
+{
+       struct stack_trace *trace = arg;
+
+       if (unlikely(nosched && in_sched_functions(pc)))
+               return false;
+       if (unlikely(trace->skip > 0)) {
+               trace->skip--;
+               return false;
+       }
+
+       trace->entries[trace->nr_entries++] = pc;
+       return (trace->nr_entries >= trace->max_entries);
+}
+
+static bool save_trace(unsigned long pc, void *arg)
+{
+       return __save_trace(pc, arg, false);
+}
+
+/*
+ * Save stack-backtrace addresses into a stack_trace buffer.
+ */
+void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
+{
+       walk_stackframe(tsk, NULL, save_trace, trace);
+}
 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
+
+void save_stack_trace(struct stack_trace *trace)
+{
+       save_stack_trace_tsk(NULL, trace);
+}
+EXPORT_SYMBOL_GPL(save_stack_trace);
+
+#endif /* CONFIG_STACKTRACE */
index 647a239..3c9bd64 100644 (file)
@@ -7,10 +7,7 @@
 unsigned long raw_copy_from_user(void *to, const void *from,
                        unsigned long n)
 {
-       if (access_ok(from, n))
-               __copy_user_zeroing(to, from, n);
-       else
-               memset(to, 0, n);
+       ___copy_from_user(to, from, n);
        return n;
 }
 EXPORT_SYMBOL(raw_copy_from_user);
@@ -18,8 +15,7 @@ EXPORT_SYMBOL(raw_copy_from_user);
 unsigned long raw_copy_to_user(void *to, const void *from,
                        unsigned long n)
 {
-       if (access_ok(to, n))
-               __copy_user(to, from, n);
+       ___copy_to_user(to, from, n);
        return n;
 }
 EXPORT_SYMBOL(raw_copy_to_user);
index 924c541..d13b532 100644 (file)
@@ -130,7 +130,7 @@ config PPC
        select ARCH_HAS_PTE_SPECIAL
        select ARCH_HAS_MEMBARRIER_CALLBACKS
        select ARCH_HAS_SCALED_CPUTIME          if VIRT_CPU_ACCOUNTING_NATIVE && PPC_BOOK3S_64
-       select ARCH_HAS_STRICT_KERNEL_RWX       if ((PPC_BOOK3S_64 || PPC32) && !HIBERNATION)
+       select ARCH_HAS_STRICT_KERNEL_RWX       if (PPC32 && !HIBERNATION)
        select ARCH_HAS_TICK_BROADCAST          if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_HAS_UACCESS_FLUSHCACHE
        select ARCH_HAS_UACCESS_MCSAFE          if PPC64
index 34a7215..2a0a467 100644 (file)
@@ -17,9 +17,9 @@
  * updating the accessed and modified bits in the page table tree.
  */
 
-#define _PAGE_USER     0x001   /* usermode access allowed */
-#define _PAGE_RW       0x002   /* software: user write access allowed */
-#define _PAGE_PRESENT  0x004   /* software: pte contains a translation */
+#define _PAGE_PRESENT  0x001   /* software: pte contains a translation */
+#define _PAGE_HASHPTE  0x002   /* hash_page has made an HPTE for this pte */
+#define _PAGE_USER     0x004   /* usermode access allowed */
 #define _PAGE_GUARDED  0x008   /* G: prohibit speculative access */
 #define _PAGE_COHERENT 0x010   /* M: enforce memory coherence (SMP systems) */
 #define _PAGE_NO_CACHE 0x020   /* I: cache inhibit */
@@ -27,7 +27,7 @@
 #define _PAGE_DIRTY    0x080   /* C: page changed */
 #define _PAGE_ACCESSED 0x100   /* R: page referenced */
 #define _PAGE_EXEC     0x200   /* software: exec allowed */
-#define _PAGE_HASHPTE  0x400   /* hash_page has made an HPTE for this pte */
+#define _PAGE_RW       0x400   /* software: user write access allowed */
 #define _PAGE_SPECIAL  0x800   /* software: Special page */
 
 #ifdef CONFIG_PTE_64BIT
index 3c0ba22..db0a1c2 100644 (file)
@@ -75,7 +75,7 @@
 
 .macro kuap_check      current, gpr
 #ifdef CONFIG_PPC_KUAP_DEBUG
-       lwz     \gpr2, KUAP(thread)
+       lwz     \gpr, KUAP(thread)
 999:   twnei   \gpr, 0
        EMIT_BUG_ENTRY 999b, __FILE__, __LINE__, (BUGFLAG_WARNING | BUGFLAG_ONCE)
 #endif
index e0e7177..3a0db7b 100644 (file)
@@ -250,9 +250,27 @@ static inline bool arch_irqs_disabled(void)
        }                                                               \
 } while(0)
 
+static inline bool __lazy_irq_pending(u8 irq_happened)
+{
+       return !!(irq_happened & ~PACA_IRQ_HARD_DIS);
+}
+
+/*
+ * Check if a lazy IRQ is pending. Should be called with IRQs hard disabled.
+ */
 static inline bool lazy_irq_pending(void)
 {
-       return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
+       return __lazy_irq_pending(get_paca()->irq_happened);
+}
+
+/*
+ * Check if a lazy IRQ is pending, with no debugging checks.
+ * Should be called with IRQs hard disabled.
+ * For use in RI disabled code or other constrained situations.
+ */
+static inline bool lazy_irq_pending_nocheck(void)
+{
+       return __lazy_irq_pending(local_paca->irq_happened);
 }
 
 /*
index 2f500de..0969285 100644 (file)
@@ -166,13 +166,17 @@ do {                                                              \
 ({                                                             \
        long __pu_err;                                          \
        __typeof__(*(ptr)) __user *__pu_addr = (ptr);           \
+       __typeof__(*(ptr)) __pu_val = (x);                      \
+       __typeof__(size) __pu_size = (size);                    \
+                                                               \
        if (!is_kernel_addr((unsigned long)__pu_addr))          \
                might_fault();                                  \
-       __chk_user_ptr(ptr);                                    \
+       __chk_user_ptr(__pu_addr);                              \
        if (do_allow)                                                           \
-               __put_user_size((x), __pu_addr, (size), __pu_err);              \
+               __put_user_size(__pu_val, __pu_addr, __pu_size, __pu_err);      \
        else                                                                    \
-               __put_user_size_allowed((x), __pu_addr, (size), __pu_err);      \
+               __put_user_size_allowed(__pu_val, __pu_addr, __pu_size, __pu_err); \
+                                                               \
        __pu_err;                                               \
 })
 
@@ -180,9 +184,13 @@ do {                                                               \
 ({                                                                     \
        long __pu_err = -EFAULT;                                        \
        __typeof__(*(ptr)) __user *__pu_addr = (ptr);                   \
+       __typeof__(*(ptr)) __pu_val = (x);                              \
+       __typeof__(size) __pu_size = (size);                            \
+                                                                       \
        might_fault();                                                  \
-       if (access_ok(__pu_addr, size))                 \
-               __put_user_size((x), __pu_addr, (size), __pu_err);      \
+       if (access_ok(__pu_addr, __pu_size))                            \
+               __put_user_size(__pu_val, __pu_addr, __pu_size, __pu_err); \
+                                                                       \
        __pu_err;                                                       \
 })
 
@@ -190,8 +198,12 @@ do {                                                               \
 ({                                                             \
        long __pu_err;                                          \
        __typeof__(*(ptr)) __user *__pu_addr = (ptr);           \
-       __chk_user_ptr(ptr);                                    \
-       __put_user_size((x), __pu_addr, (size), __pu_err);      \
+       __typeof__(*(ptr)) __pu_val = (x);                      \
+       __typeof__(size) __pu_size = (size);                    \
+                                                               \
+       __chk_user_ptr(__pu_addr);                              \
+       __put_user_size(__pu_val, __pu_addr, __pu_size, __pu_err); \
+                                                               \
        __pu_err;                                               \
 })
 
@@ -283,15 +295,18 @@ do {                                                              \
        long __gu_err;                                          \
        __long_type(*(ptr)) __gu_val;                           \
        __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
-       __chk_user_ptr(ptr);                                    \
+       __typeof__(size) __gu_size = (size);                    \
+                                                               \
+       __chk_user_ptr(__gu_addr);                              \
        if (!is_kernel_addr((unsigned long)__gu_addr))          \
                might_fault();                                  \
        barrier_nospec();                                       \
        if (do_allow)                                                           \
-               __get_user_size(__gu_val, __gu_addr, (size), __gu_err);         \
+               __get_user_size(__gu_val, __gu_addr, __gu_size, __gu_err);      \
        else                                                                    \
-               __get_user_size_allowed(__gu_val, __gu_addr, (size), __gu_err); \
+               __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \
        (x) = (__typeof__(*(ptr)))__gu_val;                     \
+                                                               \
        __gu_err;                                               \
 })
 
@@ -300,12 +315,15 @@ do {                                                              \
        long __gu_err = -EFAULT;                                        \
        __long_type(*(ptr)) __gu_val = 0;                               \
        __typeof__(*(ptr)) __user *__gu_addr = (ptr);           \
+       __typeof__(size) __gu_size = (size);                            \
+                                                                       \
        might_fault();                                                  \
-       if (access_ok(__gu_addr, (size))) {             \
+       if (access_ok(__gu_addr, __gu_size)) {                          \
                barrier_nospec();                                       \
-               __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
+               __get_user_size(__gu_val, __gu_addr, __gu_size, __gu_err); \
        }                                                               \
        (x) = (__force __typeof__(*(ptr)))__gu_val;                             \
+                                                                       \
        __gu_err;                                                       \
 })
 
@@ -314,10 +332,13 @@ do {                                                              \
        long __gu_err;                                          \
        __long_type(*(ptr)) __gu_val;                           \
        __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
-       __chk_user_ptr(ptr);                                    \
+       __typeof__(size) __gu_size = (size);                    \
+                                                               \
+       __chk_user_ptr(__gu_addr);                              \
        barrier_nospec();                                       \
-       __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
+       __get_user_size(__gu_val, __gu_addr, __gu_size, __gu_err); \
        (x) = (__force __typeof__(*(ptr)))__gu_val;                     \
+                                                               \
        __gu_err;                                               \
 })
 
index 9a1e5d6..b3c9f15 100644 (file)
@@ -472,15 +472,17 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
 #ifdef CONFIG_PPC_BOOK3S
        /*
         * If MSR EE/RI was never enabled, IRQs not reconciled, NVGPRs not
-        * touched, AMR not set, no exit work created, then this can be used.
+        * touched, no exit work created, then this can be used.
         */
        .balign IFETCH_ALIGN_BYTES
        .globl fast_interrupt_return
 fast_interrupt_return:
 _ASM_NOKPROBE_SYMBOL(fast_interrupt_return)
+       kuap_check_amr r3, r4
        ld      r4,_MSR(r1)
        andi.   r0,r4,MSR_PR
        bne     .Lfast_user_interrupt_return
+       kuap_restore_amr r3
        andi.   r0,r4,MSR_RI
        li      r3,0 /* 0 return value, no EMULATE_STACK_STORE */
        bne+    .Lfast_kernel_interrupt_return
index 728ccb0..b0ad930 100644 (file)
@@ -971,6 +971,7 @@ EXC_COMMON_BEGIN(system_reset_common)
        ld      r10,SOFTE(r1)
        stb     r10,PACAIRQSOFTMASK(r13)
 
+       kuap_restore_amr r10
        EXCEPTION_RESTORE_REGS
        RFI_TO_USER_OR_KERNEL
 
index daaa153..97c8879 100644 (file)
@@ -348,7 +348,7 @@ BEGIN_MMU_FTR_SECTION
        andis.  r0, r5, (DSISR_BAD_FAULT_32S | DSISR_DABRMATCH)@h
 #endif
        bne     handle_page_fault_tramp_2       /* if not, try to put a PTE */
-       rlwinm  r3, r5, 32 - 24, 30, 30         /* DSISR_STORE -> _PAGE_RW */
+       rlwinm  r3, r5, 32 - 15, 21, 21         /* DSISR_STORE -> _PAGE_RW */
        bl      hash_page
        b       handle_page_fault_tramp_1
 FTR_SECTION_ELSE
@@ -497,6 +497,7 @@ InstructionTLBMiss:
        andc.   r1,r1,r0                /* check access & ~permission */
        bne-    InstructionAddressInvalid /* return if access not permitted */
        /* Convert linux-style PTE to low word of PPC-style PTE */
+       rlwimi  r0,r0,32-2,31,31        /* _PAGE_USER -> PP lsb */
        ori     r1, r1, 0xe06           /* clear out reserved bits */
        andc    r1, r0, r1              /* PP = user? 1 : 0 */
 BEGIN_FTR_SECTION
@@ -564,8 +565,9 @@ DataLoadTLBMiss:
         * we would need to update the pte atomically with lwarx/stwcx.
         */
        /* Convert linux-style PTE to low word of PPC-style PTE */
-       rlwinm  r1,r0,0,30,30           /* _PAGE_RW -> PP msb */
-       rlwimi  r0,r0,1,30,30           /* _PAGE_USER -> PP msb */
+       rlwinm  r1,r0,32-9,30,30        /* _PAGE_RW -> PP msb */
+       rlwimi  r0,r0,32-1,30,30        /* _PAGE_USER -> PP msb */
+       rlwimi  r0,r0,32-1,31,31        /* _PAGE_USER -> PP lsb */
        ori     r1,r1,0xe04             /* clear out reserved bits */
        andc    r1,r0,r1                /* PP = user? rw? 1: 3: 0 */
 BEGIN_FTR_SECTION
@@ -643,6 +645,7 @@ DataStoreTLBMiss:
         * we would need to update the pte atomically with lwarx/stwcx.
         */
        /* Convert linux-style PTE to low word of PPC-style PTE */
+       rlwimi  r0,r0,32-2,31,31        /* _PAGE_USER -> PP lsb */
        li      r1,0xe06                /* clear out reserved bits & PP msb */
        andc    r1,r0,r1                /* PP = user? 1: 0 */
 BEGIN_FTR_SECTION
index 9bb6639..2cec543 100644 (file)
@@ -344,8 +344,9 @@ _ENTRY(saved_ksp_limit)
 /* 0x0C00 - System Call Exception */
        START_EXCEPTION(0x0C00, SystemCall)
        SYSCALL_ENTRY   0xc00
+/*     Trap_0D is commented out to get more space for system call exception */
 
-       EXCEPTION(0x0D00, Trap_0D, unknown_exception, EXC_XFER_STD)
+/*     EXCEPTION(0x0D00, Trap_0D, unknown_exception, EXC_XFER_STD) */
        EXCEPTION(0x0E00, Trap_0E, unknown_exception, EXC_XFER_STD)
        EXCEPTION(0x0F00, Trap_0F, unknown_exception, EXC_XFER_STD)
 
index e341162..957abd5 100644 (file)
@@ -19,12 +19,12 @@ bool arch_ima_get_secureboot(void)
  * to be stored as an xattr or as an appended signature.
  *
  * To avoid duplicate signature verification as much as possible, the IMA
- * policy rule for module appraisal is added only if CONFIG_MODULE_SIG_FORCE
+ * policy rule for module appraisal is added only if CONFIG_MODULE_SIG
  * is not enabled.
  */
 static const char *const secure_rules[] = {
        "appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
-#ifndef CONFIG_MODULE_SIG_FORCE
+#ifndef CONFIG_MODULE_SIG
        "appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
 #endif
        NULL
@@ -50,7 +50,7 @@ static const char *const secure_and_trusted_rules[] = {
        "measure func=KEXEC_KERNEL_CHECK template=ima-modsig",
        "measure func=MODULE_CHECK template=ima-modsig",
        "appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
-#ifndef CONFIG_MODULE_SIG_FORCE
+#ifndef CONFIG_MODULE_SIG
        "appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
 #endif
        NULL
index c74295a..7b7c89c 100644 (file)
@@ -35,6 +35,8 @@ notrace long system_call_exception(long r3, long r4, long r5,
        BUG_ON(!FULL_REGS(regs));
        BUG_ON(regs->softe != IRQS_ENABLED);
 
+       kuap_check_amr();
+
        account_cpu_user_entry();
 
 #ifdef CONFIG_PPC_SPLPAR
@@ -47,8 +49,6 @@ notrace long system_call_exception(long r3, long r4, long r5,
        }
 #endif
 
-       kuap_check_amr();
-
        /*
         * This is not required for the syscall exit path, but makes the
         * stack frame look nicer. If this was initialised in the first stack
@@ -117,6 +117,8 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
        unsigned long ti_flags;
        unsigned long ret = 0;
 
+       kuap_check_amr();
+
        regs->result = r3;
 
        /* Check whether the syscall is issued inside a restartable sequence */
@@ -189,7 +191,7 @@ again:
 
        /* This pattern matches prep_irq_for_idle */
        __hard_EE_RI_disable();
-       if (unlikely(lazy_irq_pending())) {
+       if (unlikely(lazy_irq_pending_nocheck())) {
                __hard_RI_enable();
                trace_hardirqs_off();
                local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
@@ -204,8 +206,6 @@ again:
        local_paca->tm_scratch = regs->msr;
 #endif
 
-       kuap_check_amr();
-
        account_cpu_user_exit();
 
        return ret;
@@ -228,6 +228,8 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs, unsigned
        BUG_ON(!FULL_REGS(regs));
        BUG_ON(regs->softe != IRQS_ENABLED);
 
+       kuap_check_amr();
+
        local_irq_save(flags);
 
 again:
@@ -264,7 +266,7 @@ again:
 
        trace_hardirqs_on();
        __hard_EE_RI_disable();
-       if (unlikely(lazy_irq_pending())) {
+       if (unlikely(lazy_irq_pending_nocheck())) {
                __hard_RI_enable();
                trace_hardirqs_off();
                local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
@@ -292,8 +294,6 @@ again:
        local_paca->tm_scratch = regs->msr;
 #endif
 
-       kuap_check_amr();
-
        account_cpu_user_exit();
 
        return ret;
@@ -313,6 +313,8 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign
        BUG_ON(regs->msr & MSR_PR);
        BUG_ON(!FULL_REGS(regs));
 
+       kuap_check_amr();
+
        if (unlikely(*ti_flagsp & _TIF_EMULATE_STACK_STORE)) {
                clear_bits(_TIF_EMULATE_STACK_STORE, ti_flagsp);
                ret = 1;
@@ -334,7 +336,7 @@ again:
 
                trace_hardirqs_on();
                __hard_EE_RI_disable();
-               if (unlikely(lazy_irq_pending())) {
+               if (unlikely(lazy_irq_pending_nocheck())) {
                        __hard_RI_enable();
                        irq_soft_mask_set(IRQS_ALL_DISABLED);
                        trace_hardirqs_off();
index a395156..e7f8f9f 100644 (file)
@@ -218,11 +218,11 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
        blr
 
        /*
-        * invalid clock
+        * syscall fallback
         */
 99:
-       li      r3, EINVAL
-       crset   so
+       li      r0,__NR_clock_getres
+       sc
        blr
   .cfi_endproc
 V_FUNCTION_END(__kernel_clock_getres)
index 6d23608..877d880 100644 (file)
@@ -35,7 +35,7 @@ mmu_hash_lock:
 /*
  * Load a PTE into the hash table, if possible.
  * The address is in r4, and r3 contains an access flag:
- * _PAGE_RW (0x002) if a write.
+ * _PAGE_RW (0x400) if a write.
  * r9 contains the SRR1 value, from which we use the MSR_PR bit.
  * SPRG_THREAD contains the physical address of the current task's thread.
  *
@@ -69,7 +69,7 @@ _GLOBAL(hash_page)
        blt+    112f                    /* assume user more likely */
        lis     r5, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
        addi    r5 ,r5 ,(swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
-       rlwimi  r3,r9,32-14,31,31       /* MSR_PR -> _PAGE_USER */
+       rlwimi  r3,r9,32-12,29,29       /* MSR_PR -> _PAGE_USER */
 112:
 #ifndef CONFIG_PTE_64BIT
        rlwimi  r5,r4,12,20,29          /* insert top 10 bits of address */
@@ -94,7 +94,7 @@ _GLOBAL(hash_page)
 #else
        rlwimi  r8,r4,23,20,28          /* compute pte address */
 #endif
-       rlwinm  r0,r3,6,24,24           /* _PAGE_RW access -> _PAGE_DIRTY */
+       rlwinm  r0,r3,32-3,24,24        /* _PAGE_RW access -> _PAGE_DIRTY */
        ori     r0,r0,_PAGE_ACCESSED|_PAGE_HASHPTE
 
        /*
@@ -310,9 +310,11 @@ Hash_msk = (((1 << Hash_bits) - 1) * 64)
 
 _GLOBAL(create_hpte)
        /* Convert linux-style PTE (r5) to low word of PPC-style PTE (r8) */
+       rlwinm  r8,r5,32-9,30,30        /* _PAGE_RW -> PP msb */
        rlwinm  r0,r5,32-6,30,30        /* _PAGE_DIRTY -> PP msb */
-       and     r8,r5,r0                /* writable if _RW & _DIRTY */
-       rlwimi  r5,r5,1,30,30           /* _PAGE_USER -> PP msb */
+       and     r8,r8,r0                /* writable if _RW & _DIRTY */
+       rlwimi  r5,r5,32-1,30,30        /* _PAGE_USER -> PP msb */
+       rlwimi  r5,r5,32-2,31,31        /* _PAGE_USER -> PP lsb */
        ori     r8,r8,0xe04             /* clear out reserved bits */
        andc    r8,r5,r8                /* PP = user? (rw&dirty? 1: 3): 0 */
 BEGIN_FTR_SECTION
@@ -564,7 +566,7 @@ _GLOBAL(flush_hash_pages)
 33:    lwarx   r8,0,r5                 /* fetch the pte flags word */
        andi.   r0,r8,_PAGE_HASHPTE
        beq     8f                      /* done if HASHPTE is already clear */
-       rlwinm  r8,r8,0,~_PAGE_HASHPTE  /* clear HASHPTE bit */
+       rlwinm  r8,r8,0,31,29           /* clear HASHPTE bit */
        stwcx.  r8,0,r5                 /* update the pte */
        bne-    33b
 
index 74f82cf..a31e1a4 100644 (file)
@@ -54,7 +54,7 @@ config RISCV
        select GENERIC_ARCH_TOPOLOGY if SMP
        select ARCH_HAS_PTE_SPECIAL
        select ARCH_HAS_MMIOWB
-       select ARCH_HAS_DEBUG_VIRTUAL
+       select ARCH_HAS_DEBUG_VIRTUAL if MMU
        select HAVE_EBPF_JIT if MMU
        select EDAC_SUPPORT
        select ARCH_HAS_GIGANTIC_PAGE
@@ -136,6 +136,7 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
        def_bool y
 
 config SYS_SUPPORTS_HUGETLBFS
+       depends on MMU
        def_bool y
 
 config STACKTRACE_SUPPORT
index 216286d..d646332 100644 (file)
@@ -11,14 +11,15 @@ config SOC_SIFIVE
          This enables support for SiFive SoC platform hardware.
 
 config SOC_VIRT
-       bool "QEMU Virt Machine"
-       select POWER_RESET_SYSCON
-       select POWER_RESET_SYSCON_POWEROFF
-       select GOLDFISH
-       select RTC_DRV_GOLDFISH
-       select SIFIVE_PLIC
-       help
-         This enables support for QEMU Virt Machine.
+       bool "QEMU Virt Machine"
+       select POWER_RESET
+       select POWER_RESET_SYSCON
+       select POWER_RESET_SYSCON_POWEROFF
+       select GOLDFISH
+       select RTC_DRV_GOLDFISH if RTC_CLASS
+       select SIFIVE_PLIC
+       help
+         This enables support for QEMU Virt Machine.
 
 config SOC_KENDRYTE
        bool "Kendryte K210 SoC"
index a2c809d..56053c9 100644 (file)
@@ -16,6 +16,8 @@
 
 #ifndef CONFIG_MMU
 #define pgprot_noncached(x)    (x)
+#define pgprot_writecombine(x) (x)
+#define pgprot_device(x)       (x)
 #endif /* CONFIG_MMU */
 
 /* Generic IO read/write.  These perform native-endian accesses. */
index bb4091f..0b2333e 100644 (file)
@@ -9,6 +9,7 @@
  */
 #define mmiowb()       __asm__ __volatile__ ("fence o,w" : : : "memory");
 
+#include <linux/smp.h>
 #include <asm-generic/mmiowb.h>
 
 #endif /* _ASM_RISCV_MMIOWB_H */
index 0234048..062efd3 100644 (file)
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
 
+#ifdef CONFIG_RISCV_BASE_PMU
 #define RISCV_BASE_COUNTERS    2
 
 /*
  * The RISCV_MAX_COUNTERS parameter should be specified.
  */
 
-#ifdef CONFIG_RISCV_BASE_PMU
 #define RISCV_MAX_COUNTERS     2
-#endif
-
-#ifndef RISCV_MAX_COUNTERS
-#error "Please provide a valid RISCV_MAX_COUNTERS for the PMU."
-#endif
 
 /*
  * These are the indexes of bits in counteren register *minus* 1,
@@ -82,6 +77,7 @@ struct riscv_pmu {
        int             irq;
 };
 
+#endif
 #ifdef CONFIG_PERF_EVENTS
 #define perf_arch_bpf_user_pt_regs(regs) (struct user_regs_struct *)regs
 #endif
index 9c188ad..35b6003 100644 (file)
@@ -470,12 +470,15 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
 
 #else /* CONFIG_MMU */
 
+#define PAGE_SHARED            __pgprot(0)
 #define PAGE_KERNEL            __pgprot(0)
 #define swapper_pg_dir         NULL
 #define VMALLOC_START          0
 
 #define TASK_SIZE 0xffffffffUL
 
+static inline void __kernel_map_pages(struct page *page, int numpages, int enable) {}
+
 #endif /* !CONFIG_MMU */
 
 #define kern_addr_valid(addr)   (1) /* FIXME */
index 86c8308..d8bbd32 100644 (file)
@@ -43,7 +43,7 @@ obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o
 obj-$(CONFIG_FUNCTION_TRACER)  += mcount.o ftrace.o
 obj-$(CONFIG_DYNAMIC_FTRACE)   += mcount-dyn.o
 
-obj-$(CONFIG_PERF_EVENTS)      += perf_event.o
+obj-$(CONFIG_RISCV_BASE_PMU)   += perf_event.o
 obj-$(CONFIG_PERF_EVENTS)      += perf_callchain.o
 obj-$(CONFIG_HAVE_PERF_REGS)   += perf_regs.o
 obj-$(CONFIG_RISCV_SBI)                += sbi.o
index 91626d9..c835f03 100644 (file)
@@ -147,7 +147,7 @@ static int riscv_map_hw_event(u64 config)
        return riscv_pmu->hw_events[config];
 }
 
-int riscv_map_cache_decode(u64 config, unsigned int *type,
+static int riscv_map_cache_decode(u64 config, unsigned int *type,
                           unsigned int *op, unsigned int *result)
 {
        return -ENOENT;
@@ -342,7 +342,7 @@ static void riscv_pmu_del(struct perf_event *event, int flags)
 
 static DEFINE_MUTEX(pmc_reserve_mutex);
 
-irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
+static irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
 {
        return IRQ_NONE;
 }
@@ -361,7 +361,7 @@ static int reserve_pmc_hardware(void)
        return err;
 }
 
-void release_pmc_hardware(void)
+static void release_pmc_hardware(void)
 {
        mutex_lock(&pmc_reserve_mutex);
        if (riscv_pmu->irq >= 0)
@@ -464,7 +464,7 @@ static const struct of_device_id riscv_pmu_of_ids[] = {
        { /* sentinel value */ }
 };
 
-int __init init_hw_perf_events(void)
+static int __init init_hw_perf_events(void)
 {
        struct device_node *node = of_find_node_by_type(NULL, "pmu");
        const struct of_device_id *of_id;
index 610c11e..824d117 100644 (file)
@@ -22,7 +22,7 @@
 #include <asm/switch_to.h>
 #include <asm/thread_info.h>
 
-unsigned long gp_in_global __asm__("gp");
+register unsigned long gp_in_global __asm__("gp");
 
 extern asmlinkage void ret_from_fork(void);
 extern asmlinkage void ret_from_kernel_thread(void);
index 6c85487..837b9b3 100644 (file)
@@ -65,7 +65,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 
 #else /* !CONFIG_FRAME_POINTER */
 
-static void notrace walk_stackframe(struct task_struct *task,
+void notrace walk_stackframe(struct task_struct *task,
        struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg)
 {
        unsigned long sp, pc;
index 27a3341..736de6c 100644 (file)
@@ -47,7 +47,7 @@ static void setup_zero_page(void)
        memset((void *)empty_zero_page, 0, PAGE_SIZE);
 }
 
-#ifdef CONFIG_DEBUG_VM
+#if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM)
 static inline void print_mlk(char *name, unsigned long b, unsigned long t)
 {
        pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
index cd060b5..e4dc64c 100644 (file)
@@ -8,6 +8,10 @@
 #include <linux/slab.h>
 #include <asm/pci_insn.h>
 
+/* I/O size constraints */
+#define ZPCI_MAX_READ_SIZE     8
+#define ZPCI_MAX_WRITE_SIZE    128
+
 /* I/O Map */
 #define ZPCI_IOMAP_SHIFT               48
 #define ZPCI_IOMAP_ADDR_BASE           0x8000000000000000UL
@@ -140,7 +144,8 @@ static inline int zpci_memcpy_fromio(void *dst,
 
        while (n > 0) {
                size = zpci_get_max_write_size((u64 __force) src,
-                                              (u64) dst, n, 8);
+                                              (u64) dst, n,
+                                              ZPCI_MAX_READ_SIZE);
                rc = zpci_read_single(dst, src, size);
                if (rc)
                        break;
@@ -161,7 +166,8 @@ static inline int zpci_memcpy_toio(volatile void __iomem *dst,
 
        while (n > 0) {
                size = zpci_get_max_write_size((u64 __force) dst,
-                                              (u64) src, n, 128);
+                                              (u64) src, n,
+                                              ZPCI_MAX_WRITE_SIZE);
                if (size > 8) /* main path */
                        rc = zpci_write_block(dst, src, size);
                else
index 8415ae7..f9e4baa 100644 (file)
@@ -151,7 +151,7 @@ static int kexec_file_add_initrd(struct kimage *image,
                buf.mem += crashk_res.start;
        buf.memsz = buf.bufsz;
 
-       data->parm->initrd_start = buf.mem;
+       data->parm->initrd_start = data->memsz;
        data->parm->initrd_size = buf.memsz;
        data->memsz += buf.memsz;
 
index d5035de..b7182ce 100644 (file)
@@ -28,6 +28,7 @@ int arch_kexec_do_relocs(int r_type, void *loc, unsigned long val,
                break;
        case R_390_64:          /* Direct 64 bit.  */
        case R_390_GLOB_DAT:
+       case R_390_JMP_SLOT:
                *(u64 *)loc = val;
                break;
        case R_390_PC16:        /* PC relative 16 bit.  */
index f01dadd..4632d4e 100644 (file)
@@ -159,10 +159,13 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
                rste &= ~_SEGMENT_ENTRY_NOEXEC;
 
        /* Set correct table type for 2G hugepages */
-       if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
-               rste |= _REGION_ENTRY_TYPE_R3 | _REGION3_ENTRY_LARGE;
-       else
+       if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) {
+               if (likely(pte_present(pte)))
+                       rste |= _REGION3_ENTRY_LARGE;
+               rste |= _REGION_ENTRY_TYPE_R3;
+       } else if (likely(pte_present(pte)))
                rste |= _SEGMENT_ENTRY_LARGE;
+
        clear_huge_pte_skeys(mm, rste);
        pte_val(*ptep) = rste;
 }
index 7d42a87..020a2c5 100644 (file)
 #include <linux/mm.h>
 #include <linux/errno.h>
 #include <linux/pci.h>
+#include <asm/pci_io.h>
+#include <asm/pci_debug.h>
+
+static inline void zpci_err_mmio(u8 cc, u8 status, u64 offset)
+{
+       struct {
+               u64 offset;
+               u8 cc;
+               u8 status;
+       } data = {offset, cc, status};
+
+       zpci_err_hex(&data, sizeof(data));
+}
+
+static inline int __pcistb_mio_inuser(
+               void __iomem *ioaddr, const void __user *src,
+               u64 len, u8 *status)
+{
+       int cc = -ENXIO;
+
+       asm volatile (
+               "       sacf 256\n"
+               "0:     .insn   rsy,0xeb00000000d4,%[len],%[ioaddr],%[src]\n"
+               "1:     ipm     %[cc]\n"
+               "       srl     %[cc],28\n"
+               "2:     sacf 768\n"
+               EX_TABLE(0b, 2b) EX_TABLE(1b, 2b)
+               : [cc] "+d" (cc), [len] "+d" (len)
+               : [ioaddr] "a" (ioaddr), [src] "Q" (*((u8 __force *)src))
+               : "cc", "memory");
+       *status = len >> 24 & 0xff;
+       return cc;
+}
+
+static inline int __pcistg_mio_inuser(
+               void __iomem *ioaddr, const void __user *src,
+               u64 ulen, u8 *status)
+{
+       register u64 addr asm("2") = (u64 __force) ioaddr;
+       register u64 len asm("3") = ulen;
+       int cc = -ENXIO;
+       u64 val = 0;
+       u64 cnt = ulen;
+       u8 tmp;
+
+       /*
+        * copy 0 < @len <= 8 bytes from @src into the right most bytes of
+        * a register, then store it to PCI at @ioaddr while in secondary
+        * address space. pcistg then uses the user mappings.
+        */
+       asm volatile (
+               "       sacf    256\n"
+               "0:     llgc    %[tmp],0(%[src])\n"
+               "       sllg    %[val],%[val],8\n"
+               "       aghi    %[src],1\n"
+               "       ogr     %[val],%[tmp]\n"
+               "       brctg   %[cnt],0b\n"
+               "1:     .insn   rre,0xb9d40000,%[val],%[ioaddr]\n"
+               "2:     ipm     %[cc]\n"
+               "       srl     %[cc],28\n"
+               "3:     sacf    768\n"
+               EX_TABLE(0b, 3b) EX_TABLE(1b, 3b) EX_TABLE(2b, 3b)
+               :
+               [src] "+a" (src), [cnt] "+d" (cnt),
+               [val] "+d" (val), [tmp] "=d" (tmp),
+               [len] "+d" (len), [cc] "+d" (cc),
+               [ioaddr] "+a" (addr)
+               :: "cc", "memory");
+       *status = len >> 24 & 0xff;
+
+       /* did we read everything from user memory? */
+       if (!cc && cnt != 0)
+               cc = -EFAULT;
+
+       return cc;
+}
+
+static inline int __memcpy_toio_inuser(void __iomem *dst,
+                                  const void __user *src, size_t n)
+{
+       int size, rc = 0;
+       u8 status = 0;
+       mm_segment_t old_fs;
+
+       if (!src)
+               return -EINVAL;
+
+       old_fs = enable_sacf_uaccess();
+       while (n > 0) {
+               size = zpci_get_max_write_size((u64 __force) dst,
+                                              (u64 __force) src, n,
+                                              ZPCI_MAX_WRITE_SIZE);
+               if (size > 8) /* main path */
+                       rc = __pcistb_mio_inuser(dst, src, size, &status);
+               else
+                       rc = __pcistg_mio_inuser(dst, src, size, &status);
+               if (rc)
+                       break;
+               src += size;
+               dst += size;
+               n -= size;
+       }
+       disable_sacf_uaccess(old_fs);
+       if (rc)
+               zpci_err_mmio(rc, status, (__force u64) dst);
+       return rc;
+}
 
 static long get_pfn(unsigned long user_addr, unsigned long access,
                    unsigned long *pfn)
@@ -46,6 +153,20 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
 
        if (length <= 0 || PAGE_SIZE - (mmio_addr & ~PAGE_MASK) < length)
                return -EINVAL;
+
+       /*
+        * Only support read access to MIO capable devices on a MIO enabled
+        * system. Otherwise we would have to check for every address if it is
+        * a special ZPCI_ADDR and we would have to do a get_pfn() which we
+        * don't need for MIO capable devices.
+        */
+       if (static_branch_likely(&have_mio)) {
+               ret = __memcpy_toio_inuser((void  __iomem *) mmio_addr,
+                                       user_buffer,
+                                       length);
+               return ret;
+       }
+
        if (length > 64) {
                buf = kmalloc(length, GFP_KERNEL);
                if (!buf)
@@ -56,7 +177,8 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
        ret = get_pfn(mmio_addr, VM_WRITE, &pfn);
        if (ret)
                goto out;
-       io_addr = (void __iomem *)((pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK));
+       io_addr = (void __iomem *)((pfn << PAGE_SHIFT) |
+                       (mmio_addr & ~PAGE_MASK));
 
        ret = -EFAULT;
        if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE)
@@ -72,6 +194,78 @@ out:
        return ret;
 }
 
+static inline int __pcilg_mio_inuser(
+               void __user *dst, const void __iomem *ioaddr,
+               u64 ulen, u8 *status)
+{
+       register u64 addr asm("2") = (u64 __force) ioaddr;
+       register u64 len asm("3") = ulen;
+       u64 cnt = ulen;
+       int shift = ulen * 8;
+       int cc = -ENXIO;
+       u64 val, tmp;
+
+       /*
+        * read 0 < @len <= 8 bytes from the PCI memory mapped at @ioaddr (in
+        * user space) into a register using pcilg then store these bytes at
+        * user address @dst
+        */
+       asm volatile (
+               "       sacf    256\n"
+               "0:     .insn   rre,0xb9d60000,%[val],%[ioaddr]\n"
+               "1:     ipm     %[cc]\n"
+               "       srl     %[cc],28\n"
+               "       ltr     %[cc],%[cc]\n"
+               "       jne     4f\n"
+               "2:     ahi     %[shift],-8\n"
+               "       srlg    %[tmp],%[val],0(%[shift])\n"
+               "3:     stc     %[tmp],0(%[dst])\n"
+               "       aghi    %[dst],1\n"
+               "       brctg   %[cnt],2b\n"
+               "4:     sacf    768\n"
+               EX_TABLE(0b, 4b) EX_TABLE(1b, 4b) EX_TABLE(3b, 4b)
+               :
+               [cc] "+d" (cc), [val] "=d" (val), [len] "+d" (len),
+               [dst] "+a" (dst), [cnt] "+d" (cnt), [tmp] "=d" (tmp),
+               [shift] "+d" (shift)
+               :
+               [ioaddr] "a" (addr)
+               : "cc", "memory");
+
+       /* did we write everything to the user space buffer? */
+       if (!cc && cnt != 0)
+               cc = -EFAULT;
+
+       *status = len >> 24 & 0xff;
+       return cc;
+}
+
+static inline int __memcpy_fromio_inuser(void __user *dst,
+                                    const void __iomem *src,
+                                    unsigned long n)
+{
+       int size, rc = 0;
+       u8 status;
+       mm_segment_t old_fs;
+
+       old_fs = enable_sacf_uaccess();
+       while (n > 0) {
+               size = zpci_get_max_write_size((u64 __force) src,
+                                              (u64 __force) dst, n,
+                                              ZPCI_MAX_READ_SIZE);
+               rc = __pcilg_mio_inuser(dst, src, size, &status);
+               if (rc)
+                       break;
+               src += size;
+               dst += size;
+               n -= size;
+       }
+       disable_sacf_uaccess(old_fs);
+       if (rc)
+               zpci_err_mmio(rc, status, (__force u64) dst);
+       return rc;
+}
+
 SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
                void __user *, user_buffer, size_t, length)
 {
@@ -86,12 +280,27 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
 
        if (length <= 0 || PAGE_SIZE - (mmio_addr & ~PAGE_MASK) < length)
                return -EINVAL;
+
+       /*
+        * Only support write access to MIO capable devices on a MIO enabled
+        * system. Otherwise we would have to check for every address if it is
+        * a special ZPCI_ADDR and we would have to do a get_pfn() which we
+        * don't need for MIO capable devices.
+        */
+       if (static_branch_likely(&have_mio)) {
+               ret = __memcpy_fromio_inuser(
+                               user_buffer, (const void __iomem *)mmio_addr,
+                               length);
+               return ret;
+       }
+
        if (length > 64) {
                buf = kmalloc(length, GFP_KERNEL);
                if (!buf)
                        return -ENOMEM;
-       } else
+       } else {
                buf = local_buf;
+       }
 
        ret = get_pfn(mmio_addr, VM_READ, &pfn);
        if (ret)
index 91f35b2..d29d5fd 100644 (file)
@@ -17,7 +17,7 @@
 #define TRANS_TAP_LEN strlen(TRANS_TAP)
 
 #define TRANS_GRE "gre"
-#define TRANS_GRE_LEN strlen(TRANS_RAW)
+#define TRANS_GRE_LEN strlen(TRANS_GRE)
 
 #define TRANS_L2TPV3 "l2tpv3"
 #define TRANS_L2TPV3_LEN strlen(TRANS_L2TPV3)
index 7a3208c..36b33d6 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <asm-generic/xor.h>
-#include <shared/timer-internal.h>
+#include <linux/time-internal.h>
 
 /* pick an arbitrary one - measuring isn't possible with inf-cpu */
 #define XOR_SELECT_TEMPLATE(x) \
index 0a12d5a..3d91f89 100644 (file)
@@ -11,6 +11,7 @@
 #include <sysdep/ptrace_user.h>
 #include <sysdep/syscalls.h>
 #include <linux/time-internal.h>
+#include <asm/unistd.h>
 
 void handle_syscall(struct uml_pt_regs *r)
 {
index 1197b55..2d3f963 100644 (file)
@@ -68,6 +68,7 @@ config X86
        select ARCH_HAS_KCOV                    if X86_64
        select ARCH_HAS_MEM_ENCRYPT
        select ARCH_HAS_MEMBARRIER_SYNC_CORE
+       select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
        select ARCH_HAS_PMEM_API                if X86_64
        select ARCH_HAS_PTE_DEVMAP              if X86_64
        select ARCH_HAS_PTE_SPECIAL
index fd51bac..acf76b4 100644 (file)
@@ -226,10 +226,18 @@ static int hv_cpu_die(unsigned int cpu)
 
        rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
        if (re_ctrl.target_vp == hv_vp_index[cpu]) {
-               /* Reassign to some other online CPU */
+               /*
+                * Reassign reenlightenment notifications to some other online
+                * CPU or just disable the feature if there are no online CPUs
+                * left (happens on hibernation).
+                */
                new_cpu = cpumask_any_but(cpu_online_mask, cpu);
 
-               re_ctrl.target_vp = hv_vp_index[new_cpu];
+               if (new_cpu < nr_cpu_ids)
+                       re_ctrl.target_vp = hv_vp_index[new_cpu];
+               else
+                       re_ctrl.enabled = 0;
+
                wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
        }
 
@@ -293,6 +301,13 @@ static void hv_resume(void)
 
        hv_hypercall_pg = hv_hypercall_pg_saved;
        hv_hypercall_pg_saved = NULL;
+
+       /*
+        * Reenlightenment notifications are disabled by hv_cpu_die(0),
+        * reenable them here if hv_reenlightenment_cb was previously set.
+        */
+       if (hv_reenlightenment_cb)
+               set_hv_tscchange_cb(hv_reenlightenment_cb);
 }
 
 /* Note: when the ops are called, only CPU0 is online and IRQs are disabled. */
index 70b96ca..84b9449 100644 (file)
@@ -56,6 +56,12 @@ struct dyn_arch_ftrace {
 
 #ifndef __ASSEMBLY__
 
+#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
+extern void set_ftrace_ops_ro(void);
+#else
+static inline void set_ftrace_ops_ro(void) { }
+#endif
+
 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
 {
index 0dea9f1..0a6b353 100644 (file)
@@ -578,6 +578,7 @@ struct kvm_vcpu_arch {
        unsigned long cr4;
        unsigned long cr4_guest_owned_bits;
        unsigned long cr8;
+       u32 host_pkru;
        u32 pkru;
        u32 hflags;
        u64 efer;
@@ -1093,8 +1094,6 @@ struct kvm_x86_ops {
        void (*set_idt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt);
        void (*get_gdt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt);
        void (*set_gdt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt);
-       u64 (*get_dr6)(struct kvm_vcpu *vcpu);
-       void (*set_dr6)(struct kvm_vcpu *vcpu, unsigned long value);
        void (*sync_dirty_debug_regs)(struct kvm_vcpu *vcpu);
        void (*set_dr7)(struct kvm_vcpu *vcpu, unsigned long value);
        void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
@@ -1449,6 +1448,7 @@ bool kvm_rdpmc(struct kvm_vcpu *vcpu);
 
 void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr);
 void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
+void kvm_queue_exception_p(struct kvm_vcpu *vcpu, unsigned nr, unsigned long payload);
 void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr);
 void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
 void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault);
index 91e29b6..9804a79 100644 (file)
 /*
  * Initialize the stackprotector canary value.
  *
- * NOTE: this must only be called from functions that never return,
+ * NOTE: this must only be called from functions that never return
  * and it must always be inlined.
+ *
+ * In addition, it should be called from a compilation unit for which
+ * stack protector is disabled. Alternatively, the caller should not end
+ * with a function call which gets tail-call optimized as that would
+ * lead to checking a modified canary value.
  */
 static __always_inline void boot_init_stack_canary(void)
 {
index 37a0aea..b0e6417 100644 (file)
@@ -407,7 +407,8 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
 
        set_vm_flush_reset_perms(trampoline);
 
-       set_memory_ro((unsigned long)trampoline, npages);
+       if (likely(system_state != SYSTEM_BOOTING))
+               set_memory_ro((unsigned long)trampoline, npages);
        set_memory_x((unsigned long)trampoline, npages);
        return (unsigned long)trampoline;
 fail:
@@ -415,6 +416,32 @@ fail:
        return 0;
 }
 
+void set_ftrace_ops_ro(void)
+{
+       struct ftrace_ops *ops;
+       unsigned long start_offset;
+       unsigned long end_offset;
+       unsigned long npages;
+       unsigned long size;
+
+       do_for_each_ftrace_op(ops, ftrace_ops_list) {
+               if (!(ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP))
+                       continue;
+
+               if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) {
+                       start_offset = (unsigned long)ftrace_regs_caller;
+                       end_offset = (unsigned long)ftrace_regs_caller_end;
+               } else {
+                       start_offset = (unsigned long)ftrace_caller;
+                       end_offset = (unsigned long)ftrace_epilogue;
+               }
+               size = end_offset - start_offset;
+               size = size + RET_SIZE + sizeof(void *);
+               npages = DIV_ROUND_UP(size, PAGE_SIZE);
+               set_memory_ro((unsigned long)ops->trampoline, npages);
+       } while_for_each_ftrace_op(ops);
+}
+
 static unsigned long calc_trampoline_call_offset(bool save_regs)
 {
        unsigned long start_offset;
index 8c89e4d..2f24c33 100644 (file)
@@ -266,6 +266,14 @@ static void notrace start_secondary(void *unused)
 
        wmb();
        cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
+
+       /*
+        * Prevent tail call to cpu_startup_entry() because the stack protector
+        * guard has been changed a couple of function calls up, in
+        * boot_init_stack_canary() and must not be checked before tail calling
+        * another function.
+        */
+       prevent_tail_call_optimization();
 }
 
 /**
index 5b0bd85..fa79e42 100644 (file)
@@ -617,23 +617,23 @@ EXPORT_SYMBOL_GPL(unwind_next_frame);
 void __unwind_start(struct unwind_state *state, struct task_struct *task,
                    struct pt_regs *regs, unsigned long *first_frame)
 {
-       if (!orc_init)
-               goto done;
-
        memset(state, 0, sizeof(*state));
        state->task = task;
 
+       if (!orc_init)
+               goto err;
+
        /*
         * Refuse to unwind the stack of a task while it's executing on another
         * CPU.  This check is racy, but that's ok: the unwinder has other
         * checks to prevent it from going off the rails.
         */
        if (task_on_another_cpu(task))
-               goto done;
+               goto err;
 
        if (regs) {
                if (user_mode(regs))
-                       goto done;
+                       goto the_end;
 
                state->ip = regs->ip;
                state->sp = regs->sp;
@@ -666,6 +666,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
                 * generate some kind of backtrace if this happens.
                 */
                void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp);
+               state->error = true;
                if (get_stack_info(next_page, state->task, &state->stack_info,
                                   &state->stack_mask))
                        return;
@@ -691,8 +692,9 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
 
        return;
 
-done:
+err:
+       state->error = true;
+the_end:
        state->stack_info.type = STACK_TYPE_UNKNOWN;
-       return;
 }
 EXPORT_SYMBOL_GPL(__unwind_start);
index bcefa9d..54d4b98 100644 (file)
@@ -1427,7 +1427,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
         */
        kvm_make_vcpus_request_mask(kvm,
                                    KVM_REQ_TLB_FLUSH | KVM_REQUEST_NO_WAKEUP,
-                                   vcpu_mask, &hv_vcpu->tlb_flush);
+                                   NULL, vcpu_mask, &hv_vcpu->tlb_flush);
 
 ret_success:
        /* We always do full TLB flush, set rep_done = rep_cnt. */
index 90a1ca9..9a2a62e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 
 #include <asm/msr-index.h>
+#include <asm/debugreg.h>
 
 #include "kvm_emulate.h"
 #include "trace.h"
@@ -267,7 +268,7 @@ void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa,
        svm->vmcb->save.rsp = nested_vmcb->save.rsp;
        svm->vmcb->save.rip = nested_vmcb->save.rip;
        svm->vmcb->save.dr7 = nested_vmcb->save.dr7;
-       svm->vmcb->save.dr6 = nested_vmcb->save.dr6;
+       svm->vcpu.arch.dr6  = nested_vmcb->save.dr6;
        svm->vmcb->save.cpl = nested_vmcb->save.cpl;
 
        svm->nested.vmcb_msrpm = nested_vmcb->control.msrpm_base_pa & ~0x0fffULL;
@@ -482,7 +483,7 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
        nested_vmcb->save.rsp    = vmcb->save.rsp;
        nested_vmcb->save.rax    = vmcb->save.rax;
        nested_vmcb->save.dr7    = vmcb->save.dr7;
-       nested_vmcb->save.dr6    = vmcb->save.dr6;
+       nested_vmcb->save.dr6    = svm->vcpu.arch.dr6;
        nested_vmcb->save.cpl    = vmcb->save.cpl;
 
        nested_vmcb->control.int_ctl           = vmcb->control.int_ctl;
@@ -606,26 +607,45 @@ static int nested_svm_exit_handled_msr(struct vcpu_svm *svm)
 /* DB exceptions for our internal use must not cause vmexit */
 static int nested_svm_intercept_db(struct vcpu_svm *svm)
 {
-       unsigned long dr6;
+       unsigned long dr6 = svm->vmcb->save.dr6;
+
+       /* Always catch it and pass it to userspace if debugging.  */
+       if (svm->vcpu.guest_debug &
+           (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
+               return NESTED_EXIT_HOST;
 
        /* if we're not singlestepping, it's not ours */
        if (!svm->nmi_singlestep)
-               return NESTED_EXIT_DONE;
+               goto reflected_db;
 
        /* if it's not a singlestep exception, it's not ours */
-       if (kvm_get_dr(&svm->vcpu, 6, &dr6))
-               return NESTED_EXIT_DONE;
        if (!(dr6 & DR6_BS))
-               return NESTED_EXIT_DONE;
+               goto reflected_db;
 
        /* if the guest is singlestepping, it should get the vmexit */
        if (svm->nmi_singlestep_guest_rflags & X86_EFLAGS_TF) {
                disable_nmi_singlestep(svm);
-               return NESTED_EXIT_DONE;
+               goto reflected_db;
        }
 
        /* it's ours, the nested hypervisor must not see this one */
        return NESTED_EXIT_HOST;
+
+reflected_db:
+       /*
+        * Synchronize guest DR6 here just like in kvm_deliver_exception_payload;
+        * it will be moved into the nested VMCB by nested_svm_vmexit.  Once
+        * exceptions will be moved to svm_check_nested_events, all this stuff
+        * will just go away and we could just return NESTED_EXIT_HOST
+        * unconditionally.  db_interception will queue the exception, which
+        * will be processed by svm_check_nested_events if a nested vmexit is
+        * required, and we will just use kvm_deliver_exception_payload to copy
+        * the payload to DR6 before vmexit.
+        */
+       WARN_ON(svm->vcpu.arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT);
+       svm->vcpu.arch.dr6 &= ~(DR_TRAP_BITS | DR6_RTM);
+       svm->vcpu.arch.dr6 |= dr6 & ~DR6_FIXED_1;
+       return NESTED_EXIT_DONE;
 }
 
 static int nested_svm_intercept_ioio(struct vcpu_svm *svm)
@@ -682,6 +702,9 @@ static int nested_svm_intercept(struct vcpu_svm *svm)
                if (svm->nested.intercept_exceptions & excp_bits) {
                        if (exit_code == SVM_EXIT_EXCP_BASE + DB_VECTOR)
                                vmexit = nested_svm_intercept_db(svm);
+                       else if (exit_code == SVM_EXIT_EXCP_BASE + BP_VECTOR &&
+                                svm->vcpu.guest_debug & KVM_GUESTDBG_USE_SW_BP)
+                               vmexit = NESTED_EXIT_HOST;
                        else
                                vmexit = NESTED_EXIT_DONE;
                }
index 38f6aee..a862c76 100644 (file)
@@ -1672,17 +1672,14 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
        mark_dirty(svm->vmcb, VMCB_ASID);
 }
 
-static u64 svm_get_dr6(struct kvm_vcpu *vcpu)
+static void svm_set_dr6(struct vcpu_svm *svm, unsigned long value)
 {
-       return to_svm(vcpu)->vmcb->save.dr6;
-}
-
-static void svm_set_dr6(struct kvm_vcpu *vcpu, unsigned long value)
-{
-       struct vcpu_svm *svm = to_svm(vcpu);
+       struct vmcb *vmcb = svm->vmcb;
 
-       svm->vmcb->save.dr6 = value;
-       mark_dirty(svm->vmcb, VMCB_DR);
+       if (unlikely(value != vmcb->save.dr6)) {
+               vmcb->save.dr6 = value;
+               mark_dirty(vmcb, VMCB_DR);
+       }
 }
 
 static void svm_sync_dirty_debug_regs(struct kvm_vcpu *vcpu)
@@ -1693,9 +1690,12 @@ static void svm_sync_dirty_debug_regs(struct kvm_vcpu *vcpu)
        get_debugreg(vcpu->arch.db[1], 1);
        get_debugreg(vcpu->arch.db[2], 2);
        get_debugreg(vcpu->arch.db[3], 3);
-       vcpu->arch.dr6 = svm_get_dr6(vcpu);
+       /*
+        * We cannot reset svm->vmcb->save.dr6 to DR6_FIXED_1|DR6_RTM here,
+        * because db_interception might need it.  We can do it before vmentry.
+        */
+       vcpu->arch.dr6 = svm->vmcb->save.dr6;
        vcpu->arch.dr7 = svm->vmcb->save.dr7;
-
        vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_WONT_EXIT;
        set_dr_intercepts(svm);
 }
@@ -1739,7 +1739,8 @@ static int db_interception(struct vcpu_svm *svm)
        if (!(svm->vcpu.guest_debug &
              (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) &&
                !svm->nmi_singlestep) {
-               kvm_queue_exception(&svm->vcpu, DB_VECTOR);
+               u32 payload = (svm->vmcb->save.dr6 ^ DR6_RTM) & ~DR6_FIXED_1;
+               kvm_queue_exception_p(&svm->vcpu, DB_VECTOR, payload);
                return 1;
        }
 
@@ -3317,6 +3318,15 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 
        svm->vmcb->save.cr2 = vcpu->arch.cr2;
 
+       /*
+        * Run with all-zero DR6 unless needed, so that we can get the exact cause
+        * of a #DB.
+        */
+       if (unlikely(svm->vcpu.arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT))
+               svm_set_dr6(svm, vcpu->arch.dr6);
+       else
+               svm_set_dr6(svm, DR6_FIXED_1 | DR6_RTM);
+
        clgi();
        kvm_load_guest_xsave_state(vcpu);
 
@@ -3931,8 +3941,6 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
        .set_idt = svm_set_idt,
        .get_gdt = svm_get_gdt,
        .set_gdt = svm_set_gdt,
-       .get_dr6 = svm_get_dr6,
-       .set_dr6 = svm_set_dr6,
        .set_dr7 = svm_set_dr7,
        .sync_dirty_debug_regs = svm_sync_dirty_debug_regs,
        .cache_reg = svm_cache_reg,
index c2c6335..89c766f 100644 (file)
@@ -1372,7 +1372,6 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 
        vmx_vcpu_pi_load(vcpu, cpu);
 
-       vmx->host_pkru = read_pkru();
        vmx->host_debugctlmsr = get_debugctlmsr();
 }
 
@@ -4677,15 +4676,13 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
                dr6 = vmcs_readl(EXIT_QUALIFICATION);
                if (!(vcpu->guest_debug &
                      (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) {
-                       vcpu->arch.dr6 &= ~DR_TRAP_BITS;
-                       vcpu->arch.dr6 |= dr6 | DR6_RTM;
                        if (is_icebp(intr_info))
                                WARN_ON(!skip_emulated_instruction(vcpu));
 
-                       kvm_queue_exception(vcpu, DB_VECTOR);
+                       kvm_queue_exception_p(vcpu, DB_VECTOR, dr6);
                        return 1;
                }
-               kvm_run->debug.arch.dr6 = dr6 | DR6_FIXED_1;
+               kvm_run->debug.arch.dr6 = dr6 | DR6_FIXED_1 | DR6_RTM;
                kvm_run->debug.arch.dr7 = vmcs_readl(GUEST_DR7);
                /* fall through */
        case BP_VECTOR:
@@ -4929,16 +4926,14 @@ static int handle_dr(struct kvm_vcpu *vcpu)
                 * guest debugging itself.
                 */
                if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) {
-                       vcpu->run->debug.arch.dr6 = vcpu->arch.dr6;
+                       vcpu->run->debug.arch.dr6 = DR6_BD | DR6_RTM | DR6_FIXED_1;
                        vcpu->run->debug.arch.dr7 = dr7;
                        vcpu->run->debug.arch.pc = kvm_get_linear_rip(vcpu);
                        vcpu->run->debug.arch.exception = DB_VECTOR;
                        vcpu->run->exit_reason = KVM_EXIT_DEBUG;
                        return 0;
                } else {
-                       vcpu->arch.dr6 &= ~DR_TRAP_BITS;
-                       vcpu->arch.dr6 |= DR6_BD | DR6_RTM;
-                       kvm_queue_exception(vcpu, DB_VECTOR);
+                       kvm_queue_exception_p(vcpu, DB_VECTOR, DR6_BD);
                        return 1;
                }
        }
@@ -4969,15 +4964,6 @@ static int handle_dr(struct kvm_vcpu *vcpu)
        return kvm_skip_emulated_instruction(vcpu);
 }
 
-static u64 vmx_get_dr6(struct kvm_vcpu *vcpu)
-{
-       return vcpu->arch.dr6;
-}
-
-static void vmx_set_dr6(struct kvm_vcpu *vcpu, unsigned long val)
-{
-}
-
 static void vmx_sync_dirty_debug_regs(struct kvm_vcpu *vcpu)
 {
        get_debugreg(vcpu->arch.db[0], 0);
@@ -6577,11 +6563,6 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 
        kvm_load_guest_xsave_state(vcpu);
 
-       if (static_cpu_has(X86_FEATURE_PKU) &&
-           kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
-           vcpu->arch.pkru != vmx->host_pkru)
-               __write_pkru(vcpu->arch.pkru);
-
        pt_guest_enter(vmx);
 
        if (vcpu_to_pmu(vcpu)->version)
@@ -6671,18 +6652,6 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 
        pt_guest_exit(vmx);
 
-       /*
-        * eager fpu is enabled if PKEY is supported and CR4 is switched
-        * back on host, so it is safe to read guest PKRU from current
-        * XSAVE.
-        */
-       if (static_cpu_has(X86_FEATURE_PKU) &&
-           kvm_read_cr4_bits(vcpu, X86_CR4_PKE)) {
-               vcpu->arch.pkru = rdpkru();
-               if (vcpu->arch.pkru != vmx->host_pkru)
-                       __write_pkru(vmx->host_pkru);
-       }
-
        kvm_load_host_xsave_state(vcpu);
 
        vmx->nested.nested_run_pending = 0;
@@ -7740,8 +7709,6 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
        .set_idt = vmx_set_idt,
        .get_gdt = vmx_get_gdt,
        .set_gdt = vmx_set_gdt,
-       .get_dr6 = vmx_get_dr6,
-       .set_dr6 = vmx_set_dr6,
        .set_dr7 = vmx_set_dr7,
        .sync_dirty_debug_regs = vmx_sync_dirty_debug_regs,
        .cache_reg = vmx_cache_reg,
index d786c7d..c17e6eb 100644 (file)
@@ -572,11 +572,12 @@ void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr)
 }
 EXPORT_SYMBOL_GPL(kvm_requeue_exception);
 
-static void kvm_queue_exception_p(struct kvm_vcpu *vcpu, unsigned nr,
-                                 unsigned long payload)
+void kvm_queue_exception_p(struct kvm_vcpu *vcpu, unsigned nr,
+                          unsigned long payload)
 {
        kvm_multiple_exception(vcpu, nr, false, 0, true, payload, false);
 }
+EXPORT_SYMBOL_GPL(kvm_queue_exception_p);
 
 static void kvm_queue_exception_e_p(struct kvm_vcpu *vcpu, unsigned nr,
                                    u32 error_code, unsigned long payload)
@@ -836,11 +837,25 @@ void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu)
                    vcpu->arch.ia32_xss != host_xss)
                        wrmsrl(MSR_IA32_XSS, vcpu->arch.ia32_xss);
        }
+
+       if (static_cpu_has(X86_FEATURE_PKU) &&
+           (kvm_read_cr4_bits(vcpu, X86_CR4_PKE) ||
+            (vcpu->arch.xcr0 & XFEATURE_MASK_PKRU)) &&
+           vcpu->arch.pkru != vcpu->arch.host_pkru)
+               __write_pkru(vcpu->arch.pkru);
 }
 EXPORT_SYMBOL_GPL(kvm_load_guest_xsave_state);
 
 void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu)
 {
+       if (static_cpu_has(X86_FEATURE_PKU) &&
+           (kvm_read_cr4_bits(vcpu, X86_CR4_PKE) ||
+            (vcpu->arch.xcr0 & XFEATURE_MASK_PKRU))) {
+               vcpu->arch.pkru = rdpkru();
+               if (vcpu->arch.pkru != vcpu->arch.host_pkru)
+                       __write_pkru(vcpu->arch.host_pkru);
+       }
+
        if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE)) {
 
                if (vcpu->arch.xcr0 != host_xcr0)
@@ -1045,12 +1060,6 @@ static void kvm_update_dr0123(struct kvm_vcpu *vcpu)
        }
 }
 
-static void kvm_update_dr6(struct kvm_vcpu *vcpu)
-{
-       if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP))
-               kvm_x86_ops.set_dr6(vcpu, vcpu->arch.dr6);
-}
-
 static void kvm_update_dr7(struct kvm_vcpu *vcpu)
 {
        unsigned long dr7;
@@ -1090,7 +1099,6 @@ static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val)
                if (val & 0xffffffff00000000ULL)
                        return -1; /* #GP */
                vcpu->arch.dr6 = (val & DR6_VOLATILE) | kvm_dr6_fixed(vcpu);
-               kvm_update_dr6(vcpu);
                break;
        case 5:
                /* fall through */
@@ -1126,10 +1134,7 @@ int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val)
        case 4:
                /* fall through */
        case 6:
-               if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)
-                       *val = vcpu->arch.dr6;
-               else
-                       *val = kvm_x86_ops.get_dr6(vcpu);
+               *val = vcpu->arch.dr6;
                break;
        case 5:
                /* fall through */
@@ -3558,6 +3563,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 
        kvm_x86_ops.vcpu_load(vcpu, cpu);
 
+       /* Save host pkru register if supported */
+       vcpu->arch.host_pkru = read_pkru();
+
        /* Apply any externally detected TSC adjustments (due to suspend) */
        if (unlikely(vcpu->arch.tsc_offset_adjustment)) {
                adjust_tsc_offset_host(vcpu, vcpu->arch.tsc_offset_adjustment);
@@ -3751,7 +3759,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
        unsigned bank_num = mcg_cap & 0xff, bank;
 
        r = -EINVAL;
-       if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS)
+       if (!bank_num || bank_num > KVM_MAX_MCE_BANKS)
                goto out;
        if (mcg_cap & ~(kvm_mce_cap_supported | 0xff | 0xff0000))
                goto out;
@@ -4009,7 +4017,6 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
        memcpy(vcpu->arch.db, dbgregs->db, sizeof(vcpu->arch.db));
        kvm_update_dr0123(vcpu);
        vcpu->arch.dr6 = dbgregs->dr6;
-       kvm_update_dr6(vcpu);
        vcpu->arch.dr7 = dbgregs->dr7;
        kvm_update_dr7(vcpu);
 
@@ -6659,7 +6666,7 @@ static int kvm_vcpu_do_singlestep(struct kvm_vcpu *vcpu)
 
        if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) {
                kvm_run->debug.arch.dr6 = DR6_BS | DR6_FIXED_1 | DR6_RTM;
-               kvm_run->debug.arch.pc = vcpu->arch.singlestep_rip;
+               kvm_run->debug.arch.pc = kvm_get_linear_rip(vcpu);
                kvm_run->debug.arch.exception = DB_VECTOR;
                kvm_run->exit_reason = KVM_EXIT_DEBUG;
                return 0;
@@ -6719,9 +6726,7 @@ static bool kvm_vcpu_check_breakpoint(struct kvm_vcpu *vcpu, int *r)
                                           vcpu->arch.db);
 
                if (dr6 != 0) {
-                       vcpu->arch.dr6 &= ~DR_TRAP_BITS;
-                       vcpu->arch.dr6 |= dr6 | DR6_RTM;
-                       kvm_queue_exception(vcpu, DB_VECTOR);
+                       kvm_queue_exception_p(vcpu, DB_VECTOR, dr6);
                        *r = 1;
                        return true;
                }
@@ -8042,7 +8047,7 @@ void kvm_make_scan_ioapic_request_mask(struct kvm *kvm,
        zalloc_cpumask_var(&cpus, GFP_ATOMIC);
 
        kvm_make_vcpus_request_mask(kvm, KVM_REQ_SCAN_IOAPIC,
-                                   vcpu_bitmap, cpus);
+                                   NULL, vcpu_bitmap, cpus);
 
        free_cpumask_var(cpus);
 }
@@ -8072,6 +8077,7 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_update_apicv);
  */
 void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
 {
+       struct kvm_vcpu *except;
        unsigned long old, new, expected;
 
        if (!kvm_x86_ops.check_apicv_inhibit_reasons ||
@@ -8096,7 +8102,17 @@ void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
        trace_kvm_apicv_update_request(activate, bit);
        if (kvm_x86_ops.pre_update_apicv_exec_ctrl)
                kvm_x86_ops.pre_update_apicv_exec_ctrl(kvm, activate);
-       kvm_make_all_cpus_request(kvm, KVM_REQ_APICV_UPDATE);
+
+       /*
+        * Sending request to update APICV for all other vcpus,
+        * while update the calling vcpu immediately instead of
+        * waiting for another #VMEXIT to handle the request.
+        */
+       except = kvm_get_running_vcpu();
+       kvm_make_all_cpus_request_except(kvm, KVM_REQ_APICV_UPDATE,
+                                        except);
+       if (except)
+               kvm_vcpu_update_apicv(except);
 }
 EXPORT_SYMBOL_GPL(kvm_request_apicv_update);
 
@@ -8420,7 +8436,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
                WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
                kvm_x86_ops.sync_dirty_debug_regs(vcpu);
                kvm_update_dr0123(vcpu);
-               kvm_update_dr6(vcpu);
                kvm_update_dr7(vcpu);
                vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
        }
@@ -9481,7 +9496,6 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
        memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db));
        kvm_update_dr0123(vcpu);
        vcpu->arch.dr6 = DR6_INIT;
-       kvm_update_dr6(vcpu);
        vcpu->arch.dr7 = DR7_FIXED_1;
        kvm_update_dr7(vcpu);
 
index 3b289c2..8b5f73f 100644 (file)
@@ -54,6 +54,7 @@
 #include <asm/init.h>
 #include <asm/uv/uv.h>
 #include <asm/setup.h>
+#include <asm/ftrace.h>
 
 #include "mm_internal.h"
 
@@ -1291,6 +1292,8 @@ void mark_rodata_ro(void)
        all_end = roundup((unsigned long)_brk_end, PMD_SIZE);
        set_memory_nx(text_end, (all_end - text_end) >> PAGE_SHIFT);
 
+       set_ftrace_ops_ro();
+
 #ifdef CONFIG_CPA_DEBUG
        printk(KERN_INFO "Testing CPA: undo %lx-%lx\n", start, end);
        set_memory_rw(start, (end-start) >> PAGE_SHIFT);
index 8fb8a50..f2adb63 100644 (file)
@@ -93,6 +93,7 @@ asmlinkage __visible void cpu_bringup_and_idle(void)
        cpu_bringup();
        boot_init_stack_canary();
        cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
+       prevent_tail_call_optimization();
 }
 
 void xen_smp_intr_free_pv(unsigned int cpu)
index b4c0152..1af2125 100644 (file)
@@ -1994,23 +1994,35 @@ void acpi_ec_set_gpe_wake_mask(u8 action)
                acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action);
 }
 
-bool acpi_ec_other_gpes_active(void)
-{
-       return acpi_any_gpe_status_set(first_ec ? first_ec->gpe : U32_MAX);
-}
-
 bool acpi_ec_dispatch_gpe(void)
 {
        u32 ret;
 
        if (!first_ec)
+               return acpi_any_gpe_status_set(U32_MAX);
+
+       /*
+        * Report wakeup if the status bit is set for any enabled GPE other
+        * than the EC one.
+        */
+       if (acpi_any_gpe_status_set(first_ec->gpe))
+               return true;
+
+       if (ec_no_wakeup)
                return false;
 
+       /*
+        * Dispatch the EC GPE in-band, but do not report wakeup in any case
+        * to allow the caller to process events properly after that.
+        */
        ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
        if (ret == ACPI_INTERRUPT_HANDLED) {
                pm_pr_dbg("EC GPE dispatched\n");
-               return true;
+
+               /* Flush the event and query workqueues. */
+               acpi_ec_flush_work();
        }
+
        return false;
 }
 #endif /* CONFIG_PM_SLEEP */
index e387517..43411a7 100644 (file)
@@ -202,7 +202,6 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
 
 #ifdef CONFIG_PM_SLEEP
 void acpi_ec_flush_work(void);
-bool acpi_ec_other_gpes_active(void);
 bool acpi_ec_dispatch_gpe(void);
 #endif
 
index 4edc8a3..fd9d4e8 100644 (file)
@@ -980,13 +980,6 @@ static int acpi_s2idle_prepare_late(void)
        return 0;
 }
 
-static void acpi_s2idle_sync(void)
-{
-       /* The EC driver uses special workqueues that need to be flushed. */
-       acpi_ec_flush_work();
-       acpi_os_wait_events_complete(); /* synchronize Notify handling */
-}
-
 static bool acpi_s2idle_wake(void)
 {
        if (!acpi_sci_irq_valid())
@@ -1013,22 +1006,12 @@ static bool acpi_s2idle_wake(void)
                if (acpi_check_wakeup_handlers())
                        return true;
 
-               /*
-                * If the status bit is set for any enabled GPE other than the
-                * EC one, the wakeup is regarded as a genuine one.
-                */
-               if (acpi_ec_other_gpes_active())
+               /* Check non-EC GPE wakeups and dispatch the EC GPE. */
+               if (acpi_ec_dispatch_gpe())
                        return true;
 
                /*
-                * If the EC GPE status bit has not been set, the wakeup is
-                * regarded as a spurious one.
-                */
-               if (!acpi_ec_dispatch_gpe())
-                       return false;
-
-               /*
-                * Cancel the wakeup and process all pending events in case
+                * Cancel the SCI wakeup and process all pending events in case
                 * there are any wakeup ones in there.
                 *
                 * Note that if any non-EC GPEs are active at this point, the
@@ -1036,8 +1019,7 @@ static bool acpi_s2idle_wake(void)
                 * should be missed by canceling the wakeup here.
                 */
                pm_system_cancel_wakeup();
-
-               acpi_s2idle_sync();
+               acpi_os_wait_events_complete();
 
                /*
                 * The SCI is in the "suspended" state now and it cannot produce
@@ -1070,7 +1052,8 @@ static void acpi_s2idle_restore(void)
         * of GPEs.
         */
        acpi_os_wait_events_complete(); /* synchronize GPE processing */
-       acpi_s2idle_sync();
+       acpi_ec_flush_work(); /* flush the EC driver's workqueues */
+       acpi_os_wait_events_complete(); /* synchronize Notify handling */
 
        s2idle_wakeup = false;
 
index 8efd877..ce9e336 100644 (file)
@@ -1535,6 +1535,13 @@ static void null_config_discard(struct nullb *nullb)
 {
        if (nullb->dev->discard == false)
                return;
+
+       if (nullb->dev->zoned) {
+               nullb->dev->discard = false;
+               pr_info("discard option is ignored in zoned mode\n");
+               return;
+       }
+
        nullb->q->limits.discard_granularity = nullb->dev->blocksize;
        nullb->q->limits.discard_alignment = nullb->dev->blocksize;
        blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
index 9e4bcda..ed5458f 100644 (file)
@@ -23,6 +23,10 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
                pr_err("zone_size must be power-of-two\n");
                return -EINVAL;
        }
+       if (dev->zone_size > dev->size) {
+               pr_err("Zone size larger than device capacity\n");
+               return -EINVAL;
+       }
 
        dev->zone_size_sects = dev->zone_size << ZONE_SIZE_SHIFT;
        dev->nr_zones = dev_size >>
index b7145f3..2704470 100644 (file)
@@ -1947,8 +1947,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
        if (adev->type != &i2c_adapter_type)
                return 0;
 
-       addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-                                                &addr_info->binfo);
+       addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+                                                       &addr_info->binfo);
 
        if (!addr_info->adapter_name)
                return 1; /* Only try the first I2C adapter by default. */
index 39c59f0..2dfb30b 100644 (file)
@@ -3519,6 +3519,9 @@ static int __clk_core_init(struct clk_core *core)
 out:
        clk_pm_runtime_put(core);
 unlock:
+       if (ret)
+               hlist_del_init(&core->child_node);
+
        clk_prepare_unlock();
 
        if (!ret)
index d17cfb7..d7243c0 100644 (file)
@@ -156,8 +156,6 @@ PNAME(mux_i2s_out_p)                = { "i2s1_pre", "xin12m" };
 PNAME(mux_i2s2_p)              = { "i2s2_src", "i2s2_frac", "xin12m" };
 PNAME(mux_sclk_spdif_p)                = { "sclk_spdif_src", "spdif_frac", "xin12m" };
 
-PNAME(mux_aclk_gpu_pre_p)      = { "cpll_gpu", "gpll_gpu", "hdmiphy_gpu", "usb480m_gpu" };
-
 PNAME(mux_uart0_p)             = { "uart0_src", "uart0_frac", "xin24m" };
 PNAME(mux_uart1_p)             = { "uart1_src", "uart1_frac", "xin24m" };
 PNAME(mux_uart2_p)             = { "uart2_src", "uart2_frac", "xin24m" };
@@ -468,16 +466,9 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = {
                        RK2928_CLKSEL_CON(24), 6, 10, DFLAGS,
                        RK2928_CLKGATE_CON(2), 8, GFLAGS),
 
-       GATE(0, "cpll_gpu", "cpll", 0,
-                       RK2928_CLKGATE_CON(3), 13, GFLAGS),
-       GATE(0, "gpll_gpu", "gpll", 0,
-                       RK2928_CLKGATE_CON(3), 13, GFLAGS),
-       GATE(0, "hdmiphy_gpu", "hdmiphy", 0,
-                       RK2928_CLKGATE_CON(3), 13, GFLAGS),
-       GATE(0, "usb480m_gpu", "usb480m", 0,
+       COMPOSITE(0, "aclk_gpu_pre", mux_pll_src_4plls_p, 0,
+                       RK2928_CLKSEL_CON(34), 5, 2, MFLAGS, 0, 5, DFLAGS,
                        RK2928_CLKGATE_CON(3), 13, GFLAGS),
-       COMPOSITE_NOGATE(0, "aclk_gpu_pre", mux_aclk_gpu_pre_p, 0,
-                       RK2928_CLKSEL_CON(34), 5, 2, MFLAGS, 0, 5, DFLAGS),
 
        COMPOSITE(SCLK_SPI0, "sclk_spi0", mux_pll_src_2plls_p, 0,
                        RK2928_CLKSEL_CON(25), 8, 1, MFLAGS, 0, 7, DFLAGS,
@@ -582,8 +573,8 @@ static struct rockchip_clk_branch rk3228_clk_branches[] __initdata = {
        GATE(0, "pclk_peri_noc", "pclk_peri", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(12), 2, GFLAGS),
 
        /* PD_GPU */
-       GATE(ACLK_GPU, "aclk_gpu", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(13), 14, GFLAGS),
-       GATE(0, "aclk_gpu_noc", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(13), 15, GFLAGS),
+       GATE(ACLK_GPU, "aclk_gpu", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(7), 14, GFLAGS),
+       GATE(0, "aclk_gpu_noc", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(7), 15, GFLAGS),
 
        /* PD_BUS */
        GATE(0, "sclk_initmem_mbist", "aclk_cpu", 0, RK2928_CLKGATE_CON(8), 1, GFLAGS),
index 64e229d..e931319 100644 (file)
@@ -1292,7 +1292,7 @@ static struct tegra_clk_init_table common_init_table[] __initdata = {
        { TEGRA124_CLK_UARTB, TEGRA124_CLK_PLL_P, 408000000, 0 },
        { TEGRA124_CLK_UARTC, TEGRA124_CLK_PLL_P, 408000000, 0 },
        { TEGRA124_CLK_UARTD, TEGRA124_CLK_PLL_P, 408000000, 0 },
-       { TEGRA124_CLK_PLL_A, TEGRA124_CLK_CLK_MAX, 564480000, 0 },
+       { TEGRA124_CLK_PLL_A, TEGRA124_CLK_CLK_MAX, 282240000, 0 },
        { TEGRA124_CLK_PLL_A_OUT0, TEGRA124_CLK_CLK_MAX, 11289600, 0 },
        { TEGRA124_CLK_I2S0, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0 },
        { TEGRA124_CLK_I2S1, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0 },
index e001b9b..7dc30dd 100644 (file)
@@ -212,7 +212,7 @@ static const struct omap_clkctrl_reg_data am3_mpu_clkctrl_regs[] __initconst = {
 };
 
 static const struct omap_clkctrl_reg_data am3_l4_rtc_clkctrl_regs[] __initconst = {
-       { AM3_L4_RTC_RTC_CLKCTRL, NULL, CLKF_SW_SUP, "clk_32768_ck" },
+       { AM3_L4_RTC_RTC_CLKCTRL, NULL, CLKF_SW_SUP, "clk-24mhz-clkctrl:0000:0" },
        { 0 },
 };
 
index 0622660..864c484 100644 (file)
@@ -255,24 +255,53 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec,
        return entry->clk;
 }
 
+/* Get clkctrl clock base name based on clkctrl_name or dts node */
+static const char * __init clkctrl_get_clock_name(struct device_node *np,
+                                                 const char *clkctrl_name,
+                                                 int offset, int index,
+                                                 bool legacy_naming)
+{
+       char *clock_name;
+
+       /* l4per-clkctrl:1234:0 style naming based on clkctrl_name */
+       if (clkctrl_name && !legacy_naming) {
+               clock_name = kasprintf(GFP_KERNEL, "%s-clkctrl:%04x:%d",
+                                      clkctrl_name, offset, index);
+               strreplace(clock_name, '_', '-');
+
+               return clock_name;
+       }
+
+       /* l4per:1234:0 old style naming based on clkctrl_name */
+       if (clkctrl_name)
+               return kasprintf(GFP_KERNEL, "%s_cm:clk:%04x:%d",
+                                clkctrl_name, offset, index);
+
+       /* l4per_cm:1234:0 old style naming based on parent node name */
+       if (legacy_naming)
+               return kasprintf(GFP_KERNEL, "%pOFn:clk:%04x:%d",
+                                np->parent, offset, index);
+
+       /* l4per-clkctrl:1234:0 style naming based on node name */
+       return kasprintf(GFP_KERNEL, "%pOFn:%04x:%d", np, offset, index);
+}
+
 static int __init
 _ti_clkctrl_clk_register(struct omap_clkctrl_provider *provider,
                         struct device_node *node, struct clk_hw *clk_hw,
                         u16 offset, u8 bit, const char * const *parents,
-                        int num_parents, const struct clk_ops *ops)
+                        int num_parents, const struct clk_ops *ops,
+                        const char *clkctrl_name)
 {
        struct clk_init_data init = { NULL };
        struct clk *clk;
        struct omap_clkctrl_clk *clkctrl_clk;
        int ret = 0;
 
-       if (ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT)
-               init.name = kasprintf(GFP_KERNEL, "%pOFn:%pOFn:%04x:%d",
-                                     node->parent, node, offset,
-                                     bit);
-       else
-               init.name = kasprintf(GFP_KERNEL, "%pOFn:%04x:%d", node,
-                                     offset, bit);
+       init.name = clkctrl_get_clock_name(node, clkctrl_name, offset, bit,
+                                          ti_clk_get_features()->flags &
+                                          TI_CLK_CLKCTRL_COMPAT);
+
        clkctrl_clk = kzalloc(sizeof(*clkctrl_clk), GFP_KERNEL);
        if (!init.name || !clkctrl_clk) {
                ret = -ENOMEM;
@@ -309,7 +338,7 @@ static void __init
 _ti_clkctrl_setup_gate(struct omap_clkctrl_provider *provider,
                       struct device_node *node, u16 offset,
                       const struct omap_clkctrl_bit_data *data,
-                      void __iomem *reg)
+                      void __iomem *reg, const char *clkctrl_name)
 {
        struct clk_hw_omap *clk_hw;
 
@@ -322,7 +351,7 @@ _ti_clkctrl_setup_gate(struct omap_clkctrl_provider *provider,
 
        if (_ti_clkctrl_clk_register(provider, node, &clk_hw->hw, offset,
                                     data->bit, data->parents, 1,
-                                    &omap_gate_clk_ops))
+                                    &omap_gate_clk_ops, clkctrl_name))
                kfree(clk_hw);
 }
 
@@ -330,7 +359,7 @@ static void __init
 _ti_clkctrl_setup_mux(struct omap_clkctrl_provider *provider,
                      struct device_node *node, u16 offset,
                      const struct omap_clkctrl_bit_data *data,
-                     void __iomem *reg)
+                     void __iomem *reg, const char *clkctrl_name)
 {
        struct clk_omap_mux *mux;
        int num_parents = 0;
@@ -357,7 +386,7 @@ _ti_clkctrl_setup_mux(struct omap_clkctrl_provider *provider,
 
        if (_ti_clkctrl_clk_register(provider, node, &mux->hw, offset,
                                     data->bit, data->parents, num_parents,
-                                    &ti_clk_mux_ops))
+                                    &ti_clk_mux_ops, clkctrl_name))
                kfree(mux);
 }
 
@@ -365,7 +394,7 @@ static void __init
 _ti_clkctrl_setup_div(struct omap_clkctrl_provider *provider,
                      struct device_node *node, u16 offset,
                      const struct omap_clkctrl_bit_data *data,
-                     void __iomem *reg)
+                     void __iomem *reg, const char *clkctrl_name)
 {
        struct clk_omap_divider *div;
        const struct omap_clkctrl_div_data *div_data = data->data;
@@ -393,7 +422,7 @@ _ti_clkctrl_setup_div(struct omap_clkctrl_provider *provider,
 
        if (_ti_clkctrl_clk_register(provider, node, &div->hw, offset,
                                     data->bit, data->parents, 1,
-                                    &ti_clk_divider_ops))
+                                    &ti_clk_divider_ops, clkctrl_name))
                kfree(div);
 }
 
@@ -401,7 +430,7 @@ static void __init
 _ti_clkctrl_setup_subclks(struct omap_clkctrl_provider *provider,
                          struct device_node *node,
                          const struct omap_clkctrl_reg_data *data,
-                         void __iomem *reg)
+                         void __iomem *reg, const char *clkctrl_name)
 {
        const struct omap_clkctrl_bit_data *bits = data->bit_data;
 
@@ -412,17 +441,17 @@ _ti_clkctrl_setup_subclks(struct omap_clkctrl_provider *provider,
                switch (bits->type) {
                case TI_CLK_GATE:
                        _ti_clkctrl_setup_gate(provider, node, data->offset,
-                                              bits, reg);
+                                              bits, reg, clkctrl_name);
                        break;
 
                case TI_CLK_DIVIDER:
                        _ti_clkctrl_setup_div(provider, node, data->offset,
-                                             bits, reg);
+                                             bits, reg, clkctrl_name);
                        break;
 
                case TI_CLK_MUX:
                        _ti_clkctrl_setup_mux(provider, node, data->offset,
-                                             bits, reg);
+                                             bits, reg, clkctrl_name);
                        break;
 
                default:
@@ -461,42 +490,10 @@ static char * __init clkctrl_get_name(struct device_node *np)
                        return name;
                }
        }
-       of_node_put(np);
 
        return NULL;
 }
 
-/* Get clkctrl clock base name based on clkctrl_name or dts node */
-static const char * __init clkctrl_get_clock_name(struct device_node *np,
-                                                 const char *clkctrl_name,
-                                                 int offset, int index,
-                                                 bool legacy_naming)
-{
-       char *clock_name;
-
-       /* l4per-clkctrl:1234:0 style naming based on clkctrl_name */
-       if (clkctrl_name && !legacy_naming) {
-               clock_name = kasprintf(GFP_KERNEL, "%s-clkctrl:%04x:%d",
-                                      clkctrl_name, offset, index);
-               strreplace(clock_name, '_', '-');
-
-               return clock_name;
-       }
-
-       /* l4per:1234:0 old style naming based on clkctrl_name */
-       if (clkctrl_name)
-               return kasprintf(GFP_KERNEL, "%s_cm:clk:%04x:%d",
-                                clkctrl_name, offset, index);
-
-       /* l4per_cm:1234:0 old style naming based on parent node name */
-       if (legacy_naming)
-               return kasprintf(GFP_KERNEL, "%pOFn:clk:%04x:%d",
-                                np->parent, offset, index);
-
-       /* l4per-clkctrl:1234:0 style naming based on node name */
-       return kasprintf(GFP_KERNEL, "%pOFn:%04x:%d", np, offset, index);
-}
-
 static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
 {
        struct omap_clkctrl_provider *provider;
@@ -664,7 +661,7 @@ clkdm_found:
                hw->enable_reg.ptr = provider->base + reg_data->offset;
 
                _ti_clkctrl_setup_subclks(provider, node, reg_data,
-                                         hw->enable_reg.ptr);
+                                         hw->enable_reg.ptr, clkctrl_name);
 
                if (reg_data->flags & CLKF_SW_SUP)
                        hw->enable_bit = MODULEMODE_SWCTRL;
index b05da85..f9f4bab 100644 (file)
@@ -206,6 +206,7 @@ static int integrator_impd1_clk_spawn(struct device *dev,
                return -ENODEV;
        }
 
+       of_property_read_string(np, "clock-output-names", &name);
        parent_name = of_clk_get_parent_name(np, 0);
        clk = icst_clk_setup(NULL, desc, name, parent_name, map,
                             ICST_INTEGRATOR_IM_PD1);
index 364dd34..0425984 100644 (file)
@@ -1166,10 +1166,11 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
                mutex_unlock(&info->lock);
                return ret;
        } else if (dmatest_run) {
-               if (is_threaded_test_pending(info))
-                       start_threaded_tests(info);
-               else
-                       pr_info("Could not start test, no channels configured\n");
+               if (!is_threaded_test_pending(info)) {
+                       pr_info("No channels configured, continue with any\n");
+                       add_threaded_test(info);
+               }
+               start_threaded_tests(info);
        } else {
                stop_threaded_test(info);
        }
index f6f49f0..8d79a87 100644 (file)
@@ -62,6 +62,13 @@ int idxd_unmask_msix_vector(struct idxd_device *idxd, int vec_id)
        perm.ignore = 0;
        iowrite32(perm.bits, idxd->reg_base + offset);
 
+       /*
+        * A readback from the device ensures that any previously generated
+        * completion record writes are visible to software based on PCI
+        * ordering rules.
+        */
+       perm.bits = ioread32(idxd->reg_base + offset);
+
        return 0;
 }
 
index d6fcd2e..6510791 100644 (file)
@@ -173,6 +173,7 @@ static int irq_process_pending_llist(struct idxd_irq_entry *irq_entry,
        struct llist_node *head;
        int queued = 0;
 
+       *processed = 0;
        head = llist_del_all(&irq_entry->pending_llist);
        if (!head)
                return 0;
@@ -197,6 +198,7 @@ static int irq_process_work_list(struct idxd_irq_entry *irq_entry,
        struct list_head *node, *next;
        int queued = 0;
 
+       *processed = 0;
        if (list_empty(&irq_entry->work_list))
                return 0;
 
@@ -218,10 +220,9 @@ static int irq_process_work_list(struct idxd_irq_entry *irq_entry,
        return queued;
 }
 
-irqreturn_t idxd_wq_thread(int irq, void *data)
+static int idxd_desc_process(struct idxd_irq_entry *irq_entry)
 {
-       struct idxd_irq_entry *irq_entry = data;
-       int rc, processed = 0, retry = 0;
+       int rc, processed, total = 0;
 
        /*
         * There are two lists we are processing. The pending_llist is where
@@ -244,15 +245,26 @@ irqreturn_t idxd_wq_thread(int irq, void *data)
         */
        do {
                rc = irq_process_work_list(irq_entry, &processed);
-               if (rc != 0) {
-                       retry++;
+               total += processed;
+               if (rc != 0)
                        continue;
-               }
 
                rc = irq_process_pending_llist(irq_entry, &processed);
-       } while (rc != 0 && retry != 10);
+               total += processed;
+       } while (rc != 0);
+
+       return total;
+}
+
+irqreturn_t idxd_wq_thread(int irq, void *data)
+{
+       struct idxd_irq_entry *irq_entry = data;
+       int processed;
 
+       processed = idxd_desc_process(irq_entry);
        idxd_unmask_msix_vector(irq_entry->idxd, irq_entry->id);
+       /* catch anything unprocessed after unmasking */
+       processed += idxd_desc_process(irq_entry);
 
        if (processed == 0)
                return IRQ_NONE;
index c683051..66ef70b 100644 (file)
@@ -175,13 +175,11 @@ struct owl_dma_txd {
  * @id: physical index to this channel
  * @base: virtual memory base for the dma channel
  * @vchan: the virtual channel currently being served by this physical channel
- * @lock: a lock to use when altering an instance of this struct
  */
 struct owl_dma_pchan {
        u32                     id;
        void __iomem            *base;
        struct owl_dma_vchan    *vchan;
-       spinlock_t              lock;
 };
 
 /**
@@ -437,14 +435,14 @@ static struct owl_dma_pchan *owl_dma_get_pchan(struct owl_dma *od,
        for (i = 0; i < od->nr_pchans; i++) {
                pchan = &od->pchans[i];
 
-               spin_lock_irqsave(&pchan->lock, flags);
+               spin_lock_irqsave(&od->lock, flags);
                if (!pchan->vchan) {
                        pchan->vchan = vchan;
-                       spin_unlock_irqrestore(&pchan->lock, flags);
+                       spin_unlock_irqrestore(&od->lock, flags);
                        break;
                }
 
-               spin_unlock_irqrestore(&pchan->lock, flags);
+               spin_unlock_irqrestore(&od->lock, flags);
        }
 
        return pchan;
index c4ce5df..db58d7e 100644 (file)
@@ -900,7 +900,7 @@ static int tegra_adma_probe(struct platform_device *pdev)
        ret = dma_async_device_register(&tdma->dma_dev);
        if (ret < 0) {
                dev_err(&pdev->dev, "ADMA registration failed: %d\n", ret);
-               goto irq_dispose;
+               goto rpm_put;
        }
 
        ret = of_dma_controller_register(pdev->dev.of_node,
index a9c0251..a90e154 100644 (file)
@@ -2156,7 +2156,8 @@ udma_prep_slave_sg_tr(struct udma_chan *uc, struct scatterlist *sgl,
                d->residue += sg_dma_len(sgent);
        }
 
-       cppi5_tr_csf_set(&tr_req[tr_idx - 1].flags, CPPI5_TR_CSF_EOP);
+       cppi5_tr_csf_set(&tr_req[tr_idx - 1].flags,
+                        CPPI5_TR_CSF_SUPR_EVT | CPPI5_TR_CSF_EOP);
 
        return d;
 }
@@ -2733,7 +2734,8 @@ udma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
                tr_req[1].dicnt3 = 1;
        }
 
-       cppi5_tr_csf_set(&tr_req[num_tr - 1].flags, CPPI5_TR_CSF_EOP);
+       cppi5_tr_csf_set(&tr_req[num_tr - 1].flags,
+                        CPPI5_TR_CSF_SUPR_EVT | CPPI5_TR_CSF_EOP);
 
        if (uc->config.metadata_size)
                d->vd.tx.metadata_ops = &metadata_ops;
index d47749a..ff25369 100644 (file)
@@ -434,6 +434,7 @@ static void zynqmp_dma_free_descriptor(struct zynqmp_dma_chan *chan,
        struct zynqmp_dma_desc_sw *child, *next;
 
        chan->desc_free_cnt++;
+       list_del(&sdesc->node);
        list_add_tail(&sdesc->node, &chan->free_list);
        list_for_each_entry_safe(child, next, &sdesc->tx_list, node) {
                chan->desc_free_cnt++;
@@ -608,8 +609,6 @@ static void zynqmp_dma_chan_desc_cleanup(struct zynqmp_dma_chan *chan)
                dma_async_tx_callback callback;
                void *callback_param;
 
-               list_del(&desc->node);
-
                callback = desc->async_tx.callback;
                callback_param = desc->async_tx.callback_param;
                if (callback) {
index 5638b4e..4269ea9 100644 (file)
@@ -531,7 +531,7 @@ static int pca953x_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
 {
        struct pca953x_chip *chip = gpiochip_get_data(gc);
 
-       switch (config) {
+       switch (pinconf_to_config_param(config)) {
        case PIN_CONFIG_BIAS_PULL_UP:
        case PIN_CONFIG_BIAS_PULL_DOWN:
                return pca953x_gpio_set_pull_up_down(chip, offset, config);
index acb99ef..8656815 100644 (file)
@@ -368,6 +368,7 @@ static void tegra_gpio_irq_shutdown(struct irq_data *d)
        struct tegra_gpio_info *tgi = bank->tgi;
        unsigned int gpio = d->hwirq;
 
+       tegra_gpio_irq_mask(d);
        gpiochip_unlock_as_irq(&tgi->gc, gpio);
 }
 
index 40f2d7f..182136d 100644 (file)
@@ -1158,8 +1158,19 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
                                  struct gpioline_info *info)
 {
        struct gpio_chip *gc = desc->gdev->chip;
+       bool ok_for_pinctrl;
        unsigned long flags;
 
+       /*
+        * This function takes a mutex so we must check this before taking
+        * the spinlock.
+        *
+        * FIXME: find a non-racy way to retrieve this information. Maybe a
+        * lock common to both frameworks?
+        */
+       ok_for_pinctrl =
+               pinctrl_gpio_can_use_line(gc->base + info->line_offset);
+
        spin_lock_irqsave(&gpio_lock, flags);
 
        if (desc->name) {
@@ -1186,7 +1197,7 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
            test_bit(FLAG_USED_AS_IRQ, &desc->flags) ||
            test_bit(FLAG_EXPORT, &desc->flags) ||
            test_bit(FLAG_SYSFS, &desc->flags) ||
-           !pinctrl_gpio_can_use_line(gc->base + info->line_offset))
+           !ok_for_pinctrl)
                info->flags |= GPIOLINE_FLAG_KERNEL;
        if (test_bit(FLAG_IS_OUT, &desc->flags))
                info->flags |= GPIOLINE_FLAG_IS_OUT;
@@ -1227,6 +1238,7 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        void __user *ip = (void __user *)arg;
        struct gpio_desc *desc;
        __u32 offset;
+       int hwgpio;
 
        /* We fail any subsequent ioctl():s when the chip is gone */
        if (!gc)
@@ -1259,13 +1271,19 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                if (IS_ERR(desc))
                        return PTR_ERR(desc);
 
+               hwgpio = gpio_chip_hwgpio(desc);
+
+               if (cmd == GPIO_GET_LINEINFO_WATCH_IOCTL &&
+                   test_bit(hwgpio, priv->watched_lines))
+                       return -EBUSY;
+
                gpio_desc_to_lineinfo(desc, &lineinfo);
 
                if (copy_to_user(ip, &lineinfo, sizeof(lineinfo)))
                        return -EFAULT;
 
                if (cmd == GPIO_GET_LINEINFO_WATCH_IOCTL)
-                       set_bit(gpio_chip_hwgpio(desc), priv->watched_lines);
+                       set_bit(hwgpio, priv->watched_lines);
 
                return 0;
        } else if (cmd == GPIO_GET_LINEHANDLE_IOCTL) {
@@ -1280,7 +1298,12 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                if (IS_ERR(desc))
                        return PTR_ERR(desc);
 
-               clear_bit(gpio_chip_hwgpio(desc), priv->watched_lines);
+               hwgpio = gpio_chip_hwgpio(desc);
+
+               if (!test_bit(hwgpio, priv->watched_lines))
+                       return -EBUSY;
+
+               clear_bit(hwgpio, priv->watched_lines);
                return 0;
        }
        return -EINVAL;
@@ -5289,8 +5312,9 @@ static int __init gpiolib_dev_init(void)
        gpiolib_initialized = true;
        gpiochip_setup_devs();
 
-       if (IS_ENABLED(CONFIG_OF_DYNAMIC))
-               WARN_ON(of_reconfig_notifier_register(&gpio_of_notifier));
+#if IS_ENABLED(CONFIG_OF_DYNAMIC) && IS_ENABLED(CONFIG_OF_GPIO)
+       WARN_ON(of_reconfig_notifier_register(&gpio_of_notifier));
+#endif /* CONFIG_OF_DYNAMIC && CONFIG_OF_GPIO */
 
        return ret;
 }
index 2992a49..8ac1581 100644 (file)
@@ -945,6 +945,7 @@ struct amdgpu_device {
 
        /* s3/s4 mask */
        bool                            in_suspend;
+       bool                            in_hibernate;
 
        /* record last mm index being written through WREG32*/
        unsigned long last_mm_index;
index 9dff792..6a5b91d 100644 (file)
@@ -1343,7 +1343,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
        }
 
        /* Free the BO*/
-       amdgpu_bo_unref(&mem->bo);
+       drm_gem_object_put_unlocked(&mem->bo->tbo.base);
        mutex_destroy(&mem->lock);
        kfree(mem);
 
@@ -1688,7 +1688,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd,
                | KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE
                | KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE;
 
-       (*mem)->bo = amdgpu_bo_ref(bo);
+       drm_gem_object_get(&bo->tbo.base);
+       (*mem)->bo = bo;
        (*mem)->va = va;
        (*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
                AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
index 466bfe5..a735d79 100644 (file)
@@ -1181,7 +1181,9 @@ static int amdgpu_pmops_freeze(struct device *dev)
        struct amdgpu_device *adev = drm_dev->dev_private;
        int r;
 
+       adev->in_hibernate = true;
        r = amdgpu_device_suspend(drm_dev, true);
+       adev->in_hibernate = false;
        if (r)
                return r;
        return amdgpu_asic_reset(adev);
index 9ae7b61..25ddb48 100644 (file)
@@ -133,8 +133,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        u32 cpp;
        u64 flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
                               AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS     |
-                              AMDGPU_GEM_CREATE_VRAM_CLEARED        |
-                              AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+                              AMDGPU_GEM_CREATE_VRAM_CLEARED;
 
        info = drm_get_format_info(adev->ddev, mode_cmd);
        cpp = info->cpp[0];
index f92c158..0e0daf0 100644 (file)
@@ -4273,7 +4273,7 @@ static int gfx_v10_0_update_gfx_clock_gating(struct amdgpu_device *adev,
                /* ===  CGCG /CGLS for GFX 3D Only === */
                gfx_v10_0_update_3d_clock_gating(adev, enable);
                /* ===  MGCG + MGLS === */
-               /* gfx_v10_0_update_medium_grain_clock_gating(adev, enable); */
+               gfx_v10_0_update_medium_grain_clock_gating(adev, enable);
        }
 
        if (adev->cg_flags &
@@ -4353,11 +4353,7 @@ static int gfx_v10_0_set_powergating_state(void *handle,
        switch (adev->asic_type) {
        case CHIP_NAVI10:
        case CHIP_NAVI14:
-               if (!enable) {
-                       amdgpu_gfx_off_ctrl(adev, false);
-                       cancel_delayed_work_sync(&adev->gfx.gfx_off_delay_work);
-               } else
-                       amdgpu_gfx_off_ctrl(adev, true);
+               amdgpu_gfx_off_ctrl(adev, enable);
                break;
        default:
                break;
@@ -4918,6 +4914,19 @@ static void gfx_v10_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
                                                           ref, mask);
 }
 
+static void gfx_v10_0_ring_soft_recovery(struct amdgpu_ring *ring,
+                                        unsigned vmid)
+{
+       struct amdgpu_device *adev = ring->adev;
+       uint32_t value = 0;
+
+       value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);
+       value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);
+       value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1);
+       value = REG_SET_FIELD(value, SQ_CMD, VM_ID, vmid);
+       WREG32_SOC15(GC, 0, mmSQ_CMD, value);
+}
+
 static void
 gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
                                      uint32_t me, uint32_t pipe,
@@ -5309,6 +5318,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = {
        .emit_wreg = gfx_v10_0_ring_emit_wreg,
        .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait,
        .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait,
+       .soft_recovery = gfx_v10_0_ring_soft_recovery,
 };
 
 static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = {
index 0c39048..d2d9dce 100644 (file)
@@ -1236,6 +1236,8 @@ static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = {
        { 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
        /* https://bugzilla.kernel.org/show_bug.cgi?id=207171 */
        { 0x1002, 0x15dd, 0x103c, 0x83e7, 0xd3 },
+       /* GFXOFF is unstable on C6 parts with a VBIOS 113-RAVEN-114 */
+       { 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc6 },
        { 0, 0, 0, 0, 0 },
 };
 
@@ -5025,10 +5027,9 @@ static int gfx_v9_0_set_powergating_state(void *handle,
        switch (adev->asic_type) {
        case CHIP_RAVEN:
        case CHIP_RENOIR:
-               if (!enable) {
+               if (!enable)
                        amdgpu_gfx_off_ctrl(adev, false);
-                       cancel_delayed_work_sync(&adev->gfx.gfx_off_delay_work);
-               }
+
                if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) {
                        gfx_v9_0_enable_sck_slow_down_on_power_up(adev, true);
                        gfx_v9_0_enable_sck_slow_down_on_power_down(adev, true);
@@ -5052,12 +5053,7 @@ static int gfx_v9_0_set_powergating_state(void *handle,
                        amdgpu_gfx_off_ctrl(adev, true);
                break;
        case CHIP_VEGA12:
-               if (!enable) {
-                       amdgpu_gfx_off_ctrl(adev, false);
-                       cancel_delayed_work_sync(&adev->gfx.gfx_off_delay_work);
-               } else {
-                       amdgpu_gfx_off_ctrl(adev, true);
-               }
+               amdgpu_gfx_off_ctrl(adev, enable);
                break;
        default:
                break;
index 9c83c13..28e651b 100644 (file)
@@ -441,7 +441,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
 
 /**
  * dm_crtc_high_irq() - Handles CRTC interrupt
- * @interrupt_params: ignored
+ * @interrupt_params: used for determining the CRTC instance
  *
  * Handles the CRTC/VSYNC interrupt by notfying DRM's VBLANK
  * event handler.
@@ -455,70 +455,6 @@ static void dm_crtc_high_irq(void *interrupt_params)
        unsigned long flags;
 
        acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VBLANK);
-
-       if (acrtc) {
-               acrtc_state = to_dm_crtc_state(acrtc->base.state);
-
-               DRM_DEBUG_VBL("crtc:%d, vupdate-vrr:%d\n",
-                             acrtc->crtc_id,
-                             amdgpu_dm_vrr_active(acrtc_state));
-
-               /* Core vblank handling at start of front-porch is only possible
-                * in non-vrr mode, as only there vblank timestamping will give
-                * valid results while done in front-porch. Otherwise defer it
-                * to dm_vupdate_high_irq after end of front-porch.
-                */
-               if (!amdgpu_dm_vrr_active(acrtc_state))
-                       drm_crtc_handle_vblank(&acrtc->base);
-
-               /* Following stuff must happen at start of vblank, for crc
-                * computation and below-the-range btr support in vrr mode.
-                */
-               amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
-
-               if (acrtc_state->stream && adev->family >= AMDGPU_FAMILY_AI &&
-                   acrtc_state->vrr_params.supported &&
-                   acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) {
-                       spin_lock_irqsave(&adev->ddev->event_lock, flags);
-                       mod_freesync_handle_v_update(
-                               adev->dm.freesync_module,
-                               acrtc_state->stream,
-                               &acrtc_state->vrr_params);
-
-                       dc_stream_adjust_vmin_vmax(
-                               adev->dm.dc,
-                               acrtc_state->stream,
-                               &acrtc_state->vrr_params.adjust);
-                       spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
-               }
-       }
-}
-
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-/**
- * dm_dcn_crtc_high_irq() - Handles VStartup interrupt for DCN generation ASICs
- * @interrupt params - interrupt parameters
- *
- * Notify DRM's vblank event handler at VSTARTUP
- *
- * Unlike DCE hardware, we trigger the handler at VSTARTUP. at which:
- * * We are close enough to VUPDATE - the point of no return for hw
- * * We are in the fixed portion of variable front porch when vrr is enabled
- * * We are before VUPDATE, where double-buffered vrr registers are swapped
- *
- * It is therefore the correct place to signal vblank, send user flip events,
- * and update VRR.
- */
-static void dm_dcn_crtc_high_irq(void *interrupt_params)
-{
-       struct common_irq_params *irq_params = interrupt_params;
-       struct amdgpu_device *adev = irq_params->adev;
-       struct amdgpu_crtc *acrtc;
-       struct dm_crtc_state *acrtc_state;
-       unsigned long flags;
-
-       acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VBLANK);
-
        if (!acrtc)
                return;
 
@@ -528,22 +464,35 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
                         amdgpu_dm_vrr_active(acrtc_state),
                         acrtc_state->active_planes);
 
+       /**
+        * Core vblank handling at start of front-porch is only possible
+        * in non-vrr mode, as only there vblank timestamping will give
+        * valid results while done in front-porch. Otherwise defer it
+        * to dm_vupdate_high_irq after end of front-porch.
+        */
+       if (!amdgpu_dm_vrr_active(acrtc_state))
+               drm_crtc_handle_vblank(&acrtc->base);
+
+       /**
+        * Following stuff must happen at start of vblank, for crc
+        * computation and below-the-range btr support in vrr mode.
+        */
        amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
-       drm_crtc_handle_vblank(&acrtc->base);
+
+       /* BTR updates need to happen before VUPDATE on Vega and above. */
+       if (adev->family < AMDGPU_FAMILY_AI)
+               return;
 
        spin_lock_irqsave(&adev->ddev->event_lock, flags);
 
-       if (acrtc_state->vrr_params.supported &&
+       if (acrtc_state->stream && acrtc_state->vrr_params.supported &&
            acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) {
-               mod_freesync_handle_v_update(
-               adev->dm.freesync_module,
-               acrtc_state->stream,
-               &acrtc_state->vrr_params);
+               mod_freesync_handle_v_update(adev->dm.freesync_module,
+                                            acrtc_state->stream,
+                                            &acrtc_state->vrr_params);
 
-               dc_stream_adjust_vmin_vmax(
-                       adev->dm.dc,
-                       acrtc_state->stream,
-                       &acrtc_state->vrr_params.adjust);
+               dc_stream_adjust_vmin_vmax(adev->dm.dc, acrtc_state->stream,
+                                          &acrtc_state->vrr_params.adjust);
        }
 
        /*
@@ -556,7 +505,8 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
         * avoid race conditions between flip programming and completion,
         * which could cause too early flip completion events.
         */
-       if (acrtc->pflip_status == AMDGPU_FLIP_SUBMITTED &&
+       if (adev->family >= AMDGPU_FAMILY_RV &&
+           acrtc->pflip_status == AMDGPU_FLIP_SUBMITTED &&
            acrtc_state->active_planes == 0) {
                if (acrtc->event) {
                        drm_crtc_send_vblank_event(&acrtc->base, acrtc->event);
@@ -568,7 +518,6 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
 
        spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
 }
-#endif
 
 static int dm_set_clockgating_state(void *handle,
                  enum amd_clockgating_state state)
@@ -2445,8 +2394,36 @@ static int dcn10_register_irq_handlers(struct amdgpu_device *adev)
                c_irq_params->adev = adev;
                c_irq_params->irq_src = int_params.irq_source;
 
+               amdgpu_dm_irq_register_interrupt(
+                       adev, &int_params, dm_crtc_high_irq, c_irq_params);
+       }
+
+       /* Use VUPDATE_NO_LOCK interrupt on DCN, which seems to correspond to
+        * the regular VUPDATE interrupt on DCE. We want DC_IRQ_SOURCE_VUPDATEx
+        * to trigger at end of each vblank, regardless of state of the lock,
+        * matching DCE behaviour.
+        */
+       for (i = DCN_1_0__SRCID__OTG0_IHC_V_UPDATE_NO_LOCK_INTERRUPT;
+            i <= DCN_1_0__SRCID__OTG0_IHC_V_UPDATE_NO_LOCK_INTERRUPT + adev->mode_info.num_crtc - 1;
+            i++) {
+               r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_DCE, i, &adev->vupdate_irq);
+
+               if (r) {
+                       DRM_ERROR("Failed to add vupdate irq id!\n");
+                       return r;
+               }
+
+               int_params.int_context = INTERRUPT_HIGH_IRQ_CONTEXT;
+               int_params.irq_source =
+                       dc_interrupt_to_irq_source(dc, i, 0);
+
+               c_irq_params = &adev->dm.vupdate_params[int_params.irq_source - DC_IRQ_SOURCE_VUPDATE1];
+
+               c_irq_params->adev = adev;
+               c_irq_params->irq_src = int_params.irq_source;
+
                amdgpu_dm_irq_register_interrupt(adev, &int_params,
-                               dm_dcn_crtc_high_irq, c_irq_params);
+                               dm_vupdate_high_irq, c_irq_params);
        }
 
        /* Use GRPH_PFLIP interrupt */
@@ -4453,10 +4430,6 @@ static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
        struct amdgpu_device *adev = crtc->dev->dev_private;
        int rc;
 
-       /* Do not set vupdate for DCN hardware */
-       if (adev->family > AMDGPU_FAMILY_AI)
-               return 0;
-
        irq_source = IRQ_TYPE_VUPDATE + acrtc->otg_inst;
 
        rc = dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY;
@@ -7882,6 +7855,7 @@ static int dm_update_plane_state(struct dc *dc,
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
        struct dm_crtc_state *dm_new_crtc_state, *dm_old_crtc_state;
        struct dm_plane_state *dm_new_plane_state, *dm_old_plane_state;
+       struct amdgpu_crtc *new_acrtc;
        bool needs_reset;
        int ret = 0;
 
@@ -7891,9 +7865,30 @@ static int dm_update_plane_state(struct dc *dc,
        dm_new_plane_state = to_dm_plane_state(new_plane_state);
        dm_old_plane_state = to_dm_plane_state(old_plane_state);
 
-       /*TODO Implement atomic check for cursor plane */
-       if (plane->type == DRM_PLANE_TYPE_CURSOR)
+       /*TODO Implement better atomic check for cursor plane */
+       if (plane->type == DRM_PLANE_TYPE_CURSOR) {
+               if (!enable || !new_plane_crtc ||
+                       drm_atomic_plane_disabling(plane->state, new_plane_state))
+                       return 0;
+
+               new_acrtc = to_amdgpu_crtc(new_plane_crtc);
+
+               if ((new_plane_state->crtc_w > new_acrtc->max_cursor_width) ||
+                       (new_plane_state->crtc_h > new_acrtc->max_cursor_height)) {
+                       DRM_DEBUG_ATOMIC("Bad cursor size %d x %d\n",
+                                                        new_plane_state->crtc_w, new_plane_state->crtc_h);
+                       return -EINVAL;
+               }
+
+               if (new_plane_state->crtc_x <= -new_acrtc->max_cursor_width ||
+                       new_plane_state->crtc_y <= -new_acrtc->max_cursor_height) {
+                       DRM_DEBUG_ATOMIC("Bad cursor position %d, %d\n",
+                                                        new_plane_state->crtc_x, new_plane_state->crtc_y);
+                       return -EINVAL;
+               }
+
                return 0;
+       }
 
        needs_reset = should_reset_plane(state, plane, old_plane_state,
                                         new_plane_state);
index 78e1c11..dcf84a6 100644 (file)
@@ -398,15 +398,15 @@ static void update_config(void *handle, struct cp_psp_stream_config *config)
        struct mod_hdcp_display *display = &hdcp_work[link_index].display;
        struct mod_hdcp_link *link = &hdcp_work[link_index].link;
 
-       memset(display, 0, sizeof(*display));
-       memset(link, 0, sizeof(*link));
-
-       display->index = aconnector->base.index;
-
        if (config->dpms_off) {
                hdcp_remove_display(hdcp_work, link_index, aconnector);
                return;
        }
+
+       memset(display, 0, sizeof(*display));
+       memset(link, 0, sizeof(*link));
+
+       display->index = aconnector->base.index;
        display->state = MOD_HDCP_DISPLAY_ACTIVE;
 
        if (aconnector->dc_sink != NULL)
index 27a7d2a..caa090d 100644 (file)
@@ -220,6 +220,30 @@ static enum dpcd_training_patterns
        return dpcd_tr_pattern;
 }
 
+static uint8_t dc_dp_initialize_scrambling_data_symbols(
+       struct dc_link *link,
+       enum dc_dp_training_pattern pattern)
+{
+       uint8_t disable_scrabled_data_symbols = 0;
+
+       switch (pattern) {
+       case DP_TRAINING_PATTERN_SEQUENCE_1:
+       case DP_TRAINING_PATTERN_SEQUENCE_2:
+       case DP_TRAINING_PATTERN_SEQUENCE_3:
+               disable_scrabled_data_symbols = 1;
+               break;
+       case DP_TRAINING_PATTERN_SEQUENCE_4:
+               disable_scrabled_data_symbols = 0;
+               break;
+       default:
+               ASSERT(0);
+               DC_LOG_HW_LINK_TRAINING("%s: Invalid HW Training pattern: %d\n",
+                       __func__, pattern);
+               break;
+       }
+       return disable_scrabled_data_symbols;
+}
+
 static inline bool is_repeater(struct dc_link *link, uint32_t offset)
 {
        return (!link->is_lttpr_mode_transparent && offset != 0);
@@ -252,6 +276,9 @@ static void dpcd_set_lt_pattern_and_lane_settings(
        dpcd_pattern.v1_4.TRAINING_PATTERN_SET =
                dc_dp_training_pattern_to_dpcd_training_pattern(link, pattern);
 
+       dpcd_pattern.v1_4.SCRAMBLING_DISABLE =
+               dc_dp_initialize_scrambling_data_symbols(link, pattern);
+
        dpcd_lt_buffer[DP_TRAINING_PATTERN_SET - DP_TRAINING_PATTERN_SET]
                = dpcd_pattern.raw;
 
index 085c1a3..82fc3d5 100644 (file)
@@ -1625,12 +1625,79 @@ void dcn10_pipe_control_lock(
                hws->funcs.verify_allow_pstate_change_high(dc);
 }
 
+/**
+ * delay_cursor_until_vupdate() - Delay cursor update if too close to VUPDATE.
+ *
+ * Software keepout workaround to prevent cursor update locking from stalling
+ * out cursor updates indefinitely or from old values from being retained in
+ * the case where the viewport changes in the same frame as the cursor.
+ *
+ * The idea is to calculate the remaining time from VPOS to VUPDATE. If it's
+ * too close to VUPDATE, then stall out until VUPDATE finishes.
+ *
+ * TODO: Optimize cursor programming to be once per frame before VUPDATE
+ *       to avoid the need for this workaround.
+ */
+static void delay_cursor_until_vupdate(struct dc *dc, struct pipe_ctx *pipe_ctx)
+{
+       struct dc_stream_state *stream = pipe_ctx->stream;
+       struct crtc_position position;
+       uint32_t vupdate_start, vupdate_end;
+       unsigned int lines_to_vupdate, us_to_vupdate, vpos;
+       unsigned int us_per_line, us_vupdate;
+
+       if (!dc->hwss.calc_vupdate_position || !dc->hwss.get_position)
+               return;
+
+       if (!pipe_ctx->stream_res.stream_enc || !pipe_ctx->stream_res.tg)
+               return;
+
+       dc->hwss.calc_vupdate_position(dc, pipe_ctx, &vupdate_start,
+                                      &vupdate_end);
+
+       dc->hwss.get_position(&pipe_ctx, 1, &position);
+       vpos = position.vertical_count;
+
+       /* Avoid wraparound calculation issues */
+       vupdate_start += stream->timing.v_total;
+       vupdate_end += stream->timing.v_total;
+       vpos += stream->timing.v_total;
+
+       if (vpos <= vupdate_start) {
+               /* VPOS is in VACTIVE or back porch. */
+               lines_to_vupdate = vupdate_start - vpos;
+       } else if (vpos > vupdate_end) {
+               /* VPOS is in the front porch. */
+               return;
+       } else {
+               /* VPOS is in VUPDATE. */
+               lines_to_vupdate = 0;
+       }
+
+       /* Calculate time until VUPDATE in microseconds. */
+       us_per_line =
+               stream->timing.h_total * 10000u / stream->timing.pix_clk_100hz;
+       us_to_vupdate = lines_to_vupdate * us_per_line;
+
+       /* 70 us is a conservative estimate of cursor update time*/
+       if (us_to_vupdate > 70)
+               return;
+
+       /* Stall out until the cursor update completes. */
+       us_vupdate = (vupdate_end - vupdate_start + 1) * us_per_line;
+       udelay(us_to_vupdate + us_vupdate);
+}
+
 void dcn10_cursor_lock(struct dc *dc, struct pipe_ctx *pipe, bool lock)
 {
        /* cursor lock is per MPCC tree, so only need to lock one pipe per stream */
        if (!pipe || pipe->top_pipe)
                return;
 
+       /* Prevent cursor lock from stalling out cursor updates. */
+       if (lock)
+               delay_cursor_until_vupdate(dc, pipe);
+
        dc->res_pool->mpc->funcs->cursor_lock(dc->res_pool->mpc,
                        pipe->stream_res.opp->inst, lock);
 }
@@ -3236,7 +3303,7 @@ int dcn10_get_vupdate_offset_from_vsync(struct pipe_ctx *pipe_ctx)
        return vertical_line_start;
 }
 
-static void dcn10_calc_vupdate_position(
+void dcn10_calc_vupdate_position(
                struct dc *dc,
                struct pipe_ctx *pipe_ctx,
                uint32_t *start_line,
index af51424..42b6e01 100644 (file)
@@ -34,6 +34,11 @@ struct dc;
 void dcn10_hw_sequencer_construct(struct dc *dc);
 
 int dcn10_get_vupdate_offset_from_vsync(struct pipe_ctx *pipe_ctx);
+void dcn10_calc_vupdate_position(
+               struct dc *dc,
+               struct pipe_ctx *pipe_ctx,
+               uint32_t *start_line,
+               uint32_t *end_line);
 void dcn10_setup_vupdate_interrupt(struct dc *dc, struct pipe_ctx *pipe_ctx);
 enum dc_status dcn10_enable_stream_timing(
                struct pipe_ctx *pipe_ctx,
index 700509b..9e8e326 100644 (file)
@@ -72,6 +72,7 @@ static const struct hw_sequencer_funcs dcn10_funcs = {
        .set_clock = dcn10_set_clock,
        .get_clock = dcn10_get_clock,
        .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
+       .calc_vupdate_position = dcn10_calc_vupdate_position,
 };
 
 static const struct hwseq_private_funcs dcn10_private_funcs = {
index 6a21228..8334bbd 100644 (file)
@@ -83,6 +83,7 @@ static const struct hw_sequencer_funcs dcn20_funcs = {
        .init_vm_ctx = dcn20_init_vm_ctx,
        .set_flip_control_gsl = dcn20_set_flip_control_gsl,
        .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
+       .calc_vupdate_position = dcn10_calc_vupdate_position,
 };
 
 static const struct hwseq_private_funcs dcn20_private_funcs = {
index 707ce0f..4dd6341 100644 (file)
@@ -86,6 +86,7 @@ static const struct hw_sequencer_funcs dcn21_funcs = {
        .optimize_pwr_state = dcn21_optimize_pwr_state,
        .exit_optimized_pwr_state = dcn21_exit_optimized_pwr_state,
        .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
+       .calc_vupdate_position = dcn10_calc_vupdate_position,
        .set_cursor_position = dcn10_set_cursor_position,
        .set_cursor_attribute = dcn10_set_cursor_attribute,
        .set_cursor_sdr_white_level = dcn10_set_cursor_sdr_white_level,
index 7ee8b84..e34c337 100644 (file)
@@ -63,10 +63,8 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_rq_dlg_calc_21.o := $(dml_ccflags)
 endif
 CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o := $(dml_ccflags)
 CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o := $(dml_ccflags)
-CFLAGS_$(AMDDALPATH)/dc/dml/dml_common_defs.o := $(dml_ccflags)
 
 DML = display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o \
-       dml_common_defs.o
 
 ifdef CONFIG_DRM_AMD_DC_DCN
 DML += display_mode_vba.o dcn20/display_rq_dlg_calc_20.o dcn20/display_mode_vba_20.o
index 8c86b63..1e557dd 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef __DML20_DISPLAY_RQ_DLG_CALC_H__
 #define __DML20_DISPLAY_RQ_DLG_CALC_H__
 
-#include "../dml_common_defs.h"
 #include "../display_rq_dlg_helpers.h"
 
 struct display_mode_lib;
index 0378406..0d53e87 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef __DML20V2_DISPLAY_RQ_DLG_CALC_H__
 #define __DML20V2_DISPLAY_RQ_DLG_CALC_H__
 
-#include "../dml_common_defs.h"
 #include "../display_rq_dlg_helpers.h"
 
 struct display_mode_lib;
index 83e95f8..e8f7785 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef __DML21_DISPLAY_RQ_DLG_CALC_H__
 #define __DML21_DISPLAY_RQ_DLG_CALC_H__
 
-#include "../dml_common_defs.h"
+#include "dm_services.h"
 #include "../display_rq_dlg_helpers.h"
 
 struct display_mode_lib;
index cf2758c..c77c3d8 100644 (file)
 #ifndef __DISPLAY_MODE_LIB_H__
 #define __DISPLAY_MODE_LIB_H__
 
-
-#include "dml_common_defs.h"
+#include "dm_services.h"
+#include "dc_features.h"
+#include "display_mode_structs.h"
+#include "display_mode_enums.h"
 #include "display_mode_vba.h"
 
 enum dml_project {
index 5d82fc5..3a73417 100644 (file)
@@ -27,8 +27,6 @@
 #ifndef __DML2_DISPLAY_MODE_VBA_H__
 #define __DML2_DISPLAY_MODE_VBA_H__
 
-#include "dml_common_defs.h"
-
 struct display_mode_lib;
 
 void ModeSupportAndSystemConfiguration(struct display_mode_lib *mode_lib);
index 1f24db8..2555ef0 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef __DISPLAY_RQ_DLG_HELPERS_H__
 #define __DISPLAY_RQ_DLG_HELPERS_H__
 
-#include "dml_common_defs.h"
 #include "display_mode_lib.h"
 
 /* Function: Printer functions
index 3041649..9c06913 100644 (file)
@@ -26,8 +26,6 @@
 #ifndef __DISPLAY_RQ_DLG_CALC_H__
 #define __DISPLAY_RQ_DLG_CALC_H__
 
-#include "dml_common_defs.h"
-
 struct display_mode_lib;
 
 #include "display_rq_dlg_helpers.h"
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c b/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.c
deleted file mode 100644 (file)
index 723af0b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include "dml_common_defs.h"
-#include "dcn_calc_math.h"
-
-#include "dml_inline_defs.h"
-
-double dml_round(double a)
-{
-       double round_pt = 0.5;
-       double ceil = dml_ceil(a, 1);
-       double floor = dml_floor(a, 1);
-
-       if (a - floor >= round_pt)
-               return ceil;
-       else
-               return floor;
-}
-
-
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h b/drivers/gpu/drm/amd/display/dc/dml/dml_common_defs.h
deleted file mode 100644 (file)
index f78cbae..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#ifndef __DC_COMMON_DEFS_H__
-#define __DC_COMMON_DEFS_H__
-
-#include "dm_services.h"
-#include "dc_features.h"
-#include "display_mode_structs.h"
-#include "display_mode_enums.h"
-
-
-double dml_round(double a);
-
-#endif /* __DC_COMMON_DEFS_H__ */
index ded71ea..02e06c9 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef __DML_INLINE_DEFS_H__
 #define __DML_INLINE_DEFS_H__
 
-#include "dml_common_defs.h"
 #include "dcn_calc_math.h"
 #include "dml_logger.h"
 
@@ -75,6 +74,18 @@ static inline double dml_floor(double a, double granularity)
        return (double) dcn_bw_floor2(a, granularity);
 }
 
+static inline double dml_round(double a)
+{
+       double round_pt = 0.5;
+       double ceil = dml_ceil(a, 1);
+       double floor = dml_floor(a, 1);
+
+       if (a - floor >= round_pt)
+               return ceil;
+       else
+               return floor;
+}
+
 static inline int dml_log2(double x)
 {
        return dml_round((double)dcn_bw_log(x, 2));
@@ -112,7 +123,7 @@ static inline double dml_log(double x, double base)
 
 static inline unsigned int dml_round_to_multiple(unsigned int num,
                                                 unsigned int multiple,
-                                                bool up)
+                                                unsigned char up)
 {
        unsigned int remainder;
 
index e57467d..08307f3 100644 (file)
@@ -92,6 +92,11 @@ struct hw_sequencer_funcs {
        void (*get_position)(struct pipe_ctx **pipe_ctx, int num_pipes,
                        struct crtc_position *position);
        int (*get_vupdate_offset_from_vsync)(struct pipe_ctx *pipe_ctx);
+       void (*calc_vupdate_position)(
+                       struct dc *dc,
+                       struct pipe_ctx *pipe_ctx,
+                       uint32_t *start_line,
+                       uint32_t *end_line);
        void (*enable_per_frame_crtc_position_reset)(struct dc *dc,
                        int group_size, struct pipe_ctx *grouped_pipes[]);
        void (*enable_timing_synchronization)(struct dc *dc,
index e4e5a53..8e2acb4 100644 (file)
@@ -319,12 +319,12 @@ static void pp_dpm_en_umd_pstate(struct pp_hwmgr  *hwmgr,
                if (*level & profile_mode_mask) {
                        hwmgr->saved_dpm_level = hwmgr->dpm_level;
                        hwmgr->en_umd_pstate = true;
-                       amdgpu_device_ip_set_clockgating_state(hwmgr->adev,
-                                               AMD_IP_BLOCK_TYPE_GFX,
-                                               AMD_CG_STATE_UNGATE);
                        amdgpu_device_ip_set_powergating_state(hwmgr->adev,
                                        AMD_IP_BLOCK_TYPE_GFX,
                                        AMD_PG_STATE_UNGATE);
+                       amdgpu_device_ip_set_clockgating_state(hwmgr->adev,
+                                               AMD_IP_BLOCK_TYPE_GFX,
+                                               AMD_CG_STATE_UNGATE);
                }
        } else {
                /* exit umd pstate, restore level, enable gfx cg*/
index e8b27fa..e770469 100644 (file)
@@ -1476,7 +1476,7 @@ static int smu_disable_dpm(struct smu_context *smu)
        bool use_baco = !smu->is_apu &&
                ((adev->in_gpu_reset &&
                  (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)) ||
-                (adev->in_runpm && amdgpu_asic_supports_baco(adev)));
+                ((adev->in_runpm || adev->in_hibernate) && amdgpu_asic_supports_baco(adev)));
 
        ret = smu_get_smc_version(smu, NULL, &smu_version);
        if (ret) {
@@ -1744,12 +1744,12 @@ static int smu_enable_umd_pstate(void *handle,
                if (*level & profile_mode_mask) {
                        smu_dpm_ctx->saved_dpm_level = smu_dpm_ctx->dpm_level;
                        smu_dpm_ctx->enable_umd_pstate = true;
-                       amdgpu_device_ip_set_clockgating_state(smu->adev,
-                                                              AMD_IP_BLOCK_TYPE_GFX,
-                                                              AMD_CG_STATE_UNGATE);
                        amdgpu_device_ip_set_powergating_state(smu->adev,
                                                               AMD_IP_BLOCK_TYPE_GFX,
                                                               AMD_PG_STATE_UNGATE);
+                       amdgpu_device_ip_set_clockgating_state(smu->adev,
+                                                              AMD_IP_BLOCK_TYPE_GFX,
+                                                              AMD_CG_STATE_UNGATE);
                }
        } else {
                /* exit umd pstate, restore level, enable gfx cg*/
index 4ede08a..d96e3ce 100644 (file)
@@ -191,10 +191,11 @@ static const struct edid_quirk {
        { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP },
        { "HVR", 0xaa02, EDID_QUIRK_NON_DESKTOP },
 
-       /* Oculus Rift DK1, DK2, and CV1 VR Headsets */
+       /* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */
        { "OVR", 0x0001, EDID_QUIRK_NON_DESKTOP },
        { "OVR", 0x0003, EDID_QUIRK_NON_DESKTOP },
        { "OVR", 0x0004, EDID_QUIRK_NON_DESKTOP },
+       { "OVR", 0x0012, EDID_QUIRK_NON_DESKTOP },
 
        /* Windows Mixed Reality Headsets */
        { "ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP },
index 3b0afa1..54def34 100644 (file)
@@ -238,8 +238,10 @@ static int submit_pin_objects(struct etnaviv_gem_submit *submit)
                }
 
                if ((submit->flags & ETNA_SUBMIT_SOFTPIN) &&
-                    submit->bos[i].va != mapping->iova)
+                    submit->bos[i].va != mapping->iova) {
+                       etnaviv_gem_mapping_unreference(mapping);
                        return -EINVAL;
+               }
 
                atomic_inc(&etnaviv_obj->gpu_active);
 
index e6795ba..75f9db8 100644 (file)
@@ -453,7 +453,7 @@ static const struct etnaviv_pm_domain *pm_domain(const struct etnaviv_gpu *gpu,
                if (!(gpu->identity.features & meta->feature))
                        continue;
 
-               if (meta->nr_domains < (index - offset)) {
+               if (index - offset >= meta->nr_domains) {
                        offset += meta->nr_domains;
                        continue;
                }
index 2e5d835..c125ca9 100644 (file)
@@ -485,8 +485,7 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv,
        if (!ret)
                goto err_llb;
        else if (ret > 1) {
-               DRM_INFO("Reducing the compressed framebuffer size. This may lead to less power savings than a non-reduced-size. Try to increase stolen memory size if available in BIOS.\n");
-
+               DRM_INFO_ONCE("Reducing the compressed framebuffer size. This may lead to less power savings than a non-reduced-size. Try to increase stolen memory size if available in BIOS.\n");
        }
 
        fbc->threshold = ret;
index 0cc40e7..4f96c87 100644 (file)
@@ -368,7 +368,6 @@ static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
        struct drm_i915_private *i915 = to_i915(obj->base.dev);
        struct i915_vma *vma;
 
-       GEM_BUG_ON(!i915_gem_object_has_pinned_pages(obj));
        if (!atomic_read(&obj->bind_count))
                return;
 
@@ -400,12 +399,8 @@ static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
 void
 i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
 {
-       struct drm_i915_gem_object *obj = vma->obj;
-
-       assert_object_held(obj);
-
        /* Bump the LRU to try and avoid premature eviction whilst flipping  */
-       i915_gem_object_bump_inactive_ggtt(obj);
+       i915_gem_object_bump_inactive_ggtt(vma->obj);
 
        i915_vma_unpin(vma);
 }
index 07cb83a..ca0d4f4 100644 (file)
@@ -69,7 +69,13 @@ struct intel_context {
 #define CONTEXT_NOPREEMPT              7
 
        u32 *lrc_reg_state;
-       u64 lrc_desc;
+       union {
+               struct {
+                       u32 lrca;
+                       u32 ccid;
+               };
+               u64 desc;
+       } lrc;
        u32 tag; /* cookie passed to HW to track this context on submission */
 
        /* Time on GPU as tracked by the hw. */
index b469de0..a1aa0d3 100644 (file)
@@ -333,13 +333,4 @@ intel_engine_has_preempt_reset(const struct intel_engine_cs *engine)
        return intel_engine_has_preemption(engine);
 }
 
-static inline bool
-intel_engine_has_timeslices(const struct intel_engine_cs *engine)
-{
-       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
-               return false;
-
-       return intel_engine_has_semaphores(engine);
-}
-
 #endif /* _INTEL_RINGBUFFER_H_ */
index 3aa8a65..883a9b7 100644 (file)
@@ -1295,6 +1295,12 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,
 
        if (engine->id == RENDER_CLASS && IS_GEN_RANGE(dev_priv, 4, 7))
                drm_printf(m, "\tCCID: 0x%08x\n", ENGINE_READ(engine, CCID));
+       if (HAS_EXECLISTS(dev_priv)) {
+               drm_printf(m, "\tEL_STAT_HI: 0x%08x\n",
+                          ENGINE_READ(engine, RING_EXECLIST_STATUS_HI));
+               drm_printf(m, "\tEL_STAT_LO: 0x%08x\n",
+                          ENGINE_READ(engine, RING_EXECLIST_STATUS_LO));
+       }
        drm_printf(m, "\tRING_START: 0x%08x\n",
                   ENGINE_READ(engine, RING_START));
        drm_printf(m, "\tRING_HEAD:  0x%08x\n",
index 80cdde7..0be674a 100644 (file)
@@ -156,6 +156,20 @@ struct intel_engine_execlists {
         */
        struct i915_priolist default_priolist;
 
+       /**
+        * @ccid: identifier for contexts submitted to this engine
+        */
+       u32 ccid;
+
+       /**
+        * @yield: CCID at the time of the last semaphore-wait interrupt.
+        *
+        * Instead of leaving a semaphore busy-spinning on an engine, we would
+        * like to switch to another ready context, i.e. yielding the semaphore
+        * timeslice.
+        */
+       u32 yield;
+
        /**
         * @error_interrupt: CS Master EIR
         *
@@ -295,8 +309,7 @@ struct intel_engine_cs {
        u32 context_size;
        u32 mmio_base;
 
-       unsigned int context_tag;
-#define NUM_CONTEXT_TAG roundup_pow_of_two(2 * EXECLIST_MAX_PORTS)
+       unsigned long context_tag;
 
        struct rb_node uabi_node;
 
@@ -483,10 +496,11 @@ struct intel_engine_cs {
 #define I915_ENGINE_SUPPORTS_STATS   BIT(1)
 #define I915_ENGINE_HAS_PREEMPTION   BIT(2)
 #define I915_ENGINE_HAS_SEMAPHORES   BIT(3)
-#define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(4)
-#define I915_ENGINE_IS_VIRTUAL       BIT(5)
-#define I915_ENGINE_HAS_RELATIVE_MMIO BIT(6)
-#define I915_ENGINE_REQUIRES_CMD_PARSER BIT(7)
+#define I915_ENGINE_HAS_TIMESLICES   BIT(4)
+#define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(5)
+#define I915_ENGINE_IS_VIRTUAL       BIT(6)
+#define I915_ENGINE_HAS_RELATIVE_MMIO BIT(7)
+#define I915_ENGINE_REQUIRES_CMD_PARSER BIT(8)
        unsigned int flags;
 
        /*
@@ -584,6 +598,15 @@ intel_engine_has_semaphores(const struct intel_engine_cs *engine)
        return engine->flags & I915_ENGINE_HAS_SEMAPHORES;
 }
 
+static inline bool
+intel_engine_has_timeslices(const struct intel_engine_cs *engine)
+{
+       if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+               return false;
+
+       return engine->flags & I915_ENGINE_HAS_TIMESLICES;
+}
+
 static inline bool
 intel_engine_needs_breadcrumb_tasklet(const struct intel_engine_cs *engine)
 {
index f0e7fd9..0cc7dd5 100644 (file)
@@ -39,6 +39,15 @@ cs_irq_handler(struct intel_engine_cs *engine, u32 iir)
                }
        }
 
+       if (iir & GT_WAIT_SEMAPHORE_INTERRUPT) {
+               WRITE_ONCE(engine->execlists.yield,
+                          ENGINE_READ_FW(engine, RING_EXECLIST_STATUS_HI));
+               ENGINE_TRACE(engine, "semaphore yield: %08x\n",
+                            engine->execlists.yield);
+               if (del_timer(&engine->execlists.timer))
+                       tasklet = true;
+       }
+
        if (iir & GT_CONTEXT_SWITCH_INTERRUPT)
                tasklet = true;
 
@@ -228,7 +237,8 @@ void gen11_gt_irq_postinstall(struct intel_gt *gt)
        const u32 irqs =
                GT_CS_MASTER_ERROR_INTERRUPT |
                GT_RENDER_USER_INTERRUPT |
-               GT_CONTEXT_SWITCH_INTERRUPT;
+               GT_CONTEXT_SWITCH_INTERRUPT |
+               GT_WAIT_SEMAPHORE_INTERRUPT;
        struct intel_uncore *uncore = gt->uncore;
        const u32 dmask = irqs << 16 | irqs;
        const u32 smask = irqs << 16;
@@ -366,7 +376,8 @@ void gen8_gt_irq_postinstall(struct intel_gt *gt)
        const u32 irqs =
                GT_CS_MASTER_ERROR_INTERRUPT |
                GT_RENDER_USER_INTERRUPT |
-               GT_CONTEXT_SWITCH_INTERRUPT;
+               GT_CONTEXT_SWITCH_INTERRUPT |
+               GT_WAIT_SEMAPHORE_INTERRUPT;
        const u32 gt_interrupts[] = {
                irqs << GEN8_RCS_IRQ_SHIFT | irqs << GEN8_BCS_IRQ_SHIFT,
                irqs << GEN8_VCS0_IRQ_SHIFT | irqs << GEN8_VCS1_IRQ_SHIFT,
index 683014e..2dfaddb 100644 (file)
@@ -456,10 +456,10 @@ assert_priority_queue(const struct i915_request *prev,
  * engine info, SW context ID and SW counter need to form a unique number
  * (Context ID) per lrc.
  */
-static u64
+static u32
 lrc_descriptor(struct intel_context *ce, struct intel_engine_cs *engine)
 {
-       u64 desc;
+       u32 desc;
 
        desc = INTEL_LEGACY_32B_CONTEXT;
        if (i915_vm_is_4lvl(ce->vm))
@@ -470,21 +470,7 @@ lrc_descriptor(struct intel_context *ce, struct intel_engine_cs *engine)
        if (IS_GEN(engine->i915, 8))
                desc |= GEN8_CTX_L3LLC_COHERENT;
 
-       desc |= i915_ggtt_offset(ce->state); /* bits 12-31 */
-       /*
-        * The following 32bits are copied into the OA reports (dword 2).
-        * Consider updating oa_get_render_ctx_id in i915_perf.c when changing
-        * anything below.
-        */
-       if (INTEL_GEN(engine->i915) >= 11) {
-               desc |= (u64)engine->instance << GEN11_ENGINE_INSTANCE_SHIFT;
-                                                               /* bits 48-53 */
-
-               desc |= (u64)engine->class << GEN11_ENGINE_CLASS_SHIFT;
-                                                               /* bits 61-63 */
-       }
-
-       return desc;
+       return i915_ggtt_offset(ce->state) | desc;
 }
 
 static inline unsigned int dword_in_page(void *addr)
@@ -1192,7 +1178,7 @@ static void reset_active(struct i915_request *rq,
        __execlists_update_reg_state(ce, engine, head);
 
        /* We've switched away, so this should be a no-op, but intent matters */
-       ce->lrc_desc |= CTX_DESC_FORCE_RESTORE;
+       ce->lrc.desc |= CTX_DESC_FORCE_RESTORE;
 }
 
 static u32 intel_context_get_runtime(const struct intel_context *ce)
@@ -1251,18 +1237,23 @@ __execlists_schedule_in(struct i915_request *rq)
        if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
                execlists_check_context(ce, engine);
 
-       ce->lrc_desc &= ~GENMASK_ULL(47, 37);
        if (ce->tag) {
                /* Use a fixed tag for OA and friends */
-               ce->lrc_desc |= (u64)ce->tag << 32;
+               GEM_BUG_ON(ce->tag <= BITS_PER_LONG);
+               ce->lrc.ccid = ce->tag;
        } else {
                /* We don't need a strict matching tag, just different values */
-               ce->lrc_desc |=
-                       (u64)(++engine->context_tag % NUM_CONTEXT_TAG) <<
-                       GEN11_SW_CTX_ID_SHIFT;
-               BUILD_BUG_ON(NUM_CONTEXT_TAG > GEN12_MAX_CONTEXT_HW_ID);
+               unsigned int tag = ffs(engine->context_tag);
+
+               GEM_BUG_ON(tag == 0 || tag >= BITS_PER_LONG);
+               clear_bit(tag - 1, &engine->context_tag);
+               ce->lrc.ccid = tag << (GEN11_SW_CTX_ID_SHIFT - 32);
+
+               BUILD_BUG_ON(BITS_PER_LONG > GEN12_MAX_CONTEXT_HW_ID);
        }
 
+       ce->lrc.ccid |= engine->execlists.ccid;
+
        __intel_gt_pm_get(engine->gt);
        execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_IN);
        intel_engine_context_in(engine);
@@ -1302,7 +1293,8 @@ static void kick_siblings(struct i915_request *rq, struct intel_context *ce)
 
 static inline void
 __execlists_schedule_out(struct i915_request *rq,
-                        struct intel_engine_cs * const engine)
+                        struct intel_engine_cs * const engine,
+                        unsigned int ccid)
 {
        struct intel_context * const ce = rq->context;
 
@@ -1320,6 +1312,14 @@ __execlists_schedule_out(struct i915_request *rq,
            i915_request_completed(rq))
                intel_engine_add_retire(engine, ce->timeline);
 
+       ccid >>= GEN11_SW_CTX_ID_SHIFT - 32;
+       ccid &= GEN12_MAX_CONTEXT_HW_ID;
+       if (ccid < BITS_PER_LONG) {
+               GEM_BUG_ON(ccid == 0);
+               GEM_BUG_ON(test_bit(ccid - 1, &engine->context_tag));
+               set_bit(ccid - 1, &engine->context_tag);
+       }
+
        intel_context_update_runtime(ce);
        intel_engine_context_out(engine);
        execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
@@ -1345,15 +1345,17 @@ execlists_schedule_out(struct i915_request *rq)
 {
        struct intel_context * const ce = rq->context;
        struct intel_engine_cs *cur, *old;
+       u32 ccid;
 
        trace_i915_request_out(rq);
 
+       ccid = rq->context->lrc.ccid;
        old = READ_ONCE(ce->inflight);
        do
                cur = ptr_unmask_bits(old, 2) ? ptr_dec(old) : NULL;
        while (!try_cmpxchg(&ce->inflight, &old, cur));
        if (!cur)
-               __execlists_schedule_out(rq, old);
+               __execlists_schedule_out(rq, old, ccid);
 
        i915_request_put(rq);
 }
@@ -1361,7 +1363,7 @@ execlists_schedule_out(struct i915_request *rq)
 static u64 execlists_update_context(struct i915_request *rq)
 {
        struct intel_context *ce = rq->context;
-       u64 desc = ce->lrc_desc;
+       u64 desc = ce->lrc.desc;
        u32 tail, prev;
 
        /*
@@ -1400,7 +1402,7 @@ static u64 execlists_update_context(struct i915_request *rq)
         */
        wmb();
 
-       ce->lrc_desc &= ~CTX_DESC_FORCE_RESTORE;
+       ce->lrc.desc &= ~CTX_DESC_FORCE_RESTORE;
        return desc;
 }
 
@@ -1719,6 +1721,9 @@ static void defer_request(struct i915_request *rq, struct list_head * const pl)
                        struct i915_request *w =
                                container_of(p->waiter, typeof(*w), sched);
 
+                       if (p->flags & I915_DEPENDENCY_WEAK)
+                               continue;
+
                        /* Leave semaphores spinning on the other engines */
                        if (w->engine != rq->engine)
                                continue;
@@ -1754,7 +1759,8 @@ static void defer_active(struct intel_engine_cs *engine)
 }
 
 static bool
-need_timeslice(struct intel_engine_cs *engine, const struct i915_request *rq)
+need_timeslice(const struct intel_engine_cs *engine,
+              const struct i915_request *rq)
 {
        int hint;
 
@@ -1768,6 +1774,32 @@ need_timeslice(struct intel_engine_cs *engine, const struct i915_request *rq)
        return hint >= effective_prio(rq);
 }
 
+static bool
+timeslice_yield(const struct intel_engine_execlists *el,
+               const struct i915_request *rq)
+{
+       /*
+        * Once bitten, forever smitten!
+        *
+        * If the active context ever busy-waited on a semaphore,
+        * it will be treated as a hog until the end of its timeslice (i.e.
+        * until it is scheduled out and replaced by a new submission,
+        * possibly even its own lite-restore). The HW only sends an interrupt
+        * on the first miss, and we do know if that semaphore has been
+        * signaled, or even if it is now stuck on another semaphore. Play
+        * safe, yield if it might be stuck -- it will be given a fresh
+        * timeslice in the near future.
+        */
+       return rq->context->lrc.ccid == READ_ONCE(el->yield);
+}
+
+static bool
+timeslice_expired(const struct intel_engine_execlists *el,
+                 const struct i915_request *rq)
+{
+       return timer_expired(&el->timer) || timeslice_yield(el, rq);
+}
+
 static int
 switch_prio(struct intel_engine_cs *engine, const struct i915_request *rq)
 {
@@ -1783,8 +1815,7 @@ timeslice(const struct intel_engine_cs *engine)
        return READ_ONCE(engine->props.timeslice_duration_ms);
 }
 
-static unsigned long
-active_timeslice(const struct intel_engine_cs *engine)
+static unsigned long active_timeslice(const struct intel_engine_cs *engine)
 {
        const struct intel_engine_execlists *execlists = &engine->execlists;
        const struct i915_request *rq = *execlists->active;
@@ -1946,13 +1977,14 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
 
                        last = NULL;
                } else if (need_timeslice(engine, last) &&
-                          timer_expired(&engine->execlists.timer)) {
+                          timeslice_expired(execlists, last)) {
                        ENGINE_TRACE(engine,
-                                    "expired last=%llx:%lld, prio=%d, hint=%d\n",
+                                    "expired last=%llx:%lld, prio=%d, hint=%d, yield?=%s\n",
                                     last->fence.context,
                                     last->fence.seqno,
                                     last->sched.attr.priority,
-                                    execlists->queue_priority_hint);
+                                    execlists->queue_priority_hint,
+                                    yesno(timeslice_yield(execlists, last)));
 
                        ring_set_paused(engine, 1);
                        defer_active(engine);
@@ -2213,6 +2245,7 @@ done:
                }
                clear_ports(port + 1, last_port - port);
 
+               WRITE_ONCE(execlists->yield, -1);
                execlists_submit_ports(engine);
                set_preempt_timeout(engine, *active);
        } else {
@@ -3043,7 +3076,7 @@ __execlists_context_pin(struct intel_context *ce,
        if (IS_ERR(vaddr))
                return PTR_ERR(vaddr);
 
-       ce->lrc_desc = lrc_descriptor(ce, engine) | CTX_DESC_FORCE_RESTORE;
+       ce->lrc.lrca = lrc_descriptor(ce, engine) | CTX_DESC_FORCE_RESTORE;
        ce->lrc_reg_state = vaddr + LRC_STATE_PN * PAGE_SIZE;
        __execlists_update_reg_state(ce, engine, ce->ring->tail);
 
@@ -3072,7 +3105,7 @@ static void execlists_context_reset(struct intel_context *ce)
                                 ce, ce->engine, ce->ring, true);
        __execlists_update_reg_state(ce, ce->engine, ce->ring->tail);
 
-       ce->lrc_desc |= CTX_DESC_FORCE_RESTORE;
+       ce->lrc.desc |= CTX_DESC_FORCE_RESTORE;
 }
 
 static const struct intel_context_ops execlists_context_ops = {
@@ -3541,7 +3574,7 @@ static void enable_execlists(struct intel_engine_cs *engine)
 
        enable_error_interrupt(engine);
 
-       engine->context_tag = 0;
+       engine->context_tag = GENMASK(BITS_PER_LONG - 2, 0);
 }
 
 static bool unexpected_starting_state(struct intel_engine_cs *engine)
@@ -3753,7 +3786,7 @@ out_replay:
                     head, ce->ring->tail);
        __execlists_reset_reg_state(ce, engine);
        __execlists_update_reg_state(ce, engine, head);
-       ce->lrc_desc |= CTX_DESC_FORCE_RESTORE; /* paranoid: GPU was reset! */
+       ce->lrc.desc |= CTX_DESC_FORCE_RESTORE; /* paranoid: GPU was reset! */
 
 unwind:
        /* Push back any incomplete requests for replay after the reset. */
@@ -4369,8 +4402,11 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
        engine->flags |= I915_ENGINE_SUPPORTS_STATS;
        if (!intel_vgpu_active(engine->i915)) {
                engine->flags |= I915_ENGINE_HAS_SEMAPHORES;
-               if (HAS_LOGICAL_RING_PREEMPTION(engine->i915))
+               if (HAS_LOGICAL_RING_PREEMPTION(engine->i915)) {
                        engine->flags |= I915_ENGINE_HAS_PREEMPTION;
+                       if (IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
+                               engine->flags |= I915_ENGINE_HAS_TIMESLICES;
+               }
        }
 
        if (INTEL_GEN(engine->i915) >= 12)
@@ -4449,6 +4485,7 @@ logical_ring_default_irqs(struct intel_engine_cs *engine)
        engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT << shift;
        engine->irq_keep_mask = GT_CONTEXT_SWITCH_INTERRUPT << shift;
        engine->irq_keep_mask |= GT_CS_MASTER_ERROR_INTERRUPT << shift;
+       engine->irq_keep_mask |= GT_WAIT_SEMAPHORE_INTERRUPT << shift;
 }
 
 static void rcs_submission_override(struct intel_engine_cs *engine)
@@ -4516,6 +4553,11 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)
        else
                execlists->csb_size = GEN11_CSB_ENTRIES;
 
+       if (INTEL_GEN(engine->i915) >= 11) {
+               execlists->ccid |= engine->instance << (GEN11_ENGINE_INSTANCE_SHIFT - 32);
+               execlists->ccid |= engine->class << (GEN11_ENGINE_CLASS_SHIFT - 32);
+       }
+
        reset_csb_pointers(engine);
 
        /* Finally, take ownership and responsibility for cleanup! */
index 6f06ba7..f95ae15 100644 (file)
@@ -929,7 +929,7 @@ create_rewinder(struct intel_context *ce,
                        goto err;
        }
 
-       cs = intel_ring_begin(rq, 10);
+       cs = intel_ring_begin(rq, 14);
        if (IS_ERR(cs)) {
                err = PTR_ERR(cs);
                goto err;
@@ -941,8 +941,8 @@ create_rewinder(struct intel_context *ce,
        *cs++ = MI_SEMAPHORE_WAIT |
                MI_SEMAPHORE_GLOBAL_GTT |
                MI_SEMAPHORE_POLL |
-               MI_SEMAPHORE_SAD_NEQ_SDD;
-       *cs++ = 0;
+               MI_SEMAPHORE_SAD_GTE_SDD;
+       *cs++ = idx;
        *cs++ = offset;
        *cs++ = 0;
 
@@ -951,6 +951,11 @@ create_rewinder(struct intel_context *ce,
        *cs++ = offset + idx * sizeof(u32);
        *cs++ = 0;
 
+       *cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
+       *cs++ = offset;
+       *cs++ = 0;
+       *cs++ = idx + 1;
+
        intel_ring_advance(rq, cs);
 
        rq->sched.attr.priority = I915_PRIORITY_MASK;
@@ -984,7 +989,7 @@ static int live_timeslice_rewind(void *arg)
 
        for_each_engine(engine, gt, id) {
                enum { A1, A2, B1 };
-               enum { X = 1, Y, Z };
+               enum { X = 1, Z, Y };
                struct i915_request *rq[3] = {};
                struct intel_context *ce;
                unsigned long heartbeat;
@@ -1017,13 +1022,13 @@ static int live_timeslice_rewind(void *arg)
                        goto err;
                }
 
-               rq[0] = create_rewinder(ce, NULL, slot, 1);
+               rq[0] = create_rewinder(ce, NULL, slot, X);
                if (IS_ERR(rq[0])) {
                        intel_context_put(ce);
                        goto err;
                }
 
-               rq[1] = create_rewinder(ce, NULL, slot, 2);
+               rq[1] = create_rewinder(ce, NULL, slot, Y);
                intel_context_put(ce);
                if (IS_ERR(rq[1]))
                        goto err;
@@ -1041,7 +1046,7 @@ static int live_timeslice_rewind(void *arg)
                        goto err;
                }
 
-               rq[2] = create_rewinder(ce, rq[0], slot, 3);
+               rq[2] = create_rewinder(ce, rq[0], slot, Z);
                intel_context_put(ce);
                if (IS_ERR(rq[2]))
                        goto err;
@@ -1055,15 +1060,12 @@ static int live_timeslice_rewind(void *arg)
                GEM_BUG_ON(!timer_pending(&engine->execlists.timer));
 
                /* ELSP[] = { { A:rq1, A:rq2 }, { B:rq1 } } */
-               GEM_BUG_ON(!i915_request_is_active(rq[A1]));
-               GEM_BUG_ON(!i915_request_is_active(rq[A2]));
-               GEM_BUG_ON(!i915_request_is_active(rq[B1]));
-
-               /* Wait for the timeslice to kick in */
-               del_timer(&engine->execlists.timer);
-               tasklet_hi_schedule(&engine->execlists.tasklet);
-               intel_engine_flush_submission(engine);
-
+               if (i915_request_is_active(rq[A2])) { /* semaphore yielded! */
+                       /* Wait for the timeslice to kick in */
+                       del_timer(&engine->execlists.timer);
+                       tasklet_hi_schedule(&engine->execlists.tasklet);
+                       intel_engine_flush_submission(engine);
+               }
                /* -> ELSP[] = { { A:rq1 }, { B:rq1 } } */
                GEM_BUG_ON(!i915_request_is_active(rq[A1]));
                GEM_BUG_ON(!i915_request_is_active(rq[B1]));
index fe7778c..aa6d56e 100644 (file)
@@ -217,7 +217,7 @@ static void guc_wq_item_append(struct intel_guc *guc,
 static void guc_add_request(struct intel_guc *guc, struct i915_request *rq)
 {
        struct intel_engine_cs *engine = rq->engine;
-       u32 ctx_desc = lower_32_bits(rq->context->lrc_desc);
+       u32 ctx_desc = rq->context->lrc.ccid;
        u32 ring_tail = intel_ring_set_tail(rq->ring, rq->tail) / sizeof(u64);
 
        guc_wq_item_append(guc, engine->guc_id, ctx_desc,
index a83df2f..a1696e9 100644 (file)
@@ -208,14 +208,41 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
                                SKL_FUSE_PG_DIST_STATUS(SKL_PG0) |
                                SKL_FUSE_PG_DIST_STATUS(SKL_PG1) |
                                SKL_FUSE_PG_DIST_STATUS(SKL_PG2);
-               vgpu_vreg_t(vgpu, LCPLL1_CTL) |=
-                               LCPLL_PLL_ENABLE |
-                               LCPLL_PLL_LOCK;
-               vgpu_vreg_t(vgpu, LCPLL2_CTL) |= LCPLL_PLL_ENABLE;
-
+               /*
+                * Only 1 PIPE enabled in current vGPU display and PIPE_A is
+                *  tied to TRANSCODER_A in HW, so it's safe to assume PIPE_A,
+                *   TRANSCODER_A can be enabled. PORT_x depends on the input of
+                *   setup_virtual_dp_monitor, we can bind DPLL0 to any PORT_x
+                *   so we fixed to DPLL0 here.
+                * Setup DPLL0: DP link clk 1620 MHz, non SSC, DP Mode
+                */
+               vgpu_vreg_t(vgpu, DPLL_CTRL1) =
+                       DPLL_CTRL1_OVERRIDE(DPLL_ID_SKL_DPLL0);
+               vgpu_vreg_t(vgpu, DPLL_CTRL1) |=
+                       DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620, DPLL_ID_SKL_DPLL0);
+               vgpu_vreg_t(vgpu, LCPLL1_CTL) =
+                       LCPLL_PLL_ENABLE | LCPLL_PLL_LOCK;
+               vgpu_vreg_t(vgpu, DPLL_STATUS) = DPLL_LOCK(DPLL_ID_SKL_DPLL0);
+               /*
+                * Golden M/N are calculated based on:
+                *   24 bpp, 4 lanes, 154000 pixel clk (from virtual EDID),
+                *   DP link clk 1620 MHz and non-constant_n.
+                * TODO: calculate DP link symbol clk and stream clk m/n.
+                */
+               vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) = 63 << TU_SIZE_SHIFT;
+               vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) |= 0x5b425e;
+               vgpu_vreg_t(vgpu, PIPE_DATA_N1(TRANSCODER_A)) = 0x800000;
+               vgpu_vreg_t(vgpu, PIPE_LINK_M1(TRANSCODER_A)) = 0x3cd6e;
+               vgpu_vreg_t(vgpu, PIPE_LINK_N1(TRANSCODER_A)) = 0x80000;
        }
 
        if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) &=
+                       ~DPLL_CTRL2_DDI_CLK_OFF(PORT_B);
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
+                       DPLL_CTRL2_DDI_CLK_SEL(DPLL_ID_SKL_DPLL0, PORT_B);
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
+                       DPLL_CTRL2_DDI_SEL_OVERRIDE(PORT_B);
                vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIB_DETECTED;
                vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
                        ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
@@ -236,6 +263,12 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
        }
 
        if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) &=
+                       ~DPLL_CTRL2_DDI_CLK_OFF(PORT_C);
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
+                       DPLL_CTRL2_DDI_CLK_SEL(DPLL_ID_SKL_DPLL0, PORT_C);
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
+                       DPLL_CTRL2_DDI_SEL_OVERRIDE(PORT_C);
                vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTC_HOTPLUG_CPT;
                vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
                        ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
@@ -256,6 +289,12 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
        }
 
        if (intel_vgpu_has_monitor_on_port(vgpu, PORT_D)) {
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) &=
+                       ~DPLL_CTRL2_DDI_CLK_OFF(PORT_D);
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
+                       DPLL_CTRL2_DDI_CLK_SEL(DPLL_ID_SKL_DPLL0, PORT_D);
+               vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
+                       DPLL_CTRL2_DDI_SEL_OVERRIDE(PORT_D);
                vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTD_HOTPLUG_CPT;
                vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
                        ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
index cb11c31..e92ed96 100644 (file)
@@ -290,7 +290,7 @@ static void
 shadow_context_descriptor_update(struct intel_context *ce,
                                 struct intel_vgpu_workload *workload)
 {
-       u64 desc = ce->lrc_desc;
+       u64 desc = ce->lrc.desc;
 
        /*
         * Update bits 0-11 of the context descriptor which includes flags
@@ -300,7 +300,7 @@ shadow_context_descriptor_update(struct intel_context *ce,
        desc |= (u64)workload->ctx_desc.addressing_mode <<
                GEN8_CTX_ADDRESSING_MODE_SHIFT;
 
-       ce->lrc_desc = desc;
+       ce->lrc.desc = desc;
 }
 
 static int copy_workload_to_ring_buffer(struct intel_vgpu_workload *workload)
@@ -379,7 +379,11 @@ static void set_context_ppgtt_from_shadow(struct intel_vgpu_workload *workload,
                for (i = 0; i < GVT_RING_CTX_NR_PDPS; i++) {
                        struct i915_page_directory * const pd =
                                i915_pd_entry(ppgtt->pd, i);
-
+                       /* skip now as current i915 ppgtt alloc won't allocate
+                          top level pdp for non 4-level table, won't impact
+                          shadow ppgtt. */
+                       if (!pd)
+                               break;
                        px_dma(pd) = mm->ppgtt_mm.shadow_pdps[i];
                }
        }
index 4518b9b..02ad1ac 100644 (file)
@@ -128,6 +128,13 @@ search_again:
        active = NULL;
        INIT_LIST_HEAD(&eviction_list);
        list_for_each_entry_safe(vma, next, &vm->bound_list, vm_link) {
+               if (vma == active) { /* now seen this vma twice */
+                       if (flags & PIN_NONBLOCK)
+                               break;
+
+                       active = ERR_PTR(-EAGAIN);
+               }
+
                /*
                 * We keep this list in a rough least-recently scanned order
                 * of active elements (inactive elements are cheap to reap).
@@ -143,21 +150,12 @@ search_again:
                 * To notice when we complete one full cycle, we record the
                 * first active element seen, before moving it to the tail.
                 */
-               if (i915_vma_is_active(vma)) {
-                       if (vma == active) {
-                               if (flags & PIN_NONBLOCK)
-                                       break;
-
-                               active = ERR_PTR(-EAGAIN);
-                       }
-
-                       if (active != ERR_PTR(-EAGAIN)) {
-                               if (!active)
-                                       active = vma;
+               if (active != ERR_PTR(-EAGAIN) && i915_vma_is_active(vma)) {
+                       if (!active)
+                               active = vma;
 
-                               list_move_tail(&vma->vm_link, &vm->bound_list);
-                               continue;
-                       }
+                       list_move_tail(&vma->vm_link, &vm->bound_list);
+                       continue;
                }
 
                if (mark_free(&scan, vma, flags, &eviction_list))
index 2a4cd0b..5c8e51d 100644 (file)
@@ -1207,8 +1207,6 @@ static void engine_record_registers(struct intel_engine_coredump *ee)
 static void record_request(const struct i915_request *request,
                           struct i915_request_coredump *erq)
 {
-       const struct i915_gem_context *ctx;
-
        erq->flags = request->fence.flags;
        erq->context = request->fence.context;
        erq->seqno = request->fence.seqno;
@@ -1219,9 +1217,13 @@ static void record_request(const struct i915_request *request,
 
        erq->pid = 0;
        rcu_read_lock();
-       ctx = rcu_dereference(request->context->gem_context);
-       if (ctx)
-               erq->pid = pid_nr(ctx->pid);
+       if (!intel_context_is_closed(request->context)) {
+               const struct i915_gem_context *ctx;
+
+               ctx = rcu_dereference(request->context->gem_context);
+               if (ctx)
+                       erq->pid = pid_nr(ctx->pid);
+       }
        rcu_read_unlock();
 }
 
index d91557d..8a2b838 100644 (file)
@@ -3361,7 +3361,7 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
        u32 de_pipe_masked = gen8_de_pipe_fault_mask(dev_priv) |
                GEN8_PIPE_CDCLK_CRC_DONE;
        u32 de_pipe_enables;
-       u32 de_port_masked = GEN8_AUX_CHANNEL_A;
+       u32 de_port_masked = gen8_de_port_aux_mask(dev_priv);
        u32 de_port_enables;
        u32 de_misc_masked = GEN8_DE_EDP_PSR;
        enum pipe pipe;
@@ -3369,18 +3369,8 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
        if (INTEL_GEN(dev_priv) <= 10)
                de_misc_masked |= GEN8_DE_MISC_GSE;
 
-       if (INTEL_GEN(dev_priv) >= 9) {
-               de_port_masked |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C |
-                                 GEN9_AUX_CHANNEL_D;
-               if (IS_GEN9_LP(dev_priv))
-                       de_port_masked |= BXT_DE_PORT_GMBUS;
-       }
-
-       if (INTEL_GEN(dev_priv) >= 11)
-               de_port_masked |= ICL_AUX_CHANNEL_E;
-
-       if (IS_CNL_WITH_PORT_F(dev_priv) || INTEL_GEN(dev_priv) >= 11)
-               de_port_masked |= CNL_AUX_CHANNEL_F;
+       if (IS_GEN9_LP(dev_priv))
+               de_port_masked |= BXT_DE_PORT_GMBUS;
 
        de_pipe_enables = de_pipe_masked | GEN8_PIPE_VBLANK |
                                           GEN8_PIPE_FIFO_UNDERRUN;
index 66a46e4..cf2c01f 100644 (file)
@@ -1310,8 +1310,7 @@ static int oa_get_render_ctx_id(struct i915_perf_stream *stream)
                         * dropped by GuC. They won't be part of the context
                         * ID in the OA reports, so squash those lower bits.
                         */
-                       stream->specific_ctx_id =
-                               lower_32_bits(ce->lrc_desc) >> 12;
+                       stream->specific_ctx_id = ce->lrc.lrca >> 12;
 
                        /*
                         * GuC uses the top bit to signal proxy submission, so
@@ -1328,11 +1327,10 @@ static int oa_get_render_ctx_id(struct i915_perf_stream *stream)
                        ((1U << GEN11_SW_CTX_ID_WIDTH) - 1) << (GEN11_SW_CTX_ID_SHIFT - 32);
                /*
                 * Pick an unused context id
-                * 0 - (NUM_CONTEXT_TAG - 1) are used by other contexts
+                * 0 - BITS_PER_LONG are used by other contexts
                 * GEN12_MAX_CONTEXT_HW_ID (0x7ff) is used by idle context
                 */
                stream->specific_ctx_id = (GEN12_MAX_CONTEXT_HW_ID - 1) << (GEN11_SW_CTX_ID_SHIFT - 32);
-               BUILD_BUG_ON((GEN12_MAX_CONTEXT_HW_ID - 1) < NUM_CONTEXT_TAG);
                break;
        }
 
index e0c6021..6e12000 100644 (file)
@@ -3094,6 +3094,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 #define GT_BSD_CS_ERROR_INTERRUPT              (1 << 15)
 #define GT_BSD_USER_INTERRUPT                  (1 << 12)
 #define GT_RENDER_L3_PARITY_ERROR_INTERRUPT_S1 (1 << 11) /* hsw+; rsvd on snb, ivb, vlv */
+#define GT_WAIT_SEMAPHORE_INTERRUPT            REG_BIT(11) /* bdw+ */
 #define GT_CONTEXT_SWITCH_INTERRUPT            (1 <<  8)
 #define GT_RENDER_L3_PARITY_ERROR_INTERRUPT    (1 <<  5) /* !snb */
 #define GT_RENDER_PIPECTL_NOTIFY_INTERRUPT     (1 <<  4)
index c0df71d..e2b78db 100644 (file)
@@ -1017,11 +1017,15 @@ i915_request_await_request(struct i915_request *to, struct i915_request *from)
        GEM_BUG_ON(to == from);
        GEM_BUG_ON(to->timeline == from->timeline);
 
-       if (i915_request_completed(from))
+       if (i915_request_completed(from)) {
+               i915_sw_fence_set_error_once(&to->submit, from->fence.error);
                return 0;
+       }
 
        if (to->engine->schedule) {
-               ret = i915_sched_node_add_dependency(&to->sched, &from->sched);
+               ret = i915_sched_node_add_dependency(&to->sched,
+                                                    &from->sched,
+                                                    I915_DEPENDENCY_EXTERNAL);
                if (ret < 0)
                        return ret;
        }
@@ -1183,7 +1187,9 @@ __i915_request_await_execution(struct i915_request *to,
 
        /* Couple the dependency tree for PI on this exposed to->fence */
        if (to->engine->schedule) {
-               err = i915_sched_node_add_dependency(&to->sched, &from->sched);
+               err = i915_sched_node_add_dependency(&to->sched,
+                                                    &from->sched,
+                                                    I915_DEPENDENCY_WEAK);
                if (err < 0)
                        return err;
        }
index 68b06a7..f0a9e89 100644 (file)
@@ -456,7 +456,8 @@ bool __i915_sched_node_add_dependency(struct i915_sched_node *node,
 }
 
 int i915_sched_node_add_dependency(struct i915_sched_node *node,
-                                  struct i915_sched_node *signal)
+                                  struct i915_sched_node *signal,
+                                  unsigned long flags)
 {
        struct i915_dependency *dep;
 
@@ -465,8 +466,7 @@ int i915_sched_node_add_dependency(struct i915_sched_node *node,
                return -ENOMEM;
 
        if (!__i915_sched_node_add_dependency(node, signal, dep,
-                                             I915_DEPENDENCY_EXTERNAL |
-                                             I915_DEPENDENCY_ALLOC))
+                                             flags | I915_DEPENDENCY_ALLOC))
                i915_dependency_free(dep);
 
        return 0;
index d1dc4ef..6f0bf00 100644 (file)
@@ -34,7 +34,8 @@ bool __i915_sched_node_add_dependency(struct i915_sched_node *node,
                                      unsigned long flags);
 
 int i915_sched_node_add_dependency(struct i915_sched_node *node,
-                                  struct i915_sched_node *signal);
+                                  struct i915_sched_node *signal,
+                                  unsigned long flags);
 
 void i915_sched_node_fini(struct i915_sched_node *node);
 
index d18e705..7186875 100644 (file)
@@ -78,6 +78,7 @@ struct i915_dependency {
        unsigned long flags;
 #define I915_DEPENDENCY_ALLOC          BIT(0)
 #define I915_DEPENDENCY_EXTERNAL       BIT(1)
+#define I915_DEPENDENCY_WEAK           BIT(2)
 };
 
 #endif /* _I915_SCHEDULER_TYPES_H_ */
index 82e3bc2..2cd7a7e 100644 (file)
@@ -1228,18 +1228,6 @@ int __i915_vma_unbind(struct i915_vma *vma)
 
        lockdep_assert_held(&vma->vm->mutex);
 
-       /*
-        * First wait upon any activity as retiring the request may
-        * have side-effects such as unpinning or even unbinding this vma.
-        *
-        * XXX Actually waiting under the vm->mutex is a hinderance and
-        * should be pipelined wherever possible. In cases where that is
-        * unavoidable, we should lift the wait to before the mutex.
-        */
-       ret = i915_vma_sync(vma);
-       if (ret)
-               return ret;
-
        if (i915_vma_is_pinned(vma)) {
                vma_print_allocator(vma, "is pinned");
                return -EAGAIN;
@@ -1313,15 +1301,20 @@ int i915_vma_unbind(struct i915_vma *vma)
        if (!drm_mm_node_allocated(&vma->node))
                return 0;
 
-       if (i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND))
-               /* XXX not always required: nop_clear_range */
-               wakeref = intel_runtime_pm_get(&vm->i915->runtime_pm);
-
        /* Optimistic wait before taking the mutex */
        err = i915_vma_sync(vma);
        if (err)
                goto out_rpm;
 
+       if (i915_vma_is_pinned(vma)) {
+               vma_print_allocator(vma, "is pinned");
+               return -EAGAIN;
+       }
+
+       if (i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND))
+               /* XXX not always required: nop_clear_range */
+               wakeref = intel_runtime_pm_get(&vm->i915->runtime_pm);
+
        err = mutex_lock_interruptible(&vm->mutex);
        if (err)
                goto out_rpm;
index 8375054..a52986a 100644 (file)
@@ -4992,7 +4992,7 @@ static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
         * WaIncreaseLatencyIPCEnabled: kbl,cfl
         * Display WA #1141: kbl,cfl
         */
-       if ((IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv)) ||
+       if ((IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv)) &&
            dev_priv->ipc_enabled)
                latency += 4;
 
index 58b5f40..af89c7f 100644 (file)
@@ -173,7 +173,7 @@ static int igt_vma_create(void *arg)
                }
 
                nc = 0;
-               for_each_prime_number(num_ctx, 2 * NUM_CONTEXT_TAG) {
+               for_each_prime_number(num_ctx, 2 * BITS_PER_LONG) {
                        for (; nc < num_ctx; nc++) {
                                ctx = mock_context(i915, "mock");
                                if (!ctx)
index b5f5eb7..8c2e1b4 100644 (file)
@@ -412,9 +412,7 @@ static int __maybe_unused meson_drv_pm_resume(struct device *dev)
        if (priv->afbcd.ops)
                priv->afbcd.ops->init(priv);
 
-       drm_mode_config_helper_resume(priv->drm);
-
-       return 0;
+       return drm_mode_config_helper_resume(priv->drm);
 }
 
 static int compare_of(struct device *dev, void *data)
index bd26802..583cd6e 100644 (file)
@@ -1039,6 +1039,7 @@ void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
 
 static bool host1x_drm_wants_iommu(struct host1x_device *dev)
 {
+       struct host1x *host1x = dev_get_drvdata(dev->dev.parent);
        struct iommu_domain *domain;
 
        /*
@@ -1076,7 +1077,7 @@ static bool host1x_drm_wants_iommu(struct host1x_device *dev)
         * sufficient and whether or not the host1x is attached to an IOMMU
         * doesn't matter.
         */
-       if (!domain && dma_get_mask(dev->dev.parent) <= DMA_BIT_MASK(32))
+       if (!domain && host1x_get_dma_mask(host1x) <= DMA_BIT_MASK(32))
                return true;
 
        return domain != NULL;
index 8cdcd6e..3596f39 100644 (file)
@@ -850,7 +850,7 @@ extern void vmw_bo_bo_free(struct ttm_buffer_object *bo);
 extern int vmw_bo_init(struct vmw_private *dev_priv,
                       struct vmw_buffer_object *vmw_bo,
                       size_t size, struct ttm_placement *placement,
-                      bool interuptable,
+                      bool interruptible,
                       void (*bo_free)(struct ttm_buffer_object *bo));
 extern int vmw_user_bo_verify_access(struct ttm_buffer_object *bo,
                                     struct ttm_object_file *tfile);
index 178a6cd..0f8d293 100644 (file)
@@ -515,7 +515,7 @@ bool vmw_fence_obj_signaled(struct vmw_fence_obj *fence)
        struct vmw_fence_manager *fman = fman_from_fence(fence);
 
        if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->base.flags))
-               return 1;
+               return true;
 
        vmw_fences_update(fman);
 
index 7ef51fa..126f93c 100644 (file)
@@ -1651,7 +1651,7 @@ vmw_gb_surface_reference_internal(struct drm_device *dev,
        struct vmw_surface_metadata *metadata;
        struct ttm_base_object *base;
        uint32_t backup_handle;
-       int ret = -EINVAL;
+       int ret;
 
        ret = vmw_surface_handle_reference(dev_priv, file_priv, req->sid,
                                           req->handle_type, &base);
index 388bcc2..d24344e 100644 (file)
@@ -192,17 +192,55 @@ static void host1x_setup_sid_table(struct host1x *host)
        }
 }
 
+static bool host1x_wants_iommu(struct host1x *host1x)
+{
+       /*
+        * If we support addressing a maximum of 32 bits of physical memory
+        * and if the host1x firewall is enabled, there's no need to enable
+        * IOMMU support. This can happen for example on Tegra20, Tegra30
+        * and Tegra114.
+        *
+        * Tegra124 and later can address up to 34 bits of physical memory and
+        * many platforms come equipped with more than 2 GiB of system memory,
+        * which requires crossing the 4 GiB boundary. But there's a catch: on
+        * SoCs before Tegra186 (i.e. Tegra124 and Tegra210), the host1x can
+        * only address up to 32 bits of memory in GATHER opcodes, which means
+        * that command buffers need to either be in the first 2 GiB of system
+        * memory (which could quickly lead to memory exhaustion), or command
+        * buffers need to be treated differently from other buffers (which is
+        * not possible with the current ABI).
+        *
+        * A third option is to use the IOMMU in these cases to make sure all
+        * buffers will be mapped into a 32-bit IOVA space that host1x can
+        * address. This allows all of the system memory to be used and works
+        * within the limitations of the host1x on these SoCs.
+        *
+        * In summary, default to enable IOMMU on Tegra124 and later. For any
+        * of the earlier SoCs, only use the IOMMU for additional safety when
+        * the host1x firewall is disabled.
+        */
+       if (host1x->info->dma_mask <= DMA_BIT_MASK(32)) {
+               if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL))
+                       return false;
+       }
+
+       return true;
+}
+
 static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
 {
        struct iommu_domain *domain = iommu_get_domain_for_dev(host->dev);
        int err;
 
        /*
-        * If the host1x firewall is enabled, there's no need to enable IOMMU
-        * support. Similarly, if host1x is already attached to an IOMMU (via
-        * the DMA API), don't try to attach again.
+        * We may not always want to enable IOMMU support (for example if the
+        * host1x firewall is already enabled and we don't support addressing
+        * more than 32 bits of physical memory), so check for that first.
+        *
+        * Similarly, if host1x is already attached to an IOMMU (via the DMA
+        * API), don't try to attach again.
         */
-       if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) || domain)
+       if (!host1x_wants_iommu(host) || domain)
                return domain;
 
        host->group = iommu_group_get(host->dev);
@@ -502,6 +540,19 @@ static void __exit tegra_host1x_exit(void)
 }
 module_exit(tegra_host1x_exit);
 
+/**
+ * host1x_get_dma_mask() - query the supported DMA mask for host1x
+ * @host1x: host1x instance
+ *
+ * Note that this returns the supported DMA mask for host1x, which can be
+ * different from the applicable DMA mask under certain circumstances.
+ */
+u64 host1x_get_dma_mask(struct host1x *host1x)
+{
+       return host1x->info->dma_mask;
+}
+EXPORT_SYMBOL(host1x_get_dma_mask);
+
 MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");
 MODULE_AUTHOR("Terje Bergstrom <tbergstrom@nvidia.com>");
 MODULE_DESCRIPTION("Host1x driver for Tegra products");
index 53b517d..4af2fc3 100644 (file)
@@ -244,9 +244,9 @@ static ssize_t da9052_tsi_show(struct device *dev,
        int channel = to_sensor_dev_attr(devattr)->index;
        int ret;
 
-       mutex_lock(&hwmon->hwmon_lock);
+       mutex_lock(&hwmon->da9052->auxadc_lock);
        ret = __da9052_read_tsi(dev, channel);
-       mutex_unlock(&hwmon->hwmon_lock);
+       mutex_unlock(&hwmon->da9052->auxadc_lock);
 
        if (ret < 0)
                return ret;
index 9179460..0d4f3d9 100644 (file)
@@ -346,7 +346,7 @@ static int drivetemp_identify_sata(struct drivetemp_data *st)
        st->have_temp_highest = temp_is_valid(buf[SCT_STATUS_TEMP_HIGHEST]);
 
        if (!have_sct_data_table)
-               goto skip_sct;
+               goto skip_sct_data;
 
        /* Request and read temperature history table */
        memset(buf, '\0', sizeof(st->smartdata));
index 1f5743d..a7eb10d 100644 (file)
@@ -41,6 +41,7 @@
 #define FANCTL_MAX             4       /* Counted from 1 */
 #define TCPU_MAX               8       /* Counted from 1 */
 #define TEMP_MAX               4       /* Counted from 1 */
+#define SMI_STS_MAX            10      /* Counted from 1 */
 
 #define VT_ADC_CTRL0_REG       0x20    /* Bank 0 */
 #define VT_ADC_CTRL1_REG       0x21    /* Bank 0 */
@@ -361,6 +362,7 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel,
        struct nct7904_data *data = dev_get_drvdata(dev);
        int ret, temp;
        unsigned int reg1, reg2, reg3;
+       s8 temps;
 
        switch (attr) {
        case hwmon_temp_input:
@@ -466,7 +468,8 @@ static int nct7904_read_temp(struct device *dev, u32 attr, int channel,
 
        if (ret < 0)
                return ret;
-       *val = ret * 1000;
+       temps = ret;
+       *val = temps * 1000;
        return 0;
 }
 
@@ -1009,6 +1012,13 @@ static int nct7904_probe(struct i2c_client *client,
                data->fan_mode[i] = ret;
        }
 
+       /* Read all of SMI status register to clear alarms */
+       for (i = 0; i < SMI_STS_MAX; i++) {
+               ret = nct7904_read_reg(data, BANK_0, SMI_STS1_REG + i);
+               if (ret < 0)
+                       return ret;
+       }
+
        hwmon_dev =
                devm_hwmon_device_register_with_info(dev, client->name, data,
                                                     &nct7904_chip_info, NULL);
index dff4e17..7f10312 100644 (file)
@@ -542,7 +542,7 @@ int i2c_pca_add_numbered_bus(struct i2c_adapter *adap)
 EXPORT_SYMBOL(i2c_pca_add_numbered_bus);
 
 MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>, "
-       "Wolfram Sang <w.sang@pengutronix.de>");
+       "Wolfram Sang <kernel@pengutronix.de>");
 MODULE_DESCRIPTION("I2C-Bus PCA9564/PCA9665 algorithm");
 MODULE_LICENSE("GPL");
 
index f5c00f9..16ddc26 100644 (file)
@@ -70,6 +70,7 @@
  * @isr_mask: cached copy of local ISR enables.
  * @isr_status: cached copy of local ISR status.
  * @lock: spinlock for IRQ synchronization.
+ * @isr_mutex: mutex for IRQ thread.
  */
 struct altr_i2c_dev {
        void __iomem *base;
@@ -86,6 +87,7 @@ struct altr_i2c_dev {
        u32 isr_mask;
        u32 isr_status;
        spinlock_t lock;        /* IRQ synchronization */
+       struct mutex isr_mutex;
 };
 
 static void
@@ -245,10 +247,11 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
        struct altr_i2c_dev *idev = _dev;
        u32 status = idev->isr_status;
 
+       mutex_lock(&idev->isr_mutex);
        if (!idev->msg) {
                dev_warn(idev->dev, "unexpected interrupt\n");
                altr_i2c_int_clear(idev, ALTR_I2C_ALL_IRQ);
-               return IRQ_HANDLED;
+               goto out;
        }
        read = (idev->msg->flags & I2C_M_RD) != 0;
 
@@ -301,6 +304,8 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
                complete(&idev->msg_complete);
                dev_dbg(idev->dev, "Message Complete\n");
        }
+out:
+       mutex_unlock(&idev->isr_mutex);
 
        return IRQ_HANDLED;
 }
@@ -312,6 +317,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
        u32 value;
        u8 addr = i2c_8bit_addr_from_msg(msg);
 
+       mutex_lock(&idev->isr_mutex);
        idev->msg = msg;
        idev->msg_len = msg->len;
        idev->buf = msg->buf;
@@ -336,6 +342,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
                altr_i2c_int_enable(idev, imask, true);
                altr_i2c_fill_tx_fifo(idev);
        }
+       mutex_unlock(&idev->isr_mutex);
 
        time_left = wait_for_completion_timeout(&idev->msg_complete,
                                                ALTR_I2C_XFER_TIMEOUT);
@@ -409,6 +416,7 @@ static int altr_i2c_probe(struct platform_device *pdev)
        idev->dev = &pdev->dev;
        init_completion(&idev->msg_complete);
        spin_lock_init(&idev->lock);
+       mutex_init(&idev->isr_mutex);
 
        ret = device_property_read_u32(idev->dev, "fifo-size",
                                       &idev->fifo_size);
index 0aba51a..37b96ac 100644 (file)
@@ -845,6 +845,18 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
                                                         PINCTRL_STATE_DEFAULT);
        dev->pinctrl_pins_gpio = pinctrl_lookup_state(dev->pinctrl,
                                                      "gpio");
+       if (IS_ERR(dev->pinctrl_pins_default) ||
+           IS_ERR(dev->pinctrl_pins_gpio)) {
+               dev_info(&pdev->dev, "pinctrl states incomplete for recovery\n");
+               return -EINVAL;
+       }
+
+       /*
+        * pins will be taken as GPIO, so we might as well inform pinctrl about
+        * this and move the state to GPIO
+        */
+       pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_gpio);
+
        rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
        if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER)
                return -EPROBE_DEFER;
@@ -855,9 +867,7 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
                return -EPROBE_DEFER;
 
        if (IS_ERR(rinfo->sda_gpiod) ||
-           IS_ERR(rinfo->scl_gpiod) ||
-           IS_ERR(dev->pinctrl_pins_default) ||
-           IS_ERR(dev->pinctrl_pins_gpio)) {
+           IS_ERR(rinfo->scl_gpiod)) {
                dev_info(&pdev->dev, "recovery information incomplete\n");
                if (!IS_ERR(rinfo->sda_gpiod)) {
                        gpiod_put(rinfo->sda_gpiod);
@@ -867,9 +877,13 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
                        gpiod_put(rinfo->scl_gpiod);
                        rinfo->scl_gpiod = NULL;
                }
+               pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);
                return -EINVAL;
        }
 
+       /* change the state of the pins back to their default state */
+       pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);
+
        dev_info(&pdev->dev, "using scl, sda for recovery\n");
 
        rinfo->prepare_recovery = at91_prepare_twi_recovery;
index a669127..1f1442d 100644 (file)
@@ -7,7 +7,7 @@
  *   Mux support by Rodolfo Giometti <giometti@enneenne.com> and
  *   Michael Lawnick <michael.lawnick.ext@nsn.com>
  *
- * Copyright (C) 2013-2017 Wolfram Sang <wsa@the-dreams.de>
+ * Copyright (C) 2013-2017 Wolfram Sang <wsa@kernel.org>
  */
 
 #define pr_fmt(fmt) "i2c-core: " fmt
@@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev)
                } else if (ACPI_COMPANION(dev)) {
                        irq = i2c_acpi_get_irq(client);
                }
-               if (irq == -EPROBE_DEFER)
-                       return irq;
+               if (irq == -EPROBE_DEFER) {
+                       status = irq;
+                       goto put_sync_adapter;
+               }
 
                if (irq < 0)
                        irq = 0;
@@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev)
         */
        if (!driver->id_table &&
            !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
-           !i2c_of_match_device(dev->driver->of_match_table, client))
-               return -ENODEV;
+           !i2c_of_match_device(dev->driver->of_match_table, client)) {
+               status = -ENODEV;
+               goto put_sync_adapter;
+       }
 
        if (client->flags & I2C_CLIENT_WAKE) {
                int wakeirq;
 
                wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
-               if (wakeirq == -EPROBE_DEFER)
-                       return wakeirq;
+               if (wakeirq == -EPROBE_DEFER) {
+                       status = wakeirq;
+                       goto put_sync_adapter;
+               }
 
                device_init_wakeup(&client->dev, true);
 
@@ -408,6 +414,10 @@ err_detach_pm_domain:
 err_clear_wakeup_irq:
        dev_pm_clear_wake_irq(&client->dev);
        device_init_wakeup(&client->dev, false);
+put_sync_adapter:
+       if (client->flags & I2C_CLIENT_HOST_NOTIFY)
+               pm_runtime_put_sync(&client->adapter->dev);
+
        return status;
 }
 
index 6787c1f..3ed74aa 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (C) 2008 Jochen Friedrich <jochen@scram.de>
  * based on a previous patch from Jon Smirl <jonsmirl@gmail.com>
  *
- * Copyright (C) 2013, 2018 Wolfram Sang <wsa@the-dreams.de>
+ * Copyright (C) 2013, 2018 Wolfram Sang <wsa@kernel.org>
  */
 
 #include <dt-bindings/i2c/i2c.h>
index 0e16490..5365199 100644 (file)
@@ -272,6 +272,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
 err_rollback_available:
        device_remove_file(&pdev->dev, &dev_attr_available_masters);
 err_rollback:
+       i2c_demux_deactivate_master(priv);
        for (j = 0; j < i; j++) {
                of_node_put(priv->chan[j].parent_np);
                of_changeset_destroy(&priv->chan[j].chgset);
index 717b798..a670209 100644 (file)
@@ -1553,8 +1553,11 @@ int ib_cache_setup_one(struct ib_device *device)
        if (err)
                return err;
 
-       rdma_for_each_port (device, p)
-               ib_cache_update(device, p, true);
+       rdma_for_each_port (device, p) {
+               err = ib_cache_update(device, p, true);
+               if (err)
+                       return err;
+       }
 
        return 0;
 }
index 9eec26d..e16105b 100644 (file)
@@ -1292,11 +1292,10 @@ static int res_get_common_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
        has_cap_net_admin = netlink_capable(skb, CAP_NET_ADMIN);
 
        ret = fill_func(msg, has_cap_net_admin, res, port);
-
-       rdma_restrack_put(res);
        if (ret)
                goto err_free;
 
+       rdma_restrack_put(res);
        nlmsg_end(msg, nlh);
        ib_device_put(device);
        return rdma_nl_unicast(sock_net(skb->sk), msg, NETLINK_CB(skb).portid);
index 177333d..bf8e149 100644 (file)
@@ -459,7 +459,8 @@ alloc_begin_fd_uobject(const struct uverbs_api_object *obj,
        struct ib_uobject *uobj;
        struct file *filp;
 
-       if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release))
+       if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release &&
+                   fd_type->fops->release != &uverbs_async_event_release))
                return ERR_PTR(-EINVAL);
 
        new_fd = get_unused_fd_flags(O_CLOEXEC);
index 7df7198..3d189c7 100644 (file)
@@ -219,6 +219,7 @@ void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue);
 void ib_uverbs_init_async_event_file(struct ib_uverbs_async_event_file *ev_file);
 void ib_uverbs_free_event_queue(struct ib_uverbs_event_queue *event_queue);
 void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res);
+int uverbs_async_event_release(struct inode *inode, struct file *filp);
 
 int ib_alloc_ucontext(struct uverbs_attr_bundle *attrs);
 int ib_init_ucontext(struct uverbs_attr_bundle *attrs);
@@ -227,6 +228,9 @@ void ib_uverbs_release_ucq(struct ib_uverbs_completion_event_file *ev_file,
                           struct ib_ucq_object *uobj);
 void ib_uverbs_release_uevent(struct ib_uevent_object *uobj);
 void ib_uverbs_release_file(struct kref *ref);
+void ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
+                            __u64 element, __u64 event,
+                            struct list_head *obj_list, u32 *counter);
 
 void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
 void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
index 17fc25d..1bab8de 100644 (file)
@@ -346,7 +346,7 @@ const struct file_operations uverbs_async_event_fops = {
        .owner   = THIS_MODULE,
        .read    = ib_uverbs_async_event_read,
        .poll    = ib_uverbs_async_event_poll,
-       .release = uverbs_uobject_fd_release,
+       .release = uverbs_async_event_release,
        .fasync  = ib_uverbs_async_event_fasync,
        .llseek  = no_llseek,
 };
@@ -386,10 +386,9 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
        kill_fasync(&ev_queue->async_queue, SIGIO, POLL_IN);
 }
 
-static void
-ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
-                       __u64 element, __u64 event, struct list_head *obj_list,
-                       u32 *counter)
+void ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
+                            __u64 element, __u64 event,
+                            struct list_head *obj_list, u32 *counter)
 {
        struct ib_uverbs_event *entry;
        unsigned long flags;
@@ -1187,9 +1186,6 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
                 */
                mutex_unlock(&uverbs_dev->lists_mutex);
 
-               ib_uverbs_async_handler(READ_ONCE(file->async_file), 0,
-                                       IB_EVENT_DEVICE_FATAL, NULL, NULL);
-
                uverbs_destroy_ufile_hw(file, RDMA_REMOVE_DRIVER_REMOVE);
                kref_put(&file->ref, ib_uverbs_release_file);
 
index 82ec080..61899ea 100644 (file)
@@ -26,10 +26,38 @@ static int uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
                container_of(uobj, struct ib_uverbs_async_event_file, uobj);
 
        ib_unregister_event_handler(&event_file->event_handler);
-       ib_uverbs_free_event_queue(&event_file->ev_queue);
+
+       if (why == RDMA_REMOVE_DRIVER_REMOVE)
+               ib_uverbs_async_handler(event_file, 0, IB_EVENT_DEVICE_FATAL,
+                                       NULL, NULL);
        return 0;
 }
 
+int uverbs_async_event_release(struct inode *inode, struct file *filp)
+{
+       struct ib_uverbs_async_event_file *event_file;
+       struct ib_uobject *uobj = filp->private_data;
+       int ret;
+
+       if (!uobj)
+               return uverbs_uobject_fd_release(inode, filp);
+
+       event_file =
+               container_of(uobj, struct ib_uverbs_async_event_file, uobj);
+
+       /*
+        * The async event FD has to deliver IB_EVENT_DEVICE_FATAL even after
+        * disassociation, so cleaning the event list must only happen after
+        * release. The user knows it has reached the end of the event stream
+        * when it sees IB_EVENT_DEVICE_FATAL.
+        */
+       uverbs_uobject_get(uobj);
+       ret = uverbs_uobject_fd_release(inode, filp);
+       ib_uverbs_free_event_queue(&event_file->ev_queue);
+       uverbs_uobject_put(uobj);
+       return ret;
+}
+
 DECLARE_UVERBS_NAMED_METHOD(
        UVERBS_METHOD_ASYNC_EVENT_ALLOC,
        UVERBS_ATTR_FD(UVERBS_ATTR_ASYNC_EVENT_ALLOC_FD_HANDLE,
index d69dece..30e08bc 100644 (file)
@@ -2891,8 +2891,7 @@ static int peer_abort(struct c4iw_dev *dev, struct sk_buff *skb)
                        srqidx = ABORT_RSS_SRQIDX_G(
                                        be32_to_cpu(req->srqidx_status));
                        if (srqidx) {
-                               complete_cached_srq_buffers(ep,
-                                                           req->srqidx_status);
+                               complete_cached_srq_buffers(ep, srqidx);
                        } else {
                                /* Hold ep ref until finish_peer_abort() */
                                c4iw_get_ep(&ep->com);
@@ -3878,8 +3877,8 @@ static int read_tcb_rpl(struct c4iw_dev *dev, struct sk_buff *skb)
                return 0;
        }
 
-       ep->srqe_idx = t4_tcb_get_field32(tcb, TCB_RQ_START_W, TCB_RQ_START_W,
-                       TCB_RQ_START_S);
+       ep->srqe_idx = t4_tcb_get_field32(tcb, TCB_RQ_START_W, TCB_RQ_START_M,
+                                         TCB_RQ_START_S);
 cleanup:
        pr_debug("ep %p tid %u %016x\n", ep, ep->hwtid, ep->srqe_idx);
 
index 13e4203..a92346e 100644 (file)
@@ -589,10 +589,6 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
 
        set_comp_state(pq, cq, info.comp_idx, QUEUED, 0);
        pq->state = SDMA_PKT_Q_ACTIVE;
-       /* Send the first N packets in the request to buy us some time */
-       ret = user_sdma_send_pkts(req, pcount);
-       if (unlikely(ret < 0 && ret != -EBUSY))
-               goto free_req;
 
        /*
         * This is a somewhat blocking send implementation.
index bb78d32..fa7a5ff 100644 (file)
@@ -1987,7 +1987,6 @@ static int i40iw_addr_resolve_neigh(struct i40iw_device *iwdev,
        struct rtable *rt;
        struct neighbour *neigh;
        int rc = arpindex;
-       struct net_device *netdev = iwdev->netdev;
        __be32 dst_ipaddr = htonl(dst_ip);
        __be32 src_ipaddr = htonl(src_ip);
 
@@ -1997,9 +1996,6 @@ static int i40iw_addr_resolve_neigh(struct i40iw_device *iwdev,
                return rc;
        }
 
-       if (netif_is_bond_slave(netdev))
-               netdev = netdev_master_upper_dev_get(netdev);
-
        neigh = dst_neigh_lookup(&rt->dst, &dst_ipaddr);
 
        rcu_read_lock();
@@ -2065,7 +2061,6 @@ static int i40iw_addr_resolve_neigh_ipv6(struct i40iw_device *iwdev,
 {
        struct neighbour *neigh;
        int rc = arpindex;
-       struct net_device *netdev = iwdev->netdev;
        struct dst_entry *dst;
        struct sockaddr_in6 dst_addr;
        struct sockaddr_in6 src_addr;
@@ -2086,9 +2081,6 @@ static int i40iw_addr_resolve_neigh_ipv6(struct i40iw_device *iwdev,
                return rc;
        }
 
-       if (netif_is_bond_slave(netdev))
-               netdev = netdev_master_upper_dev_get(netdev);
-
        neigh = dst_neigh_lookup(dst, dst_addr.sin6_addr.in6_u.u6_addr32);
 
        rcu_read_lock();
index 55a1fbf..ae8b97c 100644 (file)
@@ -534,7 +534,7 @@ void i40iw_manage_arp_cache(struct i40iw_device *iwdev,
        int arp_index;
 
        arp_index = i40iw_arp_table(iwdev, ip_addr, ipv4, mac_addr, action);
-       if (arp_index == -1)
+       if (arp_index < 0)
                return;
        cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
        if (!cqp_request)
index 2f9f789..cf51e3c 100644 (file)
@@ -2891,6 +2891,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
        int send_size;
        int header_size;
        int spc;
+       int err;
        int i;
 
        if (wr->wr.opcode != IB_WR_SEND)
@@ -2925,7 +2926,9 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
 
        sqp->ud_header.lrh.virtual_lane    = 0;
        sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & IB_SEND_SOLICITED);
-       ib_get_cached_pkey(ib_dev, sqp->qp.port, 0, &pkey);
+       err = ib_get_cached_pkey(ib_dev, sqp->qp.port, 0, &pkey);
+       if (err)
+               return err;
        sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
        if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_TUN_SMI_OWNER)
                sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
@@ -3212,9 +3215,14 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, const struct ib_ud_wr *wr,
        }
        sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & IB_SEND_SOLICITED);
        if (!sqp->qp.ibqp.qp_num)
-               ib_get_cached_pkey(ib_dev, sqp->qp.port, sqp->pkey_index, &pkey);
+               err = ib_get_cached_pkey(ib_dev, sqp->qp.port, sqp->pkey_index,
+                                        &pkey);
        else
-               ib_get_cached_pkey(ib_dev, sqp->qp.port, wr->pkey_index, &pkey);
+               err = ib_get_cached_pkey(ib_dev, sqp->qp.port, wr->pkey_index,
+                                        &pkey);
+       if (err)
+               return err;
+
        sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
        sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
        sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1));
index 48f4812..6a413d7 100644 (file)
@@ -151,7 +151,7 @@ struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *rxe, u32 size,
 
        ip = kmalloc(sizeof(*ip), GFP_KERNEL);
        if (!ip)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        size = PAGE_ALIGN(size);
 
index ff92704..245040c 100644 (file)
@@ -45,12 +45,15 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 
        if (outbuf) {
                ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
-               if (!ip)
+               if (IS_ERR(ip)) {
+                       err = PTR_ERR(ip);
                        goto err1;
+               }
 
-               err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
-               if (err)
+               if (copy_to_user(outbuf, &ip->info, sizeof(ip->info))) {
+                       err = -EFAULT;
                        goto err2;
+               }
 
                spin_lock_bh(&rxe->pending_lock);
                list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
@@ -64,7 +67,7 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 err2:
        kfree(ip);
 err1:
-       return -EINVAL;
+       return err;
 }
 
 inline void rxe_queue_reset(struct rxe_queue *q)
index 1dc3718..2883ac3 100644 (file)
@@ -127,7 +127,8 @@ static inline int get_acpihid_device_id(struct device *dev,
                return -ENODEV;
 
        list_for_each_entry(p, &acpihid_map, list) {
-               if (acpi_dev_hid_uid_match(adev, p->hid, p->uid)) {
+               if (acpi_dev_hid_uid_match(adev, p->hid,
+                                          p->uid[0] ? p->uid : NULL)) {
                        if (entry)
                                *entry = p;
                        return p->devid;
index 2b9a67e..5b81fd1 100644 (file)
@@ -1329,8 +1329,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
                }
                case IVHD_DEV_ACPI_HID: {
                        u16 devid;
-                       u8 hid[ACPIHID_HID_LEN] = {0};
-                       u8 uid[ACPIHID_UID_LEN] = {0};
+                       u8 hid[ACPIHID_HID_LEN];
+                       u8 uid[ACPIHID_UID_LEN];
                        int ret;
 
                        if (h->type != 0x40) {
@@ -1347,6 +1347,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
                                break;
                        }
 
+                       uid[0] = '\0';
                        switch (e->uidf) {
                        case UID_NOT_PRESENT:
 
@@ -1361,8 +1362,8 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
                                break;
                        case UID_IS_CHARACTER:
 
-                               memcpy(uid, (u8 *)(&e->uid), ACPIHID_UID_LEN - 1);
-                               uid[ACPIHID_UID_LEN - 1] = '\0';
+                               memcpy(uid, &e->uid, e->uidl);
+                               uid[e->uidl] = '\0';
 
                                break;
                        default:
index 7b37542..1faa08c 100644 (file)
@@ -693,6 +693,15 @@ out:
        return ret;
 }
 
+static bool iommu_is_attach_deferred(struct iommu_domain *domain,
+                                    struct device *dev)
+{
+       if (domain->ops->is_attach_deferred)
+               return domain->ops->is_attach_deferred(domain, dev);
+
+       return false;
+}
+
 /**
  * iommu_group_add_device - add a device to an iommu group
  * @group: the group into which to add the device (reference should be held)
@@ -747,7 +756,7 @@ rename:
 
        mutex_lock(&group->mutex);
        list_add_tail(&device->list, &group->devices);
-       if (group->domain)
+       if (group->domain  && !iommu_is_attach_deferred(group->domain, dev))
                ret = __iommu_attach_device(group->domain, dev);
        mutex_unlock(&group->mutex);
        if (ret)
@@ -1653,9 +1662,6 @@ static int __iommu_attach_device(struct iommu_domain *domain,
                                 struct device *dev)
 {
        int ret;
-       if ((domain->ops->is_attach_deferred != NULL) &&
-           domain->ops->is_attach_deferred(domain, dev))
-               return 0;
 
        if (unlikely(domain->ops->attach_dev == NULL))
                return -ENODEV;
@@ -1727,8 +1733,7 @@ EXPORT_SYMBOL_GPL(iommu_sva_unbind_gpasid);
 static void __iommu_detach_device(struct iommu_domain *domain,
                                  struct device *dev)
 {
-       if ((domain->ops->is_attach_deferred != NULL) &&
-           domain->ops->is_attach_deferred(domain, dev))
+       if (iommu_is_attach_deferred(domain, dev))
                return;
 
        if (unlikely(domain->ops->detach_dev == NULL))
index 8499b56..c5367e2 100644 (file)
@@ -1370,6 +1370,7 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue *mq, struct request *req)
        struct mmc_request *mrq = &mqrq->brq.mrq;
        struct request_queue *q = req->q;
        struct mmc_host *host = mq->card->host;
+       enum mmc_issue_type issue_type = mmc_issue_type(mq, req);
        unsigned long flags;
        bool put_card;
        int err;
@@ -1399,7 +1400,7 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue *mq, struct request *req)
 
        spin_lock_irqsave(&mq->lock, flags);
 
-       mq->in_flight[mmc_issue_type(mq, req)] -= 1;
+       mq->in_flight[issue_type] -= 1;
 
        put_card = (mmc_tot_in_flight(mq) == 0);
 
index 25bee3d..4b1eb89 100644 (file)
@@ -107,11 +107,10 @@ static enum blk_eh_timer_return mmc_cqe_timed_out(struct request *req)
        case MMC_ISSUE_DCMD:
                if (host->cqe_ops->cqe_timeout(host, mrq, &recovery_needed)) {
                        if (recovery_needed)
-                               __mmc_cqe_recovery_notifier(mq);
+                               mmc_cqe_recovery_notifier(mrq);
                        return BLK_EH_RESET_TIMER;
                }
-               /* No timeout (XXX: huh? comment doesn't make much sense) */
-               blk_mq_complete_request(req);
+               /* The request has gone already */
                return BLK_EH_DONE;
        default:
                /* Timeout is handled by mmc core */
@@ -127,18 +126,13 @@ static enum blk_eh_timer_return mmc_mq_timed_out(struct request *req,
        struct mmc_card *card = mq->card;
        struct mmc_host *host = card->host;
        unsigned long flags;
-       int ret;
+       bool ignore_tout;
 
        spin_lock_irqsave(&mq->lock, flags);
-
-       if (mq->recovery_needed || !mq->use_cqe || host->hsq_enabled)
-               ret = BLK_EH_RESET_TIMER;
-       else
-               ret = mmc_cqe_timed_out(req);
-
+       ignore_tout = mq->recovery_needed || !mq->use_cqe || host->hsq_enabled;
        spin_unlock_irqrestore(&mq->lock, flags);
 
-       return ret;
+       return ignore_tout ? BLK_EH_RESET_TIMER : mmc_cqe_timed_out(req);
 }
 
 static void mmc_mq_recovery_handler(struct work_struct *work)
index 1aee485..026ca91 100644 (file)
@@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 
        if (ret) {
                dev_err(&pdev->dev, "Failed to get irq for data line\n");
-               return ret;
+               goto free_host;
        }
 
        mutex_init(&host->cmd_mutex);
@@ -1116,6 +1116,10 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
        dev_set_drvdata(&pdev->dev, host);
        mmc_add_host(mmc);
        return 0;
+
+free_host:
+       mmc_free_host(mmc);
+       return ret;
 }
 
 static int alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
index faba53c..d8b76cb 100644 (file)
@@ -605,10 +605,12 @@ static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev,
 }
 
 static const struct sdhci_acpi_slot sdhci_acpi_slot_amd_emmc = {
-       .chip   = &sdhci_acpi_chip_amd,
-       .caps   = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
-       .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_32BIT_DMA_SIZE |
-                       SDHCI_QUIRK_32BIT_ADMA_SIZE,
+       .chip           = &sdhci_acpi_chip_amd,
+       .caps           = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
+       .quirks         = SDHCI_QUIRK_32BIT_DMA_ADDR |
+                         SDHCI_QUIRK_32BIT_DMA_SIZE |
+                         SDHCI_QUIRK_32BIT_ADMA_SIZE,
+       .quirks2        = SDHCI_QUIRK2_BROKEN_64_BIT_DMA,
        .probe_slot     = sdhci_acpi_emmc_amd_probe_slot,
 };
 
index ce15a05..fd76aa6 100644 (file)
@@ -26,6 +26,9 @@
 #define   SDHCI_GLI_9750_DRIVING_2    GENMASK(27, 26)
 #define   GLI_9750_DRIVING_1_VALUE    0xFFF
 #define   GLI_9750_DRIVING_2_VALUE    0x3
+#define   SDHCI_GLI_9750_SEL_1        BIT(29)
+#define   SDHCI_GLI_9750_SEL_2        BIT(31)
+#define   SDHCI_GLI_9750_ALL_RST      (BIT(24)|BIT(25)|BIT(28)|BIT(30))
 
 #define SDHCI_GLI_9750_PLL           0x864
 #define   SDHCI_GLI_9750_PLL_TX2_INV    BIT(23)
@@ -122,6 +125,8 @@ static void gli_set_9750(struct sdhci_host *host)
                                    GLI_9750_DRIVING_1_VALUE);
        driving_value |= FIELD_PREP(SDHCI_GLI_9750_DRIVING_2,
                                    GLI_9750_DRIVING_2_VALUE);
+       driving_value &= ~(SDHCI_GLI_9750_SEL_1|SDHCI_GLI_9750_SEL_2|SDHCI_GLI_9750_ALL_RST);
+       driving_value |= SDHCI_GLI_9750_SEL_2;
        sdhci_writel(host, driving_value, SDHCI_GLI_9750_DRIVING);
 
        sw_ctrl_value &= ~SDHCI_GLI_9750_SW_CTRL_4;
@@ -334,6 +339,18 @@ static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
        return value;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sdhci_pci_gli_resume(struct sdhci_pci_chip *chip)
+{
+       struct sdhci_pci_slot *slot = chip->slots[0];
+
+       pci_free_irq_vectors(slot->chip->pdev);
+       gli_pcie_enable_msi(slot);
+
+       return sdhci_pci_resume_host(chip);
+}
+#endif
+
 static const struct sdhci_ops sdhci_gl9755_ops = {
        .set_clock              = sdhci_set_clock,
        .enable_dma             = sdhci_pci_enable_dma,
@@ -348,6 +365,9 @@ const struct sdhci_pci_fixes sdhci_gl9755 = {
        .quirks2        = SDHCI_QUIRK2_BROKEN_DDR50,
        .probe_slot     = gli_probe_slot_gl9755,
        .ops            = &sdhci_gl9755_ops,
+#ifdef CONFIG_PM_SLEEP
+       .resume         = sdhci_pci_gli_resume,
+#endif
 };
 
 static const struct sdhci_ops sdhci_gl9750_ops = {
@@ -366,4 +386,7 @@ const struct sdhci_pci_fixes sdhci_gl9750 = {
        .quirks2        = SDHCI_QUIRK2_BROKEN_DDR50,
        .probe_slot     = gli_probe_slot_gl9750,
        .ops            = &sdhci_gl9750_ops,
+#ifdef CONFIG_PM_SLEEP
+       .resume         = sdhci_pci_gli_resume,
+#endif
 };
index 2916674..29d4100 100644 (file)
@@ -555,7 +555,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 
        config.id = -1;
        config.dev = &mtd->dev;
-       config.name = mtd->name;
+       config.name = dev_name(&mtd->dev);
        config.owner = THIS_MODULE;
        config.reg_read = mtd_nvmem_reg_read;
        config.size = mtd->size;
index e4e3cee..8f9ffb4 100644 (file)
@@ -2728,9 +2728,8 @@ static int brcmnand_resume(struct device *dev)
                flash_dma_writel(ctrl, FLASH_DMA_ERROR_STATUS, 0);
        }
 
-       if (has_edu(ctrl))
+       if (has_edu(ctrl)) {
                ctrl->edu_config = edu_readl(ctrl, EDU_CONFIG);
-       else {
                edu_writel(ctrl, EDU_CONFIG, ctrl->edu_config);
                edu_readl(ctrl, EDU_CONFIG);
                brcmnand_edu_init(ctrl);
index b6bb358..e2c382f 100644 (file)
@@ -1089,6 +1089,10 @@ static int spinand_init(struct spinand_device *spinand)
 
        mtd->oobavail = ret;
 
+       /* Propagate ECC information to mtd_info */
+       mtd->ecc_strength = nand->eccreq.strength;
+       mtd->ecc_step_size = nand->eccreq.step_size;
+
        return 0;
 
 err_cleanup_nanddev:
index 54646c2..ac2bdba 100644 (file)
@@ -393,9 +393,6 @@ static void *eraseblk_count_seq_start(struct seq_file *s, loff_t *pos)
 {
        struct ubi_device *ubi = s->private;
 
-       if (*pos == 0)
-               return SEQ_START_TOKEN;
-
        if (*pos < ubi->peb_count)
                return pos;
 
@@ -409,8 +406,6 @@ static void *eraseblk_count_seq_next(struct seq_file *s, void *v, loff_t *pos)
 {
        struct ubi_device *ubi = s->private;
 
-       if (v == SEQ_START_TOKEN)
-               return pos;
        (*pos)++;
 
        if (*pos < ubi->peb_count)
@@ -432,11 +427,8 @@ static int eraseblk_count_seq_show(struct seq_file *s, void *iter)
        int err;
 
        /* If this is the start, print a header */
-       if (iter == SEQ_START_TOKEN) {
-               seq_puts(s,
-                        "physical_block_number\terase_count\tblock_status\tread_status\n");
-               return 0;
-       }
+       if (*block_number == 0)
+               seq_puts(s, "physical_block_number\terase_count\n");
 
        err = ubi_io_is_bad(ubi, *block_number);
        if (err)
index cc0703c..efd1a1d 100644 (file)
@@ -136,25 +136,21 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
        oiph = skb_network_header(skb);
        skb_reset_network_header(skb);
 
-       if (family == AF_INET)
+       if (!IS_ENABLED(CONFIG_IPV6) || family == AF_INET)
                err = IP_ECN_decapsulate(oiph, skb);
-#if IS_ENABLED(CONFIG_IPV6)
        else
                err = IP6_ECN_decapsulate(oiph, skb);
-#endif
 
        if (unlikely(err)) {
                if (log_ecn_error) {
-                       if  (family == AF_INET)
+                       if  (!IS_ENABLED(CONFIG_IPV6) || family == AF_INET)
                                net_info_ratelimited("non-ECT from %pI4 "
                                                     "with TOS=%#x\n",
                                                     &((struct iphdr *)oiph)->saddr,
                                                     ((struct iphdr *)oiph)->tos);
-#if IS_ENABLED(CONFIG_IPV6)
                        else
                                net_info_ratelimited("non-ECT from %pI6\n",
                                                     &((struct ipv6hdr *)oiph)->saddr);
-#endif
                }
                if (err > 1) {
                        ++bareudp->dev->stats.rx_frame_errors;
@@ -350,7 +346,6 @@ free_dst:
        return err;
 }
 
-#if IS_ENABLED(CONFIG_IPV6)
 static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
                             struct bareudp_dev *bareudp,
                             const struct ip_tunnel_info *info)
@@ -411,7 +406,6 @@ free_dst:
        dst_release(dst);
        return err;
 }
-#endif
 
 static netdev_tx_t bareudp_xmit(struct sk_buff *skb, struct net_device *dev)
 {
@@ -435,11 +429,9 @@ static netdev_tx_t bareudp_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        rcu_read_lock();
-#if IS_ENABLED(CONFIG_IPV6)
-       if (info->mode & IP_TUNNEL_INFO_IPV6)
+       if (IS_ENABLED(CONFIG_IPV6) && info->mode & IP_TUNNEL_INFO_IPV6)
                err = bareudp6_xmit_skb(skb, dev, bareudp, info);
        else
-#endif
                err = bareudp_xmit_skb(skb, dev, bareudp, info);
 
        rcu_read_unlock();
@@ -467,7 +459,7 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,
 
        use_cache = ip_tunnel_dst_cache_usable(skb, info);
 
-       if (ip_tunnel_info_af(info) == AF_INET) {
+       if (!IS_ENABLED(CONFIG_IPV6) || ip_tunnel_info_af(info) == AF_INET) {
                struct rtable *rt;
                __be32 saddr;
 
@@ -478,7 +470,6 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,
 
                ip_rt_put(rt);
                info->key.u.ipv4.src = saddr;
-#if IS_ENABLED(CONFIG_IPV6)
        } else if (ip_tunnel_info_af(info) == AF_INET6) {
                struct dst_entry *dst;
                struct in6_addr saddr;
@@ -492,7 +483,6 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,
 
                dst_release(dst);
                info->key.u.ipv6.src = saddr;
-#endif
        } else {
                return -EINVAL;
        }
index fdcb70b..400207c 100644 (file)
@@ -360,6 +360,7 @@ static void __exit dsa_loop_exit(void)
 }
 module_exit(dsa_loop_exit);
 
+MODULE_SOFTDEP("pre: dsa_loop_bdinfo");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Florian Fainelli");
 MODULE_DESCRIPTION("DSA loopback driver");
index 53055ce..2a69c0d 100644 (file)
@@ -69,6 +69,7 @@ config BCMGENET
        select BCM7XXX_PHY
        select MDIO_BCM_UNIMAC
        select DIMLIB
+       select BROADCOM_PHY if ARCH_BCM2835
        help
          This driver supports the built-in Ethernet MACs found in the
          Broadcom BCM7xxx Set Top Box family chipset.
index 2bd7ace..bfc6bfe 100644 (file)
@@ -77,6 +77,7 @@ config UCC_GETH
        depends on QUICC_ENGINE && PPC32
        select FSL_PQ_MDIO
        select PHYLIB
+       select FIXED_PHY
        ---help---
          This driver supports the Gigabit Ethernet mode of the QUICC Engine,
          which is available on some Freescale SOCs.
@@ -90,6 +91,7 @@ config GIANFAR
        depends on HAS_DMA
        select FSL_PQ_MDIO
        select PHYLIB
+       select FIXED_PHY
        select CRC32
        ---help---
          This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
index 3b32573..0a54c7e 100644 (file)
@@ -3,6 +3,7 @@ menuconfig FSL_DPAA_ETH
        tristate "DPAA Ethernet"
        depends on FSL_DPAA && FSL_FMAN
        select PHYLIB
+       select FIXED_PHY
        select FSL_FMAN_MAC
        ---help---
          Data Path Acceleration Architecture Ethernet driver,
index b6c4663..d97c320 100644 (file)
@@ -86,7 +86,7 @@ static void free_rx_fd(struct dpaa2_eth_priv *priv,
        for (i = 1; i < DPAA2_ETH_MAX_SG_ENTRIES; i++) {
                addr = dpaa2_sg_get_addr(&sgt[i]);
                sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
-               dma_unmap_page(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
+               dma_unmap_page(dev, addr, priv->rx_buf_size,
                               DMA_BIDIRECTIONAL);
 
                free_pages((unsigned long)sg_vaddr, 0);
@@ -144,7 +144,7 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv *priv,
                /* Get the address and length from the S/G entry */
                sg_addr = dpaa2_sg_get_addr(sge);
                sg_vaddr = dpaa2_iova_to_virt(priv->iommu_domain, sg_addr);
-               dma_unmap_page(dev, sg_addr, DPAA2_ETH_RX_BUF_SIZE,
+               dma_unmap_page(dev, sg_addr, priv->rx_buf_size,
                               DMA_BIDIRECTIONAL);
 
                sg_length = dpaa2_sg_get_len(sge);
@@ -185,7 +185,7 @@ static struct sk_buff *build_frag_skb(struct dpaa2_eth_priv *priv,
                                (page_address(page) - page_address(head_page));
 
                        skb_add_rx_frag(skb, i - 1, head_page, page_offset,
-                                       sg_length, DPAA2_ETH_RX_BUF_SIZE);
+                                       sg_length, priv->rx_buf_size);
                }
 
                if (dpaa2_sg_is_final(sge))
@@ -211,7 +211,7 @@ static void free_bufs(struct dpaa2_eth_priv *priv, u64 *buf_array, int count)
 
        for (i = 0; i < count; i++) {
                vaddr = dpaa2_iova_to_virt(priv->iommu_domain, buf_array[i]);
-               dma_unmap_page(dev, buf_array[i], DPAA2_ETH_RX_BUF_SIZE,
+               dma_unmap_page(dev, buf_array[i], priv->rx_buf_size,
                               DMA_BIDIRECTIONAL);
                free_pages((unsigned long)vaddr, 0);
        }
@@ -335,7 +335,7 @@ static u32 run_xdp(struct dpaa2_eth_priv *priv,
                break;
        case XDP_REDIRECT:
                dma_unmap_page(priv->net_dev->dev.parent, addr,
-                              DPAA2_ETH_RX_BUF_SIZE, DMA_BIDIRECTIONAL);
+                              priv->rx_buf_size, DMA_BIDIRECTIONAL);
                ch->buf_count--;
                xdp.data_hard_start = vaddr;
                err = xdp_do_redirect(priv->net_dev, &xdp, xdp_prog);
@@ -374,7 +374,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
        trace_dpaa2_rx_fd(priv->net_dev, fd);
 
        vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
-       dma_sync_single_for_cpu(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
+       dma_sync_single_for_cpu(dev, addr, priv->rx_buf_size,
                                DMA_BIDIRECTIONAL);
 
        fas = dpaa2_get_fas(vaddr, false);
@@ -393,13 +393,13 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
                        return;
                }
 
-               dma_unmap_page(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
+               dma_unmap_page(dev, addr, priv->rx_buf_size,
                               DMA_BIDIRECTIONAL);
                skb = build_linear_skb(ch, fd, vaddr);
        } else if (fd_format == dpaa2_fd_sg) {
                WARN_ON(priv->xdp_prog);
 
-               dma_unmap_page(dev, addr, DPAA2_ETH_RX_BUF_SIZE,
+               dma_unmap_page(dev, addr, priv->rx_buf_size,
                               DMA_BIDIRECTIONAL);
                skb = build_frag_skb(priv, ch, buf_data);
                free_pages((unsigned long)vaddr, 0);
@@ -974,7 +974,7 @@ static int add_bufs(struct dpaa2_eth_priv *priv,
                if (!page)
                        goto err_alloc;
 
-               addr = dma_map_page(dev, page, 0, DPAA2_ETH_RX_BUF_SIZE,
+               addr = dma_map_page(dev, page, 0, priv->rx_buf_size,
                                    DMA_BIDIRECTIONAL);
                if (unlikely(dma_mapping_error(dev, addr)))
                        goto err_map;
@@ -984,7 +984,7 @@ static int add_bufs(struct dpaa2_eth_priv *priv,
                /* tracing point */
                trace_dpaa2_eth_buf_seed(priv->net_dev,
                                         page, DPAA2_ETH_RX_BUF_RAW_SIZE,
-                                        addr, DPAA2_ETH_RX_BUF_SIZE,
+                                        addr, priv->rx_buf_size,
                                         bpid);
        }
 
@@ -1720,7 +1720,7 @@ static bool xdp_mtu_valid(struct dpaa2_eth_priv *priv, int mtu)
        int mfl, linear_mfl;
 
        mfl = DPAA2_ETH_L2_MAX_FRM(mtu);
-       linear_mfl = DPAA2_ETH_RX_BUF_SIZE - DPAA2_ETH_RX_HWA_SIZE -
+       linear_mfl = priv->rx_buf_size - DPAA2_ETH_RX_HWA_SIZE -
                     dpaa2_eth_rx_head_room(priv) - XDP_PACKET_HEADROOM;
 
        if (mfl > linear_mfl) {
@@ -2462,6 +2462,11 @@ static int set_buffer_layout(struct dpaa2_eth_priv *priv)
        else
                rx_buf_align = DPAA2_ETH_RX_BUF_ALIGN;
 
+       /* We need to ensure that the buffer size seen by WRIOP is a multiple
+        * of 64 or 256 bytes depending on the WRIOP version.
+        */
+       priv->rx_buf_size = ALIGN_DOWN(DPAA2_ETH_RX_BUF_SIZE, rx_buf_align);
+
        /* tx buffer */
        buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
        buf_layout.pass_timestamp = true;
@@ -3126,7 +3131,7 @@ static int bind_dpni(struct dpaa2_eth_priv *priv)
        pools_params.num_dpbp = 1;
        pools_params.pools[0].dpbp_id = priv->dpbp_dev->obj_desc.id;
        pools_params.pools[0].backup_pool = 0;
-       pools_params.pools[0].buffer_size = DPAA2_ETH_RX_BUF_SIZE;
+       pools_params.pools[0].buffer_size = priv->rx_buf_size;
        err = dpni_set_pools(priv->mc_io, 0, priv->mc_token, &pools_params);
        if (err) {
                dev_err(dev, "dpni_set_pools() failed\n");
index 7635db3..13242bf 100644 (file)
@@ -382,6 +382,7 @@ struct dpaa2_eth_priv {
        u16 tx_data_offset;
 
        struct fsl_mc_device *dpbp_dev;
+       u16 rx_buf_size;
        u16 bpid;
        struct iommu_domain *iommu_domain;
 
index 94347c6..b7141fd 100644 (file)
@@ -635,7 +635,7 @@ static int num_rules(struct dpaa2_eth_priv *priv)
 
 static int update_cls_rule(struct net_device *net_dev,
                           struct ethtool_rx_flow_spec *new_fs,
-                          int location)
+                          unsigned int location)
 {
        struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
        struct dpaa2_eth_cls_rule *rule;
index 3892a20..2fff435 100644 (file)
@@ -64,7 +64,7 @@ config HNS_MDIO
          the PHY
 
 config HNS
-       tristate "Hisilicon Network Subsystem Support (Framework)"
+       tristate
        ---help---
          This selects the framework support for Hisilicon Network Subsystem. It
          is needed by any driver which provides HNS acceleration engine or make
index 8995e32..992908e 100644 (file)
@@ -45,6 +45,8 @@
 
 #define MGMT_MSG_TIMEOUT                5000
 
+#define SET_FUNC_PORT_MGMT_TIMEOUT     25000
+
 #define mgmt_to_pfhwdev(pf_mgmt)        \
                container_of(pf_mgmt, struct hinic_pfhwdev, pf_to_mgmt)
 
@@ -238,12 +240,13 @@ static int msg_to_mgmt_sync(struct hinic_pf_to_mgmt *pf_to_mgmt,
                            u8 *buf_in, u16 in_size,
                            u8 *buf_out, u16 *out_size,
                            enum mgmt_direction_type direction,
-                           u16 resp_msg_id)
+                           u16 resp_msg_id, u32 timeout)
 {
        struct hinic_hwif *hwif = pf_to_mgmt->hwif;
        struct pci_dev *pdev = hwif->pdev;
        struct hinic_recv_msg *recv_msg;
        struct completion *recv_done;
+       unsigned long timeo;
        u16 msg_id;
        int err;
 
@@ -267,8 +270,9 @@ static int msg_to_mgmt_sync(struct hinic_pf_to_mgmt *pf_to_mgmt,
                goto unlock_sync_msg;
        }
 
-       if (!wait_for_completion_timeout(recv_done,
-                                        msecs_to_jiffies(MGMT_MSG_TIMEOUT))) {
+       timeo = msecs_to_jiffies(timeout ? timeout : MGMT_MSG_TIMEOUT);
+
+       if (!wait_for_completion_timeout(recv_done, timeo)) {
                dev_err(&pdev->dev, "MGMT timeout, MSG id = %d\n", msg_id);
                err = -ETIMEDOUT;
                goto unlock_sync_msg;
@@ -342,6 +346,7 @@ int hinic_msg_to_mgmt(struct hinic_pf_to_mgmt *pf_to_mgmt,
 {
        struct hinic_hwif *hwif = pf_to_mgmt->hwif;
        struct pci_dev *pdev = hwif->pdev;
+       u32 timeout = 0;
 
        if (sync != HINIC_MGMT_MSG_SYNC) {
                dev_err(&pdev->dev, "Invalid MGMT msg type\n");
@@ -353,9 +358,12 @@ int hinic_msg_to_mgmt(struct hinic_pf_to_mgmt *pf_to_mgmt,
                return -EINVAL;
        }
 
+       if (cmd == HINIC_PORT_CMD_SET_FUNC_STATE)
+               timeout = SET_FUNC_PORT_MGMT_TIMEOUT;
+
        return msg_to_mgmt_sync(pf_to_mgmt, mod, cmd, buf_in, in_size,
                                buf_out, out_size, MGMT_DIRECT_SEND,
-                               MSG_NOT_RESP);
+                               MSG_NOT_RESP, timeout);
 }
 
 /**
index 1356097..63b92f6 100644 (file)
@@ -483,7 +483,6 @@ static int hinic_close(struct net_device *netdev)
 {
        struct hinic_dev *nic_dev = netdev_priv(netdev);
        unsigned int flags;
-       int err;
 
        down(&nic_dev->mgmt_lock);
 
@@ -497,20 +496,9 @@ static int hinic_close(struct net_device *netdev)
 
        up(&nic_dev->mgmt_lock);
 
-       err = hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_DISABLE);
-       if (err) {
-               netif_err(nic_dev, drv, netdev,
-                         "Failed to set func port state\n");
-               nic_dev->flags |= (flags & HINIC_INTF_UP);
-               return err;
-       }
+       hinic_port_set_state(nic_dev, HINIC_PORT_DISABLE);
 
-       err = hinic_port_set_state(nic_dev, HINIC_PORT_DISABLE);
-       if (err) {
-               netif_err(nic_dev, drv, netdev, "Failed to set port state\n");
-               nic_dev->flags |= (flags & HINIC_INTF_UP);
-               return err;
-       }
+       hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_DISABLE);
 
        if (nic_dev->flags & HINIC_RSS_ENABLE) {
                hinic_rss_deinit(nic_dev);
index 187c633..f422751 100644 (file)
@@ -497,13 +497,17 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        hw->irq_name = devm_kmalloc_array(&hw->pdev->dev, num_vec, NAME_SIZE,
                                          GFP_KERNEL);
-       if (!hw->irq_name)
+       if (!hw->irq_name) {
+               err = -ENOMEM;
                goto err_free_netdev;
+       }
 
        hw->affinity_mask = devm_kcalloc(&hw->pdev->dev, num_vec,
                                         sizeof(cpumask_var_t), GFP_KERNEL);
-       if (!hw->affinity_mask)
+       if (!hw->affinity_mask) {
+               err = -ENOMEM;
                goto err_free_netdev;
+       }
 
        err = pci_alloc_irq_vectors(hw->pdev, num_vec, num_vec, PCI_IRQ_MSIX);
        if (err < 0) {
index 39925e4..b25a13d 100644 (file)
@@ -1070,7 +1070,7 @@ static int encx24j600_spi_probe(struct spi_device *spi)
        if (unlikely(ret)) {
                netif_err(priv, probe, ndev, "Error %d initializing card encx24j600 card\n",
                          ret);
-               goto out_free;
+               goto out_stop;
        }
 
        eidled = encx24j600_read_reg(priv, EIDLED);
@@ -1088,6 +1088,8 @@ static int encx24j600_spi_probe(struct spi_device *spi)
 
 out_unregister:
        unregister_netdev(priv->ndev);
+out_stop:
+       kthread_stop(priv->kworker_task);
 out_free:
        free_netdev(ndev);
 
@@ -1100,6 +1102,7 @@ static int encx24j600_spi_remove(struct spi_device *spi)
        struct encx24j600_priv *priv = dev_get_drvdata(&spi->dev);
 
        unregister_netdev(priv->ndev);
+       kthread_stop(priv->kworker_task);
 
        free_netdev(priv->ndev);
 
index 354efff..bdbf072 100644 (file)
@@ -333,8 +333,10 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
                goto err_free_alink;
 
        alink->prio_map = kzalloc(abm->prio_map_len, GFP_KERNEL);
-       if (!alink->prio_map)
+       if (!alink->prio_map) {
+               err = -ENOMEM;
                goto err_free_alink;
+       }
 
        /* This is a multi-host app, make sure MAC/PHY is up, but don't
         * make the MAC/PHY state follow the state of any of the ports.
index d5293bf..f8a9c1b 100644 (file)
@@ -2118,6 +2118,7 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
        dev_info(ionic->dev, "FW Up: restarting LIFs\n");
 
        ionic_init_devinfo(ionic);
+       ionic_port_init(ionic);
        err = ionic_qcqs_alloc(lif);
        if (err)
                goto err_out;
@@ -2348,7 +2349,17 @@ static int ionic_station_set(struct ionic_lif *lif)
        if (is_zero_ether_addr(ctx.comp.lif_getattr.mac))
                return 0;
 
-       if (!ether_addr_equal(ctx.comp.lif_getattr.mac, netdev->dev_addr)) {
+       if (!is_zero_ether_addr(netdev->dev_addr)) {
+               /* If the netdev mac is non-zero and doesn't match the default
+                * device address, it was set by something earlier and we're
+                * likely here again after a fw-upgrade reset.  We need to be
+                * sure the netdev mac is in our filter list.
+                */
+               if (!ether_addr_equal(ctx.comp.lif_getattr.mac,
+                                     netdev->dev_addr))
+                       ionic_lif_addr(lif, netdev->dev_addr, true);
+       } else {
+               /* Update the netdev mac with the device's mac */
                memcpy(addr.sa_data, ctx.comp.lif_getattr.mac, netdev->addr_len);
                addr.sa_family = AF_INET;
                err = eth_prepare_mac_addr_change(netdev, &addr);
@@ -2358,12 +2369,6 @@ static int ionic_station_set(struct ionic_lif *lif)
                        return 0;
                }
 
-               if (!is_zero_ether_addr(netdev->dev_addr)) {
-                       netdev_dbg(lif->netdev, "deleting station MAC addr %pM\n",
-                                  netdev->dev_addr);
-                       ionic_lif_addr(lif, netdev->dev_addr, false);
-               }
-
                eth_commit_mac_addr_change(netdev, &addr);
        }
 
index 588c62e..3344bc1 100644 (file)
@@ -509,16 +509,16 @@ int ionic_port_init(struct ionic *ionic)
        size_t sz;
        int err;
 
-       if (idev->port_info)
-               return 0;
-
-       idev->port_info_sz = ALIGN(sizeof(*idev->port_info), PAGE_SIZE);
-       idev->port_info = dma_alloc_coherent(ionic->dev, idev->port_info_sz,
-                                            &idev->port_info_pa,
-                                            GFP_KERNEL);
        if (!idev->port_info) {
-               dev_err(ionic->dev, "Failed to allocate port info, aborting\n");
-               return -ENOMEM;
+               idev->port_info_sz = ALIGN(sizeof(*idev->port_info), PAGE_SIZE);
+               idev->port_info = dma_alloc_coherent(ionic->dev,
+                                                    idev->port_info_sz,
+                                                    &idev->port_info_pa,
+                                                    GFP_KERNEL);
+               if (!idev->port_info) {
+                       dev_err(ionic->dev, "Failed to allocate port info\n");
+                       return -ENOMEM;
+               }
        }
 
        sz = min(sizeof(ident->port.config), sizeof(idev->dev_cmd_regs->data));
index bf5bf05..78e15cc 100644 (file)
@@ -2127,6 +2127,8 @@ static enum mac_version rtl8169_get_mac_version(u16 xid, bool gmii)
                { 0x7cf, 0x348, RTL_GIGA_MAC_VER_07 },
                { 0x7cf, 0x248, RTL_GIGA_MAC_VER_07 },
                { 0x7cf, 0x340, RTL_GIGA_MAC_VER_13 },
+               /* RTL8401, reportedly works if treated as RTL8101e */
+               { 0x7cf, 0x240, RTL_GIGA_MAC_VER_13 },
                { 0x7cf, 0x343, RTL_GIGA_MAC_VER_10 },
                { 0x7cf, 0x342, RTL_GIGA_MAC_VER_16 },
                { 0x7c8, 0x348, RTL_GIGA_MAC_VER_09 },
index e0a5fe8..bfc4a92 100644 (file)
@@ -75,6 +75,11 @@ struct ethqos_emac_por {
        unsigned int value;
 };
 
+struct ethqos_emac_driver_data {
+       const struct ethqos_emac_por *por;
+       unsigned int num_por;
+};
+
 struct qcom_ethqos {
        struct platform_device *pdev;
        void __iomem *rgmii_base;
@@ -171,6 +176,11 @@ static const struct ethqos_emac_por emac_v2_3_0_por[] = {
        { .offset = RGMII_IO_MACRO_CONFIG2,     .value = 0x00002060 },
 };
 
+static const struct ethqos_emac_driver_data emac_v2_3_0_data = {
+       .por = emac_v2_3_0_por,
+       .num_por = ARRAY_SIZE(emac_v2_3_0_por),
+};
+
 static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
 {
        unsigned int val;
@@ -442,6 +452,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
        struct device_node *np = pdev->dev.of_node;
        struct plat_stmmacenet_data *plat_dat;
        struct stmmac_resources stmmac_res;
+       const struct ethqos_emac_driver_data *data;
        struct qcom_ethqos *ethqos;
        struct resource *res;
        int ret;
@@ -471,7 +482,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
                goto err_mem;
        }
 
-       ethqos->por = of_device_get_match_data(&pdev->dev);
+       data = of_device_get_match_data(&pdev->dev);
+       ethqos->por = data->por;
+       ethqos->num_por = data->num_por;
 
        ethqos->rgmii_clk = devm_clk_get(&pdev->dev, "rgmii");
        if (IS_ERR(ethqos->rgmii_clk)) {
@@ -526,7 +539,7 @@ static int qcom_ethqos_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id qcom_ethqos_match[] = {
-       { .compatible = "qcom,qcs404-ethqos", .data = &emac_v2_3_0_por},
+       { .compatible = "qcom,qcs404-ethqos", .data = &emac_v2_3_0_data},
        { }
 };
 MODULE_DEVICE_TABLE(of, qcom_ethqos_match);
index 8e34878..62f809b 100644 (file)
@@ -49,6 +49,7 @@ config TI_CPSW_PHY_SEL
 config TI_CPSW
        tristate "TI CPSW Switch Support"
        depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST
+       depends on TI_CPTS || !TI_CPTS
        select TI_DAVINCI_MDIO
        select MFD_SYSCON
        select PAGE_POOL
@@ -64,6 +65,7 @@ config TI_CPSW_SWITCHDEV
        tristate "TI CPSW Switch Support with switchdev"
        depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST
        depends on NET_SWITCHDEV
+       depends on TI_CPTS || !TI_CPTS
        select PAGE_POOL
        select TI_DAVINCI_MDIO
        select MFD_SYSCON
@@ -77,23 +79,16 @@ config TI_CPSW_SWITCHDEV
          will be called cpsw_new.
 
 config TI_CPTS
-       bool "TI Common Platform Time Sync (CPTS) Support"
-       depends on TI_CPSW || TI_KEYSTONE_NETCP || TI_CPSW_SWITCHDEV || COMPILE_TEST
+       tristate "TI Common Platform Time Sync (CPTS) Support"
+       depends on ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
        depends on COMMON_CLK
-       depends on POSIX_TIMERS
+       depends on PTP_1588_CLOCK
        ---help---
          This driver supports the Common Platform Time Sync unit of
          the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
          The unit can time stamp PTP UDP/IPv4 and Layer 2 packets, and the
          driver offers a PTP Hardware Clock.
 
-config TI_CPTS_MOD
-       tristate
-       depends on TI_CPTS
-       depends on PTP_1588_CLOCK
-       default y if TI_CPSW=y || TI_KEYSTONE_NETCP=y || TI_CPSW_SWITCHDEV=y
-       default m
-
 config TI_K3_AM65_CPSW_NUSS
        tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
        depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
@@ -114,6 +109,7 @@ config TI_KEYSTONE_NETCP
        select TI_DAVINCI_MDIO
        depends on OF
        depends on KEYSTONE_NAVIGATOR_DMA && KEYSTONE_NAVIGATOR_QMSS
+       depends on TI_CPTS || !TI_CPTS
        ---help---
          This driver supports TI's Keystone NETCP Core.
 
index 5379219..cb26a9d 100644 (file)
@@ -13,7 +13,7 @@ obj-$(CONFIG_TI_DAVINCI_EMAC) += ti_davinci_emac.o
 ti_davinci_emac-y := davinci_emac.o davinci_cpdma.o
 obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o
 obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o
-obj-$(CONFIG_TI_CPTS_MOD) += cpts.o
+obj-$(CONFIG_TI_CPTS) += cpts.o
 obj-$(CONFIG_TI_CPSW) += ti_cpsw.o
 ti_cpsw-y := cpsw.o davinci_cpdma.o cpsw_ale.o cpsw_priv.o cpsw_sl.o cpsw_ethtool.o
 obj-$(CONFIG_TI_CPSW_SWITCHDEV) += ti_cpsw_new.o
index fbea6f2..e2ad3c2 100644 (file)
@@ -127,7 +127,8 @@ static inline struct net_device *bpq_get_ax25_dev(struct net_device *dev)
 {
        struct bpqdev *bpq;
 
-       list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list) {
+       list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list,
+                               lockdep_rtnl_is_held()) {
                if (bpq->ethdev == dev)
                        return bpq->axdev;
        }
index 2fd21d7..bdbfeed 100644 (file)
@@ -399,13 +399,14 @@ void gsi_trans_cmd_add(struct gsi_trans *trans, void *buf, u32 size,
        /* assert(which < trans->tre_count); */
 
        /* Set the page information for the buffer.  We also need to fill in
-        * the DMA address for the buffer (something dma_map_sg() normally
-        * does).
+        * the DMA address and length for the buffer (something dma_map_sg()
+        * normally does).
         */
        sg = &trans->sgl[which];
 
        sg_set_buf(sg, buf, size);
        sg_dma_address(sg) = addr;
+       sg_dma_len(sg) = sg->length;
 
        info = &trans->info[which];
        info->opcode = opcode;
index d226b85..cee4171 100644 (file)
@@ -628,23 +628,15 @@ static void ipa_cmd_transfer_add(struct gsi_trans *trans, u16 size)
 
 void ipa_cmd_tag_process_add(struct gsi_trans *trans)
 {
-       ipa_cmd_register_write_add(trans, 0, 0, 0, true);
-#if 1
-       /* Reference these functions to avoid a compile error */
-       (void)ipa_cmd_ip_packet_init_add;
-       (void)ipa_cmd_ip_tag_status_add;
-       (void) ipa_cmd_transfer_add;
-#else
        struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
-       struct gsi_endpoint *endpoint;
+       struct ipa_endpoint *endpoint;
 
        endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX];
-       ipa_cmd_ip_packet_init_add(trans, endpoint->endpoint_id);
 
+       ipa_cmd_register_write_add(trans, 0, 0, 0, true);
+       ipa_cmd_ip_packet_init_add(trans, endpoint->endpoint_id);
        ipa_cmd_ip_tag_status_add(trans, 0xcba987654321);
-
        ipa_cmd_transfer_add(trans, 4);
-#endif
 }
 
 /* Returns the number of commands required for the tag process */
index 4d33aa7..a5f7a79 100644 (file)
@@ -53,7 +53,7 @@
  * @clock_on:          Whether IPA clock is on
  * @notified:          Whether modem has been notified of clock state
  * @disabled:          Whether setup ready interrupt handling is disabled
- * @mutex mutex:       Motex protecting ready interrupt/shutdown interlock
+ * @mutex:             Mutex protecting ready-interrupt/shutdown interlock
  * @panic_notifier:    Panic notifier structure
 */
 struct ipa_smp2p {
index ae4873f..d14d91b 100644 (file)
@@ -225,8 +225,12 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
        else
                val |= BCM54XX_SHD_SCR3_DLLAPD_DIS;
 
-       if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY)
-               val |= BCM54XX_SHD_SCR3_TRDDAPD;
+       if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
+               if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810)
+                       val |= BCM54810_SHD_SCR3_TRDDAPD;
+               else
+                       val |= BCM54XX_SHD_SCR3_TRDDAPD;
+       }
 
        if (orig != val)
                bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val);
index 72c69a9..20ca641 100644 (file)
@@ -1132,9 +1132,11 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
                /* Restart autonegotiation so the new modes get sent to the
                 * link partner.
                 */
-               ret = phy_restart_aneg(phydev);
-               if (ret < 0)
-                       return ret;
+               if (phydev->autoneg == AUTONEG_ENABLE) {
+                       ret = phy_restart_aneg(phydev);
+                       if (ret < 0)
+                               return ret;
+               }
        }
 
        return 0;
index d760a36..beedaad 100644 (file)
@@ -490,6 +490,9 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev,
        if (!skb)
                goto out;
 
+       if (skb->pkt_type != PACKET_HOST)
+               goto abort;
+
        if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
                goto abort;
 
index 417e42c..bb8c34d 100644 (file)
@@ -2659,7 +2659,7 @@ static struct hso_device *hso_create_bulk_serial_device(
        if (!
            (serial->out_endp =
             hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) {
-               dev_err(&interface->dev, "Failed to find BULK IN ep\n");
+               dev_err(&interface->dev, "Failed to find BULK OUT ep\n");
                goto exit2;
        }
 
index 11f7224..ce07f52 100644 (file)
@@ -1243,9 +1243,11 @@ static bool try_fill_recv(struct virtnet_info *vi, struct receive_queue *rq,
                        break;
        } while (rq->vq->num_free);
        if (virtqueue_kick_prepare(rq->vq) && virtqueue_notify(rq->vq)) {
-               u64_stats_update_begin(&rq->stats.syncp);
+               unsigned long flags;
+
+               flags = u64_stats_update_begin_irqsave(&rq->stats.syncp);
                rq->stats.kicks++;
-               u64_stats_update_end(&rq->stats.syncp);
+               u64_stats_update_end_irqrestore(&rq->stats.syncp, flags);
        }
 
        return !oom;
index e13c370..3726dc7 100644 (file)
@@ -989,6 +989,11 @@ static inline int nvme_process_cq(struct nvme_queue *nvmeq)
 
        while (nvme_cqe_pending(nvmeq)) {
                found++;
+               /*
+                * load-load control dependency between phase and the rest of
+                * the cqe requires a full read memory barrier
+                */
+               dma_rmb();
                nvme_handle_cqe(nvmeq, nvmeq->cq_head);
                nvme_update_cq_head(nvmeq);
        }
index 47a4ccd..f579a65 100644 (file)
@@ -1435,7 +1435,7 @@ static const char * const sd2_groups[] = {
 static const char * const i2c0_groups[] = {
        "uart0_rx_mfp",
        "uart0_tx_mfp",
-       "i2c0_mfp_mfp",
+       "i2c0_mfp",
 };
 
 static const char * const i2c1_groups[] = {
index b409642..9b821c9 100644 (file)
@@ -1286,6 +1286,7 @@ static const struct gpio_chip byt_gpio_chip = {
        .direction_output       = byt_gpio_direction_output,
        .get                    = byt_gpio_get,
        .set                    = byt_gpio_set,
+       .set_config             = gpiochip_generic_config,
        .dbg_show               = byt_gpio_dbg_show,
 };
 
index 4c74fdd..1093a61 100644 (file)
@@ -1479,11 +1479,15 @@ static void chv_gpio_irq_handler(struct irq_desc *desc)
        struct chv_pinctrl *pctrl = gpiochip_get_data(gc);
        struct irq_chip *chip = irq_desc_get_chip(desc);
        unsigned long pending;
+       unsigned long flags;
        u32 intr_line;
 
        chained_irq_enter(chip, desc);
 
+       raw_spin_lock_irqsave(&chv_lock, flags);
        pending = readl(pctrl->regs + CHV_INTSTAT);
+       raw_spin_unlock_irqrestore(&chv_lock, flags);
+
        for_each_set_bit(intr_line, &pending, pctrl->community->nirqs) {
                unsigned int irq, offset;
 
index 330c8f0..4d7a86a 100644 (file)
 
 #include "pinctrl-intel.h"
 
-#define SPT_PAD_OWN    0x020
-#define SPT_PADCFGLOCK 0x0a0
-#define SPT_HOSTSW_OWN 0x0d0
-#define SPT_GPI_IS     0x100
-#define SPT_GPI_IE     0x120
+#define SPT_PAD_OWN            0x020
+#define SPT_H_PADCFGLOCK       0x090
+#define SPT_LP_PADCFGLOCK      0x0a0
+#define SPT_HOSTSW_OWN         0x0d0
+#define SPT_GPI_IS             0x100
+#define SPT_GPI_IE             0x120
 
 #define SPT_COMMUNITY(b, s, e)                         \
        {                                               \
                .barno = (b),                           \
                .padown_offset = SPT_PAD_OWN,           \
-               .padcfglock_offset = SPT_PADCFGLOCK,    \
+               .padcfglock_offset = SPT_LP_PADCFGLOCK, \
                .hostown_offset = SPT_HOSTSW_OWN,       \
                .is_offset = SPT_GPI_IS,                \
                .ie_offset = SPT_GPI_IE,                \
@@ -47,7 +48,7 @@
        {                                               \
                .barno = (b),                           \
                .padown_offset = SPT_PAD_OWN,           \
-               .padcfglock_offset = SPT_PADCFGLOCK,    \
+               .padcfglock_offset = SPT_H_PADCFGLOCK,  \
                .hostown_offset = SPT_HOSTSW_OWN,       \
                .is_offset = SPT_GPI_IS,                \
                .ie_offset = SPT_GPI_IE,                \
index 3853ec3..ee305f1 100644 (file)
@@ -164,8 +164,6 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
        case MTK_PIN_CONFIG_PU_ADV:
        case MTK_PIN_CONFIG_PD_ADV:
                if (hw->soc->adv_pull_get) {
-                       bool pullup;
-
                        pullup = param == MTK_PIN_CONFIG_PU_ADV;
                        err = hw->soc->adv_pull_get(hw, desc, pullup, &ret);
                } else
index 9a398a2..85858c1 100644 (file)
@@ -697,7 +697,7 @@ static void msm_gpio_update_dual_edge_pos(struct msm_pinctrl *pctrl,
 
                pol = msm_readl_intr_cfg(pctrl, g);
                pol ^= BIT(g->intr_polarity_bit);
-               msm_writel_intr_cfg(val, pctrl, g);
+               msm_writel_intr_cfg(pol, pctrl, g);
 
                val2 = msm_readl_io(pctrl, g) & BIT(g->in_bit);
                intstat = msm_readl_intr_status(pctrl, g);
@@ -1034,6 +1034,29 @@ static void msm_gpio_irq_relres(struct irq_data *d)
        module_put(gc->owner);
 }
 
+static int msm_gpio_irq_set_affinity(struct irq_data *d,
+                               const struct cpumask *dest, bool force)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+       struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
+
+       if (d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs))
+               return irq_chip_set_affinity_parent(d, dest, force);
+
+       return 0;
+}
+
+static int msm_gpio_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+       struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
+
+       if (d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs))
+               return irq_chip_set_vcpu_affinity_parent(d, vcpu_info);
+
+       return 0;
+}
+
 static void msm_gpio_irq_handler(struct irq_desc *desc)
 {
        struct gpio_chip *gc = irq_desc_get_handler_data(desc);
@@ -1132,6 +1155,8 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
        pctrl->irq_chip.irq_set_wake = msm_gpio_irq_set_wake;
        pctrl->irq_chip.irq_request_resources = msm_gpio_irq_reqres;
        pctrl->irq_chip.irq_release_resources = msm_gpio_irq_relres;
+       pctrl->irq_chip.irq_set_affinity = msm_gpio_irq_set_affinity;
+       pctrl->irq_chip.irq_set_vcpu_affinity = msm_gpio_irq_set_vcpu_affinity;
 
        np = of_parse_phandle(pctrl->dev->of_node, "wakeup-parent", 0);
        if (np) {
index c75112e..c7fade8 100644 (file)
@@ -521,8 +521,10 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        ism->smcd = smcd_alloc_dev(&pdev->dev, dev_name(&pdev->dev), &ism_ops,
                                   ISM_NR_DMBS);
-       if (!ism->smcd)
+       if (!ism->smcd) {
+               ret = -ENOMEM;
                goto err_resource;
+       }
 
        ism->smcd->priv = ism;
        ret = ism_dev_init(ism);
index 3325596..2c9e5ac 100644 (file)
@@ -1850,9 +1850,6 @@ qla2x00_port_speed_show(struct device *dev, struct device_attribute *attr,
                return -EINVAL;
        }
 
-       ql_log(ql_log_info, vha, 0x70d6,
-           "port speed:%d\n", ha->link_data_rate);
-
        return scnprintf(buf, PAGE_SIZE, "%s\n", spd[ha->link_data_rate]);
 }
 
index 3717eea..5f0ad8b 100644 (file)
@@ -80,6 +80,10 @@ static int scsi_dev_type_resume(struct device *dev,
        dev_dbg(dev, "scsi resume: %d\n", err);
 
        if (err == 0) {
+               bool was_runtime_suspended;
+
+               was_runtime_suspended = pm_runtime_suspended(dev);
+
                pm_runtime_disable(dev);
                err = pm_runtime_set_active(dev);
                pm_runtime_enable(dev);
@@ -93,8 +97,10 @@ static int scsi_dev_type_resume(struct device *dev,
                 */
                if (!err && scsi_is_sdev_device(dev)) {
                        struct scsi_device *sdev = to_scsi_device(dev);
-
-                       blk_set_runtime_active(sdev->request_queue);
+                       if (was_runtime_suspended)
+                               blk_post_runtime_resume(sdev->request_queue, 0);
+                       else
+                               blk_set_runtime_active(sdev->request_queue);
                }
        }
 
index 594b724..264a822 100644 (file)
@@ -3350,6 +3350,7 @@ static void target_tmr_work(struct work_struct *work)
 
        cmd->se_tfo->queue_tm_rsp(cmd);
 
+       transport_lun_remove_cmd(cmd);
        transport_cmd_check_stop_to_fabric(cmd);
        return;
 
index 13eadcb..0b5110d 100644 (file)
@@ -883,6 +883,7 @@ console_initcall(sifive_console_init);
 
 static void __ssp_add_console_port(struct sifive_serial_port *ssp)
 {
+       spin_lock_init(&ssp->port.lock);
        sifive_serial_console_ports[ssp->port.line] = ssp;
 }
 
index 372460e..4d43f3b 100644 (file)
@@ -82,7 +82,7 @@ static int cdns3_ep_run_stream_transfer(struct cdns3_endpoint *priv_ep,
  * @ptr: address of device controller register to be read and changed
  * @mask: bits requested to clar
  */
-void cdns3_clear_register_bit(void __iomem *ptr, u32 mask)
+static void cdns3_clear_register_bit(void __iomem *ptr, u32 mask)
 {
        mask = readl(ptr) & ~mask;
        writel(mask, ptr);
@@ -137,7 +137,7 @@ struct usb_request *cdns3_next_request(struct list_head *list)
  *
  * Returns buffer or NULL if no buffers in list
  */
-struct cdns3_aligned_buf *cdns3_next_align_buf(struct list_head *list)
+static struct cdns3_aligned_buf *cdns3_next_align_buf(struct list_head *list)
 {
        return list_first_entry_or_null(list, struct cdns3_aligned_buf, list);
 }
@@ -148,7 +148,7 @@ struct cdns3_aligned_buf *cdns3_next_align_buf(struct list_head *list)
  *
  * Returns request or NULL if no requests in list
  */
-struct cdns3_request *cdns3_next_priv_request(struct list_head *list)
+static struct cdns3_request *cdns3_next_priv_request(struct list_head *list)
 {
        return list_first_entry_or_null(list, struct cdns3_request, list);
 }
@@ -190,7 +190,7 @@ dma_addr_t cdns3_trb_virt_to_dma(struct cdns3_endpoint *priv_ep,
        return priv_ep->trb_pool_dma + offset;
 }
 
-int cdns3_ring_size(struct cdns3_endpoint *priv_ep)
+static int cdns3_ring_size(struct cdns3_endpoint *priv_ep)
 {
        switch (priv_ep->type) {
        case USB_ENDPOINT_XFER_ISOC:
@@ -345,7 +345,7 @@ static void cdns3_ep_inc_deq(struct cdns3_endpoint *priv_ep)
        cdns3_ep_inc_trb(&priv_ep->dequeue, &priv_ep->ccs, priv_ep->num_trbs);
 }
 
-void cdns3_move_deq_to_next_trb(struct cdns3_request *priv_req)
+static void cdns3_move_deq_to_next_trb(struct cdns3_request *priv_req)
 {
        struct cdns3_endpoint *priv_ep = priv_req->priv_ep;
        int current_trb = priv_req->start_trb;
@@ -511,7 +511,7 @@ static void cdns3_wa2_descmiss_copy_data(struct cdns3_endpoint *priv_ep,
        }
 }
 
-struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_dev,
+static struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_dev,
                                              struct cdns3_endpoint *priv_ep,
                                              struct cdns3_request *priv_req)
 {
@@ -551,7 +551,7 @@ struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_dev,
        return &priv_req->request;
 }
 
-int cdns3_wa2_gadget_ep_queue(struct cdns3_device *priv_dev,
+static int cdns3_wa2_gadget_ep_queue(struct cdns3_device *priv_dev,
                              struct cdns3_endpoint *priv_ep,
                              struct cdns3_request *priv_req)
 {
@@ -836,7 +836,7 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep,
                cdns3_gadget_ep_free_request(&priv_ep->endpoint, request);
 }
 
-void cdns3_wa1_restore_cycle_bit(struct cdns3_endpoint *priv_ep)
+static void cdns3_wa1_restore_cycle_bit(struct cdns3_endpoint *priv_ep)
 {
        /* Work around for stale data address in TRB*/
        if (priv_ep->wa1_set) {
@@ -1904,7 +1904,7 @@ static int cdns3_ep_onchip_buffer_reserve(struct cdns3_device *priv_dev,
        return 0;
 }
 
-void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev,
+static void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev,
                              struct cdns3_endpoint *priv_ep)
 {
        if (!priv_ep->use_streams || priv_dev->gadget.speed < USB_SPEED_SUPER)
@@ -1925,7 +1925,7 @@ void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev,
                               EP_CFG_TDL_CHK | EP_CFG_SID_CHK);
 }
 
-void cdns3_configure_dmult(struct cdns3_device *priv_dev,
+static void cdns3_configure_dmult(struct cdns3_device *priv_dev,
                           struct cdns3_endpoint *priv_ep)
 {
        struct cdns3_usb_regs __iomem *regs = priv_dev->regs;
@@ -2548,7 +2548,7 @@ found:
        link_trb = priv_req->trb;
 
        /* Update ring only if removed request is on pending_req_list list */
-       if (req_on_hw_ring) {
+       if (req_on_hw_ring && link_trb) {
                link_trb->buffer = TRB_BUFFER(priv_ep->trb_pool_dma +
                        ((priv_req->end_trb + 1) * TRB_SIZE));
                link_trb->control = (link_trb->control & TRB_CYCLE) |
index b9db981..d93d94d 100644 (file)
@@ -251,9 +251,19 @@ static int usbdev_mmap(struct file *file, struct vm_area_struct *vma)
        usbm->vma_use_count = 1;
        INIT_LIST_HEAD(&usbm->memlist);
 
-       if (dma_mmap_coherent(hcd->self.sysdev, vma, mem, dma_handle, size)) {
-               dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
-               return -EAGAIN;
+       if (hcd->localmem_pool || !hcd_uses_dma(hcd)) {
+               if (remap_pfn_range(vma, vma->vm_start,
+                                   virt_to_phys(usbm->mem) >> PAGE_SHIFT,
+                                   size, vma->vm_page_prot) < 0) {
+                       dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
+                       return -EAGAIN;
+               }
+       } else {
+               if (dma_mmap_coherent(hcd->self.sysdev, vma, mem, dma_handle,
+                                     size)) {
+                       dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
+                       return -EAGAIN;
+               }
        }
 
        vma->vm_flags |= VM_IO;
index 2b6565c..fc748c7 100644 (file)
@@ -39,6 +39,7 @@
 
 #define USB_VENDOR_GENESYS_LOGIC               0x05e3
 #define USB_VENDOR_SMSC                                0x0424
+#define USB_PRODUCT_USB5534B                   0x5534
 #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND       0x01
 #define HUB_QUIRK_DISABLE_AUTOSUSPEND          0x02
 
@@ -5621,8 +5622,11 @@ out_hdev_lock:
 }
 
 static const struct usb_device_id hub_id_table[] = {
-    { .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_CLASS,
+    { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
+                   | USB_DEVICE_ID_MATCH_PRODUCT
+                   | USB_DEVICE_ID_MATCH_INT_CLASS,
       .idVendor = USB_VENDOR_SMSC,
+      .idProduct = USB_PRODUCT_USB5534B,
       .bInterfaceClass = USB_CLASS_HUB,
       .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND},
     { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
index 206caa0..7a23045 100644 (file)
@@ -4,6 +4,7 @@ config USB_DWC3
        tristate "DesignWare USB3 DRD Core Support"
        depends on (USB || USB_GADGET) && HAS_DMA
        select USB_XHCI_PLATFORM if USB_XHCI_HCD
+       select USB_ROLE_SWITCH if USB_DWC3_DUAL_ROLE
        help
          Say Y or M here if your system has a Dual Role SuperSpeed
          USB controller based on the DesignWare USB3 IP Core.
index 7051611..b673727 100644 (file)
@@ -114,6 +114,7 @@ static const struct property_entry dwc3_pci_intel_properties[] = {
 
 static const struct property_entry dwc3_pci_mrfld_properties[] = {
        PROPERTY_ENTRY_STRING("dr_mode", "otg"),
+       PROPERTY_ENTRY_STRING("linux,extcon-name", "mrfld_bcove_pwrsrc"),
        PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
        {}
 };
index 00746c2..585cb3d 100644 (file)
@@ -2483,9 +2483,6 @@ static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep *dep,
        for_each_sg(sg, s, pending, i) {
                trb = &dep->trb_pool[dep->trb_dequeue];
 
-               if (trb->ctrl & DWC3_TRB_CTRL_HWO)
-                       break;
-
                req->sg = sg_next(s);
                req->num_pending_sgs--;
 
index 32b637e..6a9aa44 100644 (file)
@@ -260,6 +260,9 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
        char *name;
        int ret;
 
+       if (strlen(page) < len)
+               return -EOVERFLOW;
+
        name = kstrdup(page, GFP_KERNEL);
        if (!name)
                return -ENOMEM;
index dd81fd5..a748ed0 100644 (file)
@@ -300,8 +300,10 @@ static int audio_bind(struct usb_composite_dev *cdev)
                struct usb_descriptor_header *usb_desc;
 
                usb_desc = usb_otg_descriptor_alloc(cdev->gadget);
-               if (!usb_desc)
+               if (!usb_desc) {
+                       status = -ENOMEM;
                        goto fail;
+               }
                usb_otg_descriptor_init(cdev->gadget, usb_desc);
                otg_desc[0] = usb_desc;
                otg_desc[1] = NULL;
index 8d7a556..563363a 100644 (file)
@@ -179,8 +179,10 @@ static int cdc_bind(struct usb_composite_dev *cdev)
                struct usb_descriptor_header *usb_desc;
 
                usb_desc = usb_otg_descriptor_alloc(gadget);
-               if (!usb_desc)
+               if (!usb_desc) {
+                       status = -ENOMEM;
                        goto fail1;
+               }
                usb_otg_descriptor_init(gadget, usb_desc);
                otg_desc[0] = usb_desc;
                otg_desc[1] = NULL;
index aa0de9e..3afddd3 100644 (file)
@@ -1361,7 +1361,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 
        req->buf = dev->rbuf;
        req->context = NULL;
-       value = -EOPNOTSUPP;
        switch (ctrl->bRequest) {
 
        case USB_REQ_GET_DESCRIPTOR:
@@ -1784,7 +1783,7 @@ static ssize_t
 dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 {
        struct dev_data         *dev = fd->private_data;
-       ssize_t                 value = len, length = len;
+       ssize_t                 value, length = len;
        unsigned                total;
        u32                     tag;
        char                    *kbuf;
index c61e71b..0f1b45e 100644 (file)
@@ -156,8 +156,10 @@ static int gncm_bind(struct usb_composite_dev *cdev)
                struct usb_descriptor_header *usb_desc;
 
                usb_desc = usb_otg_descriptor_alloc(gadget);
-               if (!usb_desc)
+               if (!usb_desc) {
+                       status = -ENOMEM;
                        goto fail;
+               }
                usb_otg_descriptor_init(gadget, usb_desc);
                otg_desc[0] = usb_desc;
                otg_desc[1] = NULL;
index ca7d95b..e01e366 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/compiler.h>
+#include <linux/ctype.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/kref.h>
@@ -123,8 +124,6 @@ static void raw_event_queue_destroy(struct raw_event_queue *queue)
 
 struct raw_dev;
 
-#define USB_RAW_MAX_ENDPOINTS 32
-
 enum ep_state {
        STATE_EP_DISABLED,
        STATE_EP_ENABLED,
@@ -134,6 +133,7 @@ struct raw_ep {
        struct raw_dev          *dev;
        enum ep_state           state;
        struct usb_ep           *ep;
+       u8                      addr;
        struct usb_request      *req;
        bool                    urb_queued;
        bool                    disabling;
@@ -168,7 +168,8 @@ struct raw_dev {
        bool                            ep0_out_pending;
        bool                            ep0_urb_queued;
        ssize_t                         ep0_status;
-       struct raw_ep                   eps[USB_RAW_MAX_ENDPOINTS];
+       struct raw_ep                   eps[USB_RAW_EPS_NUM_MAX];
+       int                             eps_num;
 
        struct completion               ep0_done;
        struct raw_event_queue          queue;
@@ -202,8 +203,8 @@ static void dev_free(struct kref *kref)
                usb_ep_free_request(dev->gadget->ep0, dev->req);
        }
        raw_event_queue_destroy(&dev->queue);
-       for (i = 0; i < USB_RAW_MAX_ENDPOINTS; i++) {
-               if (dev->eps[i].state != STATE_EP_ENABLED)
+       for (i = 0; i < dev->eps_num; i++) {
+               if (dev->eps[i].state == STATE_EP_DISABLED)
                        continue;
                usb_ep_disable(dev->eps[i].ep);
                usb_ep_free_request(dev->eps[i].ep, dev->eps[i].req);
@@ -249,12 +250,26 @@ static void gadget_ep0_complete(struct usb_ep *ep, struct usb_request *req)
        complete(&dev->ep0_done);
 }
 
+static u8 get_ep_addr(const char *name)
+{
+       /* If the endpoint has fixed function (named as e.g. "ep12out-bulk"),
+        * parse the endpoint address from its name. We deliberately use
+        * deprecated simple_strtoul() function here, as the number isn't
+        * followed by '\0' nor '\n'.
+        */
+       if (isdigit(name[2]))
+               return simple_strtoul(&name[2], NULL, 10);
+       /* Otherwise the endpoint is configurable (named as e.g. "ep-a"). */
+       return USB_RAW_EP_ADDR_ANY;
+}
+
 static int gadget_bind(struct usb_gadget *gadget,
                        struct usb_gadget_driver *driver)
 {
-       int ret = 0;
+       int ret = 0, i = 0;
        struct raw_dev *dev = container_of(driver, struct raw_dev, driver);
        struct usb_request *req;
+       struct usb_ep *ep;
        unsigned long flags;
 
        if (strcmp(gadget->name, dev->udc_name) != 0)
@@ -273,6 +288,13 @@ static int gadget_bind(struct usb_gadget *gadget,
        dev->req->context = dev;
        dev->req->complete = gadget_ep0_complete;
        dev->gadget = gadget;
+       gadget_for_each_ep(ep, dev->gadget) {
+               dev->eps[i].ep = ep;
+               dev->eps[i].addr = get_ep_addr(ep->name);
+               dev->eps[i].state = STATE_EP_DISABLED;
+               i++;
+       }
+       dev->eps_num = i;
        spin_unlock_irqrestore(&dev->lock, flags);
 
        /* Matches kref_put() in gadget_unbind(). */
@@ -555,7 +577,7 @@ static void *raw_alloc_io_data(struct usb_raw_ep_io *io, void __user *ptr,
 
        if (copy_from_user(io, ptr, sizeof(*io)))
                return ERR_PTR(-EFAULT);
-       if (io->ep >= USB_RAW_MAX_ENDPOINTS)
+       if (io->ep >= USB_RAW_EPS_NUM_MAX)
                return ERR_PTR(-EINVAL);
        if (!usb_raw_io_flags_valid(io->flags))
                return ERR_PTR(-EINVAL);
@@ -669,43 +691,61 @@ static int raw_ioctl_ep0_read(struct raw_dev *dev, unsigned long value)
        if (IS_ERR(data))
                return PTR_ERR(data);
        ret = raw_process_ep0_io(dev, &io, data, false);
-       if (ret)
+       if (ret < 0)
                goto free;
 
        length = min(io.length, (unsigned int)ret);
        if (copy_to_user((void __user *)(value + sizeof(io)), data, length))
                ret = -EFAULT;
+       else
+               ret = length;
 free:
        kfree(data);
        return ret;
 }
 
-static bool check_ep_caps(struct usb_ep *ep,
-                               struct usb_endpoint_descriptor *desc)
+static int raw_ioctl_ep0_stall(struct raw_dev *dev, unsigned long value)
 {
-       switch (usb_endpoint_type(desc)) {
-       case USB_ENDPOINT_XFER_ISOC:
-               if (!ep->caps.type_iso)
-                       return false;
-               break;
-       case USB_ENDPOINT_XFER_BULK:
-               if (!ep->caps.type_bulk)
-                       return false;
-               break;
-       case USB_ENDPOINT_XFER_INT:
-               if (!ep->caps.type_int)
-                       return false;
-               break;
-       default:
-               return false;
+       int ret = 0;
+       unsigned long flags;
+
+       if (value)
+               return -EINVAL;
+       spin_lock_irqsave(&dev->lock, flags);
+       if (dev->state != STATE_DEV_RUNNING) {
+               dev_dbg(dev->dev, "fail, device is not running\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+       if (!dev->gadget) {
+               dev_dbg(dev->dev, "fail, gadget is not bound\n");
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+       if (dev->ep0_urb_queued) {
+               dev_dbg(&dev->gadget->dev, "fail, urb already queued\n");
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+       if (!dev->ep0_in_pending && !dev->ep0_out_pending) {
+               dev_dbg(&dev->gadget->dev, "fail, no request pending\n");
+               ret = -EBUSY;
+               goto out_unlock;
        }
 
-       if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in)
-               return false;
-       if (usb_endpoint_dir_out(desc) && !ep->caps.dir_out)
-               return false;
+       ret = usb_ep_set_halt(dev->gadget->ep0);
+       if (ret < 0)
+               dev_err(&dev->gadget->dev,
+                               "fail, usb_ep_set_halt returned %d\n", ret);
+
+       if (dev->ep0_in_pending)
+               dev->ep0_in_pending = false;
+       else
+               dev->ep0_out_pending = false;
 
-       return true;
+out_unlock:
+       spin_unlock_irqrestore(&dev->lock, flags);
+       return ret;
 }
 
 static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
@@ -713,7 +753,7 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
        int ret = 0, i;
        unsigned long flags;
        struct usb_endpoint_descriptor *desc;
-       struct usb_ep *ep = NULL;
+       struct raw_ep *ep;
 
        desc = memdup_user((void __user *)value, sizeof(*desc));
        if (IS_ERR(desc))
@@ -741,41 +781,32 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
                goto out_free;
        }
 
-       for (i = 0; i < USB_RAW_MAX_ENDPOINTS; i++) {
-               if (dev->eps[i].state == STATE_EP_ENABLED)
+       for (i = 0; i < dev->eps_num; i++) {
+               ep = &dev->eps[i];
+               if (ep->state != STATE_EP_DISABLED)
                        continue;
-               break;
-       }
-       if (i == USB_RAW_MAX_ENDPOINTS) {
-               dev_dbg(&dev->gadget->dev,
-                               "fail, no device endpoints available\n");
-               ret = -EBUSY;
-               goto out_free;
-       }
-
-       gadget_for_each_ep(ep, dev->gadget) {
-               if (ep->enabled)
+               if (ep->addr != usb_endpoint_num(desc) &&
+                               ep->addr != USB_RAW_EP_ADDR_ANY)
                        continue;
-               if (!check_ep_caps(ep, desc))
+               if (!usb_gadget_ep_match_desc(dev->gadget, ep->ep, desc, NULL))
                        continue;
-               ep->desc = desc;
-               ret = usb_ep_enable(ep);
+               ep->ep->desc = desc;
+               ret = usb_ep_enable(ep->ep);
                if (ret < 0) {
                        dev_err(&dev->gadget->dev,
                                "fail, usb_ep_enable returned %d\n", ret);
                        goto out_free;
                }
-               dev->eps[i].req = usb_ep_alloc_request(ep, GFP_ATOMIC);
-               if (!dev->eps[i].req) {
+               ep->req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC);
+               if (!ep->req) {
                        dev_err(&dev->gadget->dev,
                                "fail, usb_ep_alloc_request failed\n");
-                       usb_ep_disable(ep);
+                       usb_ep_disable(ep->ep);
                        ret = -ENOMEM;
                        goto out_free;
                }
-               dev->eps[i].ep = ep;
-               dev->eps[i].state = STATE_EP_ENABLED;
-               ep->driver_data = &dev->eps[i];
+               ep->state = STATE_EP_ENABLED;
+               ep->ep->driver_data = ep;
                ret = i;
                goto out_unlock;
        }
@@ -794,10 +825,6 @@ static int raw_ioctl_ep_disable(struct raw_dev *dev, unsigned long value)
 {
        int ret = 0, i = value;
        unsigned long flags;
-       const void *desc;
-
-       if (i < 0 || i >= USB_RAW_MAX_ENDPOINTS)
-               return -EINVAL;
 
        spin_lock_irqsave(&dev->lock, flags);
        if (dev->state != STATE_DEV_RUNNING) {
@@ -810,7 +837,12 @@ static int raw_ioctl_ep_disable(struct raw_dev *dev, unsigned long value)
                ret = -EBUSY;
                goto out_unlock;
        }
-       if (dev->eps[i].state != STATE_EP_ENABLED) {
+       if (i < 0 || i >= dev->eps_num) {
+               dev_dbg(dev->dev, "fail, invalid endpoint\n");
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+       if (dev->eps[i].state == STATE_EP_DISABLED) {
                dev_dbg(&dev->gadget->dev, "fail, endpoint is not enabled\n");
                ret = -EINVAL;
                goto out_unlock;
@@ -834,10 +866,8 @@ static int raw_ioctl_ep_disable(struct raw_dev *dev, unsigned long value)
 
        spin_lock_irqsave(&dev->lock, flags);
        usb_ep_free_request(dev->eps[i].ep, dev->eps[i].req);
-       desc = dev->eps[i].ep->desc;
-       dev->eps[i].ep = NULL;
+       kfree(dev->eps[i].ep->desc);
        dev->eps[i].state = STATE_EP_DISABLED;
-       kfree(desc);
        dev->eps[i].disabling = false;
 
 out_unlock:
@@ -845,6 +875,74 @@ out_unlock:
        return ret;
 }
 
+static int raw_ioctl_ep_set_clear_halt_wedge(struct raw_dev *dev,
+               unsigned long value, bool set, bool halt)
+{
+       int ret = 0, i = value;
+       unsigned long flags;
+
+       spin_lock_irqsave(&dev->lock, flags);
+       if (dev->state != STATE_DEV_RUNNING) {
+               dev_dbg(dev->dev, "fail, device is not running\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+       if (!dev->gadget) {
+               dev_dbg(dev->dev, "fail, gadget is not bound\n");
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+       if (i < 0 || i >= dev->eps_num) {
+               dev_dbg(dev->dev, "fail, invalid endpoint\n");
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+       if (dev->eps[i].state == STATE_EP_DISABLED) {
+               dev_dbg(&dev->gadget->dev, "fail, endpoint is not enabled\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+       if (dev->eps[i].disabling) {
+               dev_dbg(&dev->gadget->dev,
+                               "fail, disable is in progress\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+       if (dev->eps[i].urb_queued) {
+               dev_dbg(&dev->gadget->dev,
+                               "fail, waiting for urb completion\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+       if (usb_endpoint_xfer_isoc(dev->eps[i].ep->desc)) {
+               dev_dbg(&dev->gadget->dev,
+                               "fail, can't halt/wedge ISO endpoint\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+
+       if (set && halt) {
+               ret = usb_ep_set_halt(dev->eps[i].ep);
+               if (ret < 0)
+                       dev_err(&dev->gadget->dev,
+                               "fail, usb_ep_set_halt returned %d\n", ret);
+       } else if (!set && halt) {
+               ret = usb_ep_clear_halt(dev->eps[i].ep);
+               if (ret < 0)
+                       dev_err(&dev->gadget->dev,
+                               "fail, usb_ep_clear_halt returned %d\n", ret);
+       } else if (set && !halt) {
+               ret = usb_ep_set_wedge(dev->eps[i].ep);
+               if (ret < 0)
+                       dev_err(&dev->gadget->dev,
+                               "fail, usb_ep_set_wedge returned %d\n", ret);
+       }
+
+out_unlock:
+       spin_unlock_irqrestore(&dev->lock, flags);
+       return ret;
+}
+
 static void gadget_ep_complete(struct usb_ep *ep, struct usb_request *req)
 {
        struct raw_ep *r_ep = (struct raw_ep *)ep->driver_data;
@@ -866,7 +964,7 @@ static int raw_process_ep_io(struct raw_dev *dev, struct usb_raw_ep_io *io,
 {
        int ret = 0;
        unsigned long flags;
-       struct raw_ep *ep = &dev->eps[io->ep];
+       struct raw_ep *ep;
        DECLARE_COMPLETION_ONSTACK(done);
 
        spin_lock_irqsave(&dev->lock, flags);
@@ -880,6 +978,12 @@ static int raw_process_ep_io(struct raw_dev *dev, struct usb_raw_ep_io *io,
                ret = -EBUSY;
                goto out_unlock;
        }
+       if (io->ep >= dev->eps_num) {
+               dev_dbg(&dev->gadget->dev, "fail, invalid endpoint\n");
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+       ep = &dev->eps[io->ep];
        if (ep->state != STATE_EP_ENABLED) {
                dev_dbg(&dev->gadget->dev, "fail, endpoint is not enabled\n");
                ret = -EBUSY;
@@ -964,12 +1068,14 @@ static int raw_ioctl_ep_read(struct raw_dev *dev, unsigned long value)
        if (IS_ERR(data))
                return PTR_ERR(data);
        ret = raw_process_ep_io(dev, &io, data, false);
-       if (ret)
+       if (ret < 0)
                goto free;
 
        length = min(io.length, (unsigned int)ret);
        if (copy_to_user((void __user *)(value + sizeof(io)), data, length))
                ret = -EFAULT;
+       else
+               ret = length;
 free:
        kfree(data);
        return ret;
@@ -1023,6 +1129,71 @@ out_unlock:
        return ret;
 }
 
+static void fill_ep_caps(struct usb_ep_caps *caps,
+                               struct usb_raw_ep_caps *raw_caps)
+{
+       raw_caps->type_control = caps->type_control;
+       raw_caps->type_iso = caps->type_iso;
+       raw_caps->type_bulk = caps->type_bulk;
+       raw_caps->type_int = caps->type_int;
+       raw_caps->dir_in = caps->dir_in;
+       raw_caps->dir_out = caps->dir_out;
+}
+
+static void fill_ep_limits(struct usb_ep *ep, struct usb_raw_ep_limits *limits)
+{
+       limits->maxpacket_limit = ep->maxpacket_limit;
+       limits->max_streams = ep->max_streams;
+}
+
+static int raw_ioctl_eps_info(struct raw_dev *dev, unsigned long value)
+{
+       int ret = 0, i;
+       unsigned long flags;
+       struct usb_raw_eps_info *info;
+       struct raw_ep *ep;
+
+       info = kmalloc(sizeof(*info), GFP_KERNEL);
+       if (!info) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       spin_lock_irqsave(&dev->lock, flags);
+       if (dev->state != STATE_DEV_RUNNING) {
+               dev_dbg(dev->dev, "fail, device is not running\n");
+               ret = -EINVAL;
+               spin_unlock_irqrestore(&dev->lock, flags);
+               goto out_free;
+       }
+       if (!dev->gadget) {
+               dev_dbg(dev->dev, "fail, gadget is not bound\n");
+               ret = -EBUSY;
+               spin_unlock_irqrestore(&dev->lock, flags);
+               goto out_free;
+       }
+
+       memset(info, 0, sizeof(*info));
+       for (i = 0; i < dev->eps_num; i++) {
+               ep = &dev->eps[i];
+               strscpy(&info->eps[i].name[0], ep->ep->name,
+                               USB_RAW_EP_NAME_MAX);
+               info->eps[i].addr = ep->addr;
+               fill_ep_caps(&ep->ep->caps, &info->eps[i].caps);
+               fill_ep_limits(ep->ep, &info->eps[i].limits);
+       }
+       ret = dev->eps_num;
+       spin_unlock_irqrestore(&dev->lock, flags);
+
+       if (copy_to_user((void __user *)value, info, sizeof(*info)))
+               ret = -EFAULT;
+
+out_free:
+       kfree(info);
+out:
+       return ret;
+}
+
 static long raw_ioctl(struct file *fd, unsigned int cmd, unsigned long value)
 {
        struct raw_dev *dev = fd->private_data;
@@ -1065,6 +1236,24 @@ static long raw_ioctl(struct file *fd, unsigned int cmd, unsigned long value)
        case USB_RAW_IOCTL_VBUS_DRAW:
                ret = raw_ioctl_vbus_draw(dev, value);
                break;
+       case USB_RAW_IOCTL_EPS_INFO:
+               ret = raw_ioctl_eps_info(dev, value);
+               break;
+       case USB_RAW_IOCTL_EP0_STALL:
+               ret = raw_ioctl_ep0_stall(dev, value);
+               break;
+       case USB_RAW_IOCTL_EP_SET_HALT:
+               ret = raw_ioctl_ep_set_clear_halt_wedge(
+                                       dev, value, true, true);
+               break;
+       case USB_RAW_IOCTL_EP_CLEAR_HALT:
+               ret = raw_ioctl_ep_set_clear_halt_wedge(
+                                       dev, value, false, true);
+               break;
+       case USB_RAW_IOCTL_EP_SET_WEDGE:
+               ret = raw_ioctl_ep_set_clear_halt_wedge(
+                                       dev, value, true, false);
+               break;
        default:
                ret = -EINVAL;
        }
index 2220034..b771a85 100644 (file)
@@ -185,7 +185,7 @@ static int regs_dbg_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-const struct file_operations queue_dbg_fops = {
+static const struct file_operations queue_dbg_fops = {
        .owner          = THIS_MODULE,
        .open           = queue_dbg_open,
        .llseek         = no_llseek,
@@ -193,7 +193,7 @@ const struct file_operations queue_dbg_fops = {
        .release        = queue_dbg_release,
 };
 
-const struct file_operations regs_dbg_fops = {
+static const struct file_operations regs_dbg_fops = {
        .owner          = THIS_MODULE,
        .open           = regs_dbg_open,
        .llseek         = generic_file_llseek,
index a8273b5..5af0fe9 100644 (file)
@@ -2647,6 +2647,8 @@ net2272_plat_probe(struct platform_device *pdev)
  err_req:
        release_mem_region(base, len);
  err:
+       kfree(dev);
+
        return ret;
 }
 
index 52a6add..dfabc54 100644 (file)
@@ -3840,11 +3840,11 @@ static int __maybe_unused tegra_xudc_suspend(struct device *dev)
 
        flush_work(&xudc->usb_role_sw_work);
 
-       /* Forcibly disconnect before powergating. */
-       tegra_xudc_device_mode_off(xudc);
-
-       if (!pm_runtime_status_suspended(dev))
+       if (!pm_runtime_status_suspended(dev)) {
+               /* Forcibly disconnect before powergating. */
+               tegra_xudc_device_mode_off(xudc);
                tegra_xudc_powergate(xudc);
+       }
 
        pm_runtime_disable(dev);
 
index 1d4f6f8..ea460b9 100644 (file)
@@ -362,6 +362,7 @@ static int xhci_plat_remove(struct platform_device *dev)
        struct clk *reg_clk = xhci->reg_clk;
        struct usb_hcd *shared_hcd = xhci->shared_hcd;
 
+       pm_runtime_get_sync(&dev->dev);
        xhci->xhc_state |= XHCI_STATE_REMOVING;
 
        usb_remove_hcd(shared_hcd);
@@ -375,8 +376,9 @@ static int xhci_plat_remove(struct platform_device *dev)
        clk_disable_unprepare(reg_clk);
        usb_put_hcd(hcd);
 
-       pm_runtime_set_suspended(&dev->dev);
        pm_runtime_disable(&dev->dev);
+       pm_runtime_put_noidle(&dev->dev);
+       pm_runtime_set_suspended(&dev->dev);
 
        return 0;
 }
index 0fda0c0..2c255d0 100644 (file)
@@ -3433,8 +3433,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
                        /* New sg entry */
                        --num_sgs;
                        sent_len -= block_len;
-                       if (num_sgs != 0) {
-                               sg = sg_next(sg);
+                       sg = sg_next(sg);
+                       if (num_sgs != 0 && sg) {
                                block_len = sg_dma_len(sg);
                                addr = (u64) sg_dma_address(sg);
                                addr += sent_len;
index c96e5da..fdeade6 100644 (file)
@@ -276,7 +276,7 @@ static const struct file_operations mtu3_ep_fops = {
        .release = single_release,
 };
 
-static struct debugfs_reg32 mtu3_prb_regs[] = {
+static const struct debugfs_reg32 mtu3_prb_regs[] = {
        dump_prb_reg("enable", U3D_SSUSB_PRB_CTRL0),
        dump_prb_reg("byte-sell", U3D_SSUSB_PRB_CTRL1),
        dump_prb_reg("byte-selh", U3D_SSUSB_PRB_CTRL2),
@@ -349,7 +349,7 @@ static const struct file_operations mtu3_probe_fops = {
 static void mtu3_debugfs_create_prb_files(struct mtu3 *mtu)
 {
        struct ssusb_mtk *ssusb = mtu->ssusb;
-       struct debugfs_reg32 *regs;
+       const struct debugfs_reg32 *regs;
        struct dentry *dir_prb;
        int i;
 
index bfebf1f..9a7e655 100644 (file)
@@ -377,7 +377,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
        if (status < 0) {
                dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
                        twl->irq1, status);
-               return status;
+               goto err_put_regulator;
        }
 
        status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
@@ -386,8 +386,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
        if (status < 0) {
                dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
                        twl->irq2, status);
-               free_irq(twl->irq1, twl);
-               return status;
+               goto err_free_irq1;
        }
 
        twl->asleep = 0;
@@ -396,6 +395,13 @@ static int twl6030_usb_probe(struct platform_device *pdev)
        dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");
 
        return 0;
+
+err_free_irq1:
+       free_irq(twl->irq1, twl);
+err_put_regulator:
+       regulator_put(twl->usb3v3);
+
+       return status;
 }
 
 static int twl6030_usb_remove(struct platform_device *pdev)
index 67c5139..c22e5c4 100644 (file)
@@ -63,6 +63,7 @@ enum {
 #define PMC_USB_ALTMODE_DP_MODE_SHIFT  8
 
 /* TBT specific Mode Data bits */
+#define PMC_USB_ALTMODE_HPD_HIGH       BIT(14)
 #define PMC_USB_ALTMODE_TBT_TYPE       BIT(17)
 #define PMC_USB_ALTMODE_CABLE_TYPE     BIT(18)
 #define PMC_USB_ALTMODE_ACTIVE_LINK    BIT(20)
@@ -74,8 +75,8 @@ enum {
 #define PMC_USB_ALTMODE_TBT_GEN(_g_)   (((_g_) & GENMASK(1, 0)) << 28)
 
 /* Display HPD Request bits */
+#define PMC_USB_DP_HPD_LVL             BIT(4)
 #define PMC_USB_DP_HPD_IRQ             BIT(5)
-#define PMC_USB_DP_HPD_LVL             BIT(6)
 
 struct pmc_usb;
 
@@ -158,8 +159,7 @@ pmc_usb_mux_dp(struct pmc_usb_port *port, struct typec_mux_state *state)
                         PMC_USB_ALTMODE_DP_MODE_SHIFT;
 
        if (data->status & DP_STATUS_HPD_STATE)
-               req.mode_data |= PMC_USB_DP_HPD_LVL <<
-                                PMC_USB_ALTMODE_DP_MODE_SHIFT;
+               req.mode_data |= PMC_USB_ALTMODE_HPD_HIGH;
 
        return pmc_usb_command(port, (void *)&req, sizeof(req));
 }
index 7957d2d..01c456f 100644 (file)
@@ -89,15 +89,14 @@ static struct vdpasim *dev_to_sim(struct device *dev)
 static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
 {
        struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
-       int ret;
 
-       ret = vringh_init_iotlb(&vq->vring, vdpasim_features,
-                               VDPASIM_QUEUE_MAX, false,
-                               (struct vring_desc *)(uintptr_t)vq->desc_addr,
-                               (struct vring_avail *)
-                               (uintptr_t)vq->driver_addr,
-                               (struct vring_used *)
-                               (uintptr_t)vq->device_addr);
+       vringh_init_iotlb(&vq->vring, vdpasim_features,
+                         VDPASIM_QUEUE_MAX, false,
+                         (struct vring_desc *)(uintptr_t)vq->desc_addr,
+                         (struct vring_avail *)
+                         (uintptr_t)vq->driver_addr,
+                         (struct vring_used *)
+                         (uintptr_t)vq->device_addr);
 }
 
 static void vdpasim_vq_reset(struct vdpasim_virtqueue *vq)
index d450e16..21a59b5 100644 (file)
@@ -730,7 +730,7 @@ static inline void __user *vhost_vq_meta_fetch(struct vhost_virtqueue *vq,
        if (!map)
                return NULL;
 
-       return (void *)(uintptr_t)(map->addr + addr - map->start);
+       return (void __user *)(uintptr_t)(map->addr + addr - map->start);
 }
 
 /* Can we switch to this memory table? */
@@ -869,7 +869,7 @@ static void __user *__vhost_get_user_slow(struct vhost_virtqueue *vq,
  * not happen in this case.
  */
 static inline void __user *__vhost_get_user(struct vhost_virtqueue *vq,
-                                           void *addr, unsigned int size,
+                                           void __user *addr, unsigned int size,
                                            int type)
 {
        void __user *uaddr = vhost_vq_meta_fetch(vq,
index 68fc466..d2b3798 100644 (file)
@@ -385,8 +385,6 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                ASSERTCMP(req->offset, <=, PAGE_SIZE);
                if (req->offset == PAGE_SIZE) {
                        req->offset = 0;
-                       if (req->page_done)
-                               req->page_done(req);
                        req->index++;
                        if (req->remain > 0)
                                goto begin_page;
@@ -440,11 +438,13 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                if (req->offset < PAGE_SIZE)
                        zero_user_segment(req->pages[req->index],
                                          req->offset, PAGE_SIZE);
-               if (req->page_done)
-                       req->page_done(req);
                req->offset = 0;
        }
 
+       if (req->page_done)
+               for (req->index = 0; req->index < req->nr_pages; req->index++)
+                       req->page_done(req);
+
        _leave(" = 0 [done]");
        return 0;
 }
index b5b45c5..fe413e7 100644 (file)
@@ -497,8 +497,6 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                ASSERTCMP(req->offset, <=, PAGE_SIZE);
                if (req->offset == PAGE_SIZE) {
                        req->offset = 0;
-                       if (req->page_done)
-                               req->page_done(req);
                        req->index++;
                        if (req->remain > 0)
                                goto begin_page;
@@ -556,11 +554,13 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                if (req->offset < PAGE_SIZE)
                        zero_user_segment(req->pages[req->index],
                                          req->offset, PAGE_SIZE);
-               if (req->page_done)
-                       req->page_done(req);
                req->offset = 0;
        }
 
+       if (req->page_done)
+               for (req->index = 0; req->index < req->nr_pages; req->index++)
+                       req->page_done(req);
+
        _leave(" = 0 [done]");
        return 0;
 }
index 1dc97f2..e7726f5 100644 (file)
@@ -60,9 +60,9 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode,
        object = container_of(op->op.object, struct cachefiles_object, fscache);
        spin_lock(&object->work_lock);
        list_add_tail(&monitor->op_link, &op->to_do);
+       fscache_enqueue_retrieval(op);
        spin_unlock(&object->work_lock);
 
-       fscache_enqueue_retrieval(op);
        fscache_put_retrieval(op);
        return 0;
 }
@@ -398,7 +398,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
        struct inode *inode;
        sector_t block;
        unsigned shift;
-       int ret;
+       int ret, ret2;
 
        object = container_of(op->op.object,
                              struct cachefiles_object, fscache);
@@ -430,8 +430,8 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
        block = page->index;
        block <<= shift;
 
-       ret = bmap(inode, &block);
-       ASSERT(ret < 0);
+       ret2 = bmap(inode, &block);
+       ASSERT(ret2 == 0);
 
        _debug("%llx -> %llx",
               (unsigned long long) (page->index << shift),
@@ -739,8 +739,8 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
                block = page->index;
                block <<= shift;
 
-               ret = bmap(inode, &block);
-               ASSERT(!ret);
+               ret2 = bmap(inode, &block);
+               ASSERT(ret2 == 0);
 
                _debug("%llx -> %llx",
                       (unsigned long long) (page->index << shift),
index 182b864..5014a82 100644 (file)
@@ -2152,8 +2152,8 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
                        }
                }
 
+               kref_put(&wdata2->refcount, cifs_writedata_release);
                if (rc) {
-                       kref_put(&wdata2->refcount, cifs_writedata_release);
                        if (is_retryable_error(rc))
                                continue;
                        i += nr_pages;
index 0b1528e..75ddce8 100644 (file)
@@ -4060,7 +4060,7 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
                         * than it negotiated since it will refuse the read
                         * then.
                         */
-                       if ((tcon->ses) && !(tcon->ses->capabilities &
+                       if (!(tcon->ses->capabilities &
                                tcon->ses->server->vals->cap_large_files)) {
                                current_read_size = min_t(uint,
                                        current_read_size, CIFSMaxBufSize);
index 390d2b1..5d2965a 100644 (file)
@@ -730,7 +730,7 @@ static __u64 simple_hashstr(const char *str)
  * cifs_backup_query_path_info - SMB1 fallback code to get ino
  *
  * Fallback code to get file metadata when we don't have access to
- * @full_path (EACCESS) and have backup creds.
+ * @full_path (EACCES) and have backup creds.
  *
  * @data will be set to search info result buffer
  * @resp_buf will be set to cifs resp buf and needs to be freed with
index aba03ee..12eebcd 100644 (file)
@@ -1879,34 +1879,33 @@ fetch_events:
                 * event delivery.
                 */
                init_wait(&wait);
-               write_lock_irq(&ep->lock);
-               __add_wait_queue_exclusive(&ep->wq, &wait);
-               write_unlock_irq(&ep->lock);
 
+               write_lock_irq(&ep->lock);
                /*
-                * We don't want to sleep if the ep_poll_callback() sends us
-                * a wakeup in between. That's why we set the task state
-                * to TASK_INTERRUPTIBLE before doing the checks.
+                * Barrierless variant, waitqueue_active() is called under
+                * the same lock on wakeup ep_poll_callback() side, so it
+                * is safe to avoid an explicit barrier.
                 */
-               set_current_state(TASK_INTERRUPTIBLE);
+               __set_current_state(TASK_INTERRUPTIBLE);
+
                /*
-                * Always short-circuit for fatal signals to allow
-                * threads to make a timely exit without the chance of
-                * finding more events available and fetching
-                * repeatedly.
+                * Do the final check under the lock. ep_scan_ready_list()
+                * plays with two lists (->rdllist and ->ovflist) and there
+                * is always a race when both lists are empty for short
+                * period of time although events are pending, so lock is
+                * important.
                 */
-               if (fatal_signal_pending(current)) {
-                       res = -EINTR;
-                       break;
+               eavail = ep_events_available(ep);
+               if (!eavail) {
+                       if (signal_pending(current))
+                               res = -EINTR;
+                       else
+                               __add_wait_queue_exclusive(&ep->wq, &wait);
                }
+               write_unlock_irq(&ep->lock);
 
-               eavail = ep_events_available(ep);
-               if (eavail)
-                       break;
-               if (signal_pending(current)) {
-                       res = -EINTR;
+               if (eavail || res)
                        break;
-               }
 
                if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) {
                        timed_out = 1;
@@ -1927,6 +1926,15 @@ fetch_events:
        }
 
 send_events:
+       if (fatal_signal_pending(current)) {
+               /*
+                * Always short-circuit for fatal signals to allow
+                * threads to make a timely exit without the chance of
+                * finding more events available and fetching
+                * repeatedly.
+                */
+               res = -EINTR;
+       }
        /*
         * Try to transfer events to user space. In case we get 0 events and
         * there's still timeout left over, we go trying again in search of
index 06b4c55..2c46511 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1317,6 +1317,8 @@ int flush_old_exec(struct linux_binprm * bprm)
         */
        set_mm_exe_file(bprm->mm, bprm->file);
 
+       would_dump(bprm, bprm->file);
+
        /*
         * Release all of the old mmap stuff
         */
@@ -1876,8 +1878,6 @@ static int __do_execve_file(int fd, struct filename *filename,
        if (retval < 0)
                goto out;
 
-       would_dump(bprm, bprm->file);
-
        retval = exec_binprm(bprm);
        if (retval < 0)
                goto out;
index 4f76764..c9db8eb 100644 (file)
@@ -348,12 +348,13 @@ out:
 }
 
 const struct file_operations exfat_file_operations = {
-       .llseek      = generic_file_llseek,
-       .read_iter   = generic_file_read_iter,
-       .write_iter  = generic_file_write_iter,
-       .mmap        = generic_file_mmap,
-       .fsync       = generic_file_fsync,
-       .splice_read = generic_file_splice_read,
+       .llseek         = generic_file_llseek,
+       .read_iter      = generic_file_read_iter,
+       .write_iter     = generic_file_write_iter,
+       .mmap           = generic_file_mmap,
+       .fsync          = generic_file_fsync,
+       .splice_read    = generic_file_splice_read,
+       .splice_write   = iter_file_splice_write,
 };
 
 const struct inode_operations exfat_file_inode_operations = {
index b72d782..a2659a8 100644 (file)
@@ -692,6 +692,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
                        exfat_fs_error(sb,
                                "non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
                                i_size_read(dir), ei->dir.dir, ei->entry);
+                       kfree(es);
                        return -EIO;
                }
 
index 0565d55..a846ff5 100644 (file)
@@ -203,6 +203,12 @@ enum {
        Opt_errors,
        Opt_discard,
        Opt_time_offset,
+
+       /* Deprecated options */
+       Opt_utf8,
+       Opt_debug,
+       Opt_namecase,
+       Opt_codepage,
 };
 
 static const struct constant_table exfat_param_enums[] = {
@@ -223,6 +229,14 @@ static const struct fs_parameter_spec exfat_parameters[] = {
        fsparam_enum("errors",                  Opt_errors, exfat_param_enums),
        fsparam_flag("discard",                 Opt_discard),
        fsparam_s32("time_offset",              Opt_time_offset),
+       __fsparam(NULL, "utf8",                 Opt_utf8, fs_param_deprecated,
+                 NULL),
+       __fsparam(NULL, "debug",                Opt_debug, fs_param_deprecated,
+                 NULL),
+       __fsparam(fs_param_is_u32, "namecase",  Opt_namecase,
+                 fs_param_deprecated, NULL),
+       __fsparam(fs_param_is_u32, "codepage",  Opt_codepage,
+                 fs_param_deprecated, NULL),
        {}
 };
 
@@ -278,6 +292,11 @@ static int exfat_parse_param(struct fs_context *fc, struct fs_parameter *param)
                        return -EINVAL;
                opts->time_offset = result.int_32;
                break;
+       case Opt_utf8:
+       case Opt_debug:
+       case Opt_namecase:
+       case Opt_codepage:
+               break;
        default:
                return -EINVAL;
        }
index 91eb438..ad2dbf6 100644 (file)
@@ -722,7 +722,7 @@ enum {
 #define EXT4_MAX_BLOCK_FILE_PHYS       0xFFFFFFFF
 
 /* Max logical block we can support */
-#define EXT4_MAX_LOGICAL_BLOCK         0xFFFFFFFF
+#define EXT4_MAX_LOGICAL_BLOCK         0xFFFFFFFE
 
 /*
  * Structure of an inode on the disk
index f2b577b..2b4b945 100644 (file)
@@ -4832,6 +4832,28 @@ static const struct iomap_ops ext4_iomap_xattr_ops = {
        .iomap_begin            = ext4_iomap_xattr_begin,
 };
 
+static int ext4_fiemap_check_ranges(struct inode *inode, u64 start, u64 *len)
+{
+       u64 maxbytes;
+
+       if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+               maxbytes = inode->i_sb->s_maxbytes;
+       else
+               maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
+
+       if (*len == 0)
+               return -EINVAL;
+       if (start > maxbytes)
+               return -EFBIG;
+
+       /*
+        * Shrink request scope to what the fs can actually handle.
+        */
+       if (*len > maxbytes || (maxbytes - *len) < start)
+               *len = maxbytes - start;
+       return 0;
+}
+
 static int _ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                        __u64 start, __u64 len, bool from_es_cache)
 {
@@ -4852,6 +4874,15 @@ static int _ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
        if (fiemap_check_flags(fieinfo, ext4_fiemap_flags))
                return -EBADR;
 
+       /*
+        * For bitmap files the maximum size limit could be smaller than
+        * s_maxbytes, so check len here manually instead of just relying on the
+        * generic check.
+        */
+       error = ext4_fiemap_check_ranges(inode, start, &len);
+       if (error)
+               return error;
+
        if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
                fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR;
                error = iomap_fiemap(inode, fieinfo, start, len,
index bfc1281..0746532 100644 (file)
@@ -733,29 +733,6 @@ static void ext4_fill_fsxattr(struct inode *inode, struct fsxattr *fa)
                fa->fsx_projid = from_kprojid(&init_user_ns, ei->i_projid);
 }
 
-/* copied from fs/ioctl.c */
-static int fiemap_check_ranges(struct super_block *sb,
-                              u64 start, u64 len, u64 *new_len)
-{
-       u64 maxbytes = (u64) sb->s_maxbytes;
-
-       *new_len = len;
-
-       if (len == 0)
-               return -EINVAL;
-
-       if (start > maxbytes)
-               return -EFBIG;
-
-       /*
-        * Shrink request scope to what the fs can actually handle.
-        */
-       if (len > maxbytes || (maxbytes - len) < start)
-               *new_len = maxbytes - start;
-
-       return 0;
-}
-
 /* So that the fiemap access checks can't overflow on 32 bit machines. */
 #define FIEMAP_MAX_EXTENTS     (UINT_MAX / sizeof(struct fiemap_extent))
 
@@ -765,8 +742,6 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
        struct fiemap __user *ufiemap = (struct fiemap __user *) arg;
        struct fiemap_extent_info fieinfo = { 0, };
        struct inode *inode = file_inode(filp);
-       struct super_block *sb = inode->i_sb;
-       u64 len;
        int error;
 
        if (copy_from_user(&fiemap, ufiemap, sizeof(fiemap)))
@@ -775,11 +750,6 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
        if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
                return -EINVAL;
 
-       error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
-                                   &len);
-       if (error)
-               return error;
-
        fieinfo.fi_flags = fiemap.fm_flags;
        fieinfo.fi_extents_max = fiemap.fm_extent_count;
        fieinfo.fi_extents_start = ufiemap->fm_extents;
@@ -792,7 +762,8 @@ static int ext4_ioctl_get_es_cache(struct file *filp, unsigned long arg)
        if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
                filemap_write_and_wait(inode->i_mapping);
 
-       error = ext4_get_es_cache(inode, &fieinfo, fiemap.fm_start, len);
+       error = ext4_get_es_cache(inode, &fieinfo, fiemap.fm_start,
+                       fiemap.fm_length);
        fiemap.fm_flags = fieinfo.fi_flags;
        fiemap.fm_mapped_extents = fieinfo.fi_extents_mapped;
        if (copy_to_user(ufiemap, &fiemap, sizeof(fiemap)))
index c8a4e4c..abb8b70 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -70,7 +70,7 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct fdtable *ofdt,
  */
 static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt)
 {
-       unsigned int cpy, set;
+       size_t cpy, set;
 
        BUG_ON(nfdt->max_fds < ofdt->max_fds);
 
index 936a8ec..6306eaa 100644 (file)
@@ -528,10 +528,12 @@ lower_metapath:
 
                /* Advance in metadata tree. */
                (mp->mp_list[hgt])++;
-               if (mp->mp_list[hgt] >= sdp->sd_inptrs) {
-                       if (!hgt)
+               if (hgt) {
+                       if (mp->mp_list[hgt] >= sdp->sd_inptrs)
+                               goto lower_metapath;
+               } else {
+                       if (mp->mp_list[hgt] >= sdp->sd_diptrs)
                                break;
-                       goto lower_metapath;
                }
 
 fill_up_metapath:
@@ -876,10 +878,9 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
                                        ret = -ENOENT;
                                        goto unlock;
                                } else {
-                                       /* report a hole */
                                        iomap->offset = pos;
                                        iomap->length = length;
-                                       goto do_alloc;
+                                       goto hole_found;
                                }
                        }
                        iomap->length = size;
@@ -933,8 +934,6 @@ unlock:
        return ret;
 
 do_alloc:
-       iomap->addr = IOMAP_NULL_ADDR;
-       iomap->type = IOMAP_HOLE;
        if (flags & IOMAP_REPORT) {
                if (pos >= size)
                        ret = -ENOENT;
@@ -956,6 +955,9 @@ do_alloc:
                if (pos < size && height == ip->i_height)
                        ret = gfs2_hole_size(inode, lblock, len, mp, iomap);
        }
+hole_found:
+       iomap->addr = IOMAP_NULL_ADDR;
+       iomap->type = IOMAP_HOLE;
        goto out;
 }
 
index 29f9b66..bf70e3b 100644 (file)
@@ -613,7 +613,7 @@ __acquires(&gl->gl_lockref.lock)
                                fs_err(sdp, "Error %d syncing glock \n", ret);
                                gfs2_dump_glock(NULL, gl, true);
                        }
-                       return;
+                       goto skip_inval;
                }
        }
        if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags)) {
@@ -633,6 +633,7 @@ __acquires(&gl->gl_lockref.lock)
                clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags);
        }
 
+skip_inval:
        gfs2_glock_hold(gl);
        /*
         * Check for an error encountered since we called go_sync and go_inval.
@@ -722,9 +723,6 @@ __acquires(&gl->gl_lockref.lock)
                        goto out_unlock;
                if (nonblock)
                        goto out_sched;
-               smp_mb();
-               if (atomic_read(&gl->gl_revokes) != 0)
-                       goto out_sched;
                set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
                GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
                gl->gl_target = gl->gl_demote_state;
index 70b2d3a..5acd3ce 100644 (file)
@@ -622,7 +622,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
                                error = finish_no_open(file, NULL);
                }
                gfs2_glock_dq_uninit(ghs);
-               return error;
+               goto fail;
        } else if (error != -ENOENT) {
                goto fail_gunlock;
        }
@@ -764,9 +764,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
                error = finish_open(file, dentry, gfs2_open_common);
        }
        gfs2_glock_dq_uninit(ghs);
+       gfs2_qa_put(ip);
        gfs2_glock_dq_uninit(ghs + 1);
        clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
        gfs2_glock_put(io_gl);
+       gfs2_qa_put(dip);
        return error;
 
 fail_gunlock3:
@@ -776,7 +778,6 @@ fail_gunlock2:
        clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
        gfs2_glock_put(io_gl);
 fail_free_inode:
-       gfs2_qa_put(ip);
        if (ip->i_gl) {
                glock_clear_object(ip->i_gl, ip);
                gfs2_glock_put(ip->i_gl);
@@ -1005,7 +1006,7 @@ out_gunlock:
 out_child:
        gfs2_glock_dq(ghs);
 out_parent:
-       gfs2_qa_put(ip);
+       gfs2_qa_put(dip);
        gfs2_holder_uninit(ghs);
        gfs2_holder_uninit(ghs + 1);
        return error;
index 3a75843..0644e58 100644 (file)
@@ -669,13 +669,13 @@ void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
        struct buffer_head *bh = bd->bd_bh;
        struct gfs2_glock *gl = bd->bd_gl;
 
+       sdp->sd_log_num_revoke++;
+       if (atomic_inc_return(&gl->gl_revokes) == 1)
+               gfs2_glock_hold(gl);
        bh->b_private = NULL;
        bd->bd_blkno = bh->b_blocknr;
        gfs2_remove_from_ail(bd); /* drops ref on bh */
        bd->bd_bh = NULL;
-       sdp->sd_log_num_revoke++;
-       if (atomic_inc_return(&gl->gl_revokes) == 1)
-               gfs2_glock_hold(gl);
        set_bit(GLF_LFLUSH, &gl->gl_flags);
        list_add(&bd->bd_list, &sdp->sd_log_revokes);
 }
@@ -1131,6 +1131,10 @@ int gfs2_logd(void *data)
 
        while (!kthread_should_stop()) {
 
+               if (gfs2_withdrawn(sdp)) {
+                       msleep_interruptible(HZ);
+                       continue;
+               }
                /* Check for errors writing to the journal */
                if (sdp->sd_log_error) {
                        gfs2_lm(sdp,
@@ -1139,6 +1143,7 @@ int gfs2_logd(void *data)
                                "prevent further damage.\n",
                                sdp->sd_fsname, sdp->sd_log_error);
                        gfs2_withdraw(sdp);
+                       continue;
                }
 
                did_flush = false;
index 5ea9675..48b54ec 100644 (file)
@@ -263,7 +263,7 @@ static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno,
        struct super_block *sb = sdp->sd_vfs;
        struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
 
-       bio->bi_iter.bi_sector = blkno << (sb->s_blocksize_bits - 9);
+       bio->bi_iter.bi_sector = blkno << sdp->sd_fsb2bb_shift;
        bio_set_dev(bio, sb->s_bdev);
        bio->bi_end_io = end_io;
        bio->bi_private = sdp;
@@ -509,7 +509,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
        unsigned int bsize = sdp->sd_sb.sb_bsize, off;
        unsigned int bsize_shift = sdp->sd_sb.sb_bsize_shift;
        unsigned int shift = PAGE_SHIFT - bsize_shift;
-       unsigned int readahead_blocks = BIO_MAX_PAGES << shift;
+       unsigned int max_bio_size = 2 * 1024 * 1024;
        struct gfs2_journal_extent *je;
        int sz, ret = 0;
        struct bio *bio = NULL;
@@ -537,12 +537,17 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
                                off = 0;
                        }
 
-                       if (!bio || (bio_chained && !off)) {
+                       if (!bio || (bio_chained && !off) ||
+                           bio->bi_iter.bi_size >= max_bio_size) {
                                /* start new bio */
                        } else {
-                               sz = bio_add_page(bio, page, bsize, off);
-                               if (sz == bsize)
-                                       goto block_added;
+                               sector_t sector = dblock << sdp->sd_fsb2bb_shift;
+
+                               if (bio_end_sector(bio) == sector) {
+                                       sz = bio_add_page(bio, page, bsize, off);
+                                       if (sz == bsize)
+                                               goto block_added;
+                               }
                                if (off) {
                                        unsigned int blocks =
                                                (PAGE_SIZE - off) >> bsize_shift;
@@ -568,7 +573,7 @@ block_added:
                        off += bsize;
                        if (off == PAGE_SIZE)
                                page = NULL;
-                       if (blocks_submitted < blocks_read + readahead_blocks) {
+                       if (blocks_submitted < 2 * max_bio_size >> bsize_shift) {
                                /* Keep at least one bio in flight */
                                continue;
                        }
index 4b72abc..9856cc2 100644 (file)
@@ -252,7 +252,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
        int num = 0;
 
        if (unlikely(gfs2_withdrawn(sdp)) &&
-           (!sdp->sd_jdesc || (blkno != sdp->sd_jdesc->jd_no_addr))) {
+           (!sdp->sd_jdesc || gl != sdp->sd_jinode_gl)) {
                *bhp = NULL;
                return -EIO;
        }
index cc0c4b5..8259fef 100644 (file)
@@ -1051,8 +1051,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
        u32 x;
        int error = 0;
 
-       if (capable(CAP_SYS_RESOURCE) ||
-           sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
+       if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
                return 0;
 
        error = gfs2_quota_hold(ip, uid, gid);
@@ -1125,7 +1124,7 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
        int found;
 
        if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags))
-               goto out;
+               return;
 
        for (x = 0; x < ip->i_qadata->qa_qd_num; x++) {
                struct gfs2_quota_data *qd;
@@ -1162,7 +1161,6 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
                        qd_unlock(qda[x]);
        }
 
-out:
        gfs2_quota_unhold(ip);
 }
 
@@ -1210,9 +1208,6 @@ int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,
        if (!test_bit(GIF_QD_LOCKED, &ip->i_flags))
                return 0;
 
-        if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
-                return 0;
-
        for (x = 0; x < ip->i_qadata->qa_qd_num; x++) {
                qd = ip->i_qadata->qa_qd[x];
 
@@ -1270,7 +1265,9 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
        if (ip->i_diskflags & GFS2_DIF_SYSTEM)
                return;
 
-       BUG_ON(ip->i_qadata->qa_ref <= 0);
+       if (gfs2_assert_withdraw(sdp, ip->i_qadata &&
+                                ip->i_qadata->qa_ref > 0))
+               return;
        for (x = 0; x < ip->i_qadata->qa_qd_num; x++) {
                qd = ip->i_qadata->qa_qd[x];
 
index 7f9ca8e..21ada33 100644 (file)
@@ -44,7 +44,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,
        int ret;
 
        ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */
-       if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
+       if (capable(CAP_SYS_RESOURCE) ||
+           sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
                return 0;
        ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
        if (ret)
index 37fc416..956fced 100644 (file)
@@ -1404,7 +1404,6 @@ out:
        if (ip->i_qadata)
                gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
        gfs2_rs_delete(ip, NULL);
-       gfs2_qa_put(ip);
        gfs2_ordered_del_inode(ip);
        clear_inode(inode);
        gfs2_dir_hash_inval(ip);
index 9b64d40..aa087a5 100644 (file)
@@ -119,6 +119,12 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp)
        if (!sb_rdonly(sdp->sd_vfs))
                ret = gfs2_make_fs_ro(sdp);
 
+       if (sdp->sd_lockstruct.ls_ops->lm_lock == NULL) { /* lock_nolock */
+               if (!ret)
+                       ret = -EIO;
+               clear_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags);
+               goto skip_recovery;
+       }
        /*
         * Drop the glock for our journal so another node can recover it.
         */
@@ -159,10 +165,6 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp)
                wait_on_bit(&gl->gl_flags, GLF_FREEING, TASK_UNINTERRUPTIBLE);
        }
 
-       if (sdp->sd_lockstruct.ls_ops->lm_lock == NULL) { /* lock_nolock */
-               clear_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags);
-               goto skip_recovery;
-       }
        /*
         * Dequeue the "live" glock, but keep a reference so it's never freed.
         */
index 979d9f9..bb25e39 100644 (file)
@@ -619,6 +619,8 @@ struct io_kiocb {
        bool                            needs_fixed_file;
        u8                              opcode;
 
+       u16                             buf_index;
+
        struct io_ring_ctx      *ctx;
        struct list_head        list;
        unsigned int            flags;
@@ -924,6 +926,7 @@ static struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
                goto err;
 
        ctx->flags = p->flags;
+       init_waitqueue_head(&ctx->sqo_wait);
        init_waitqueue_head(&ctx->cq_wait);
        INIT_LIST_HEAD(&ctx->cq_overflow_list);
        init_completion(&ctx->completions[0]);
@@ -1394,10 +1397,6 @@ static void io_free_req_many(struct io_ring_ctx *ctx, struct req_batch *rb)
                for (i = 0; i < rb->to_free; i++) {
                        struct io_kiocb *req = rb->reqs[i];
 
-                       if (req->flags & REQ_F_FIXED_FILE) {
-                               req->file = NULL;
-                               percpu_ref_put(req->fixed_file_refs);
-                       }
                        if (req->flags & REQ_F_INFLIGHT)
                                inflight++;
                        __io_req_aux_free(req);
@@ -1670,7 +1669,7 @@ static inline bool io_req_multi_free(struct req_batch *rb, struct io_kiocb *req)
        if ((req->flags & REQ_F_LINK_HEAD) || io_is_fallback_req(req))
                return false;
 
-       if (!(req->flags & REQ_F_FIXED_FILE) || req->io)
+       if (req->file || req->io)
                rb->need_iter++;
 
        rb->reqs[rb->to_free++] = req;
@@ -2104,9 +2103,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 
        req->rw.addr = READ_ONCE(sqe->addr);
        req->rw.len = READ_ONCE(sqe->len);
-       /* we own ->private, reuse it for the buffer index  / buffer ID */
-       req->rw.kiocb.private = (void *) (unsigned long)
-                                       READ_ONCE(sqe->buf_index);
+       req->buf_index = READ_ONCE(sqe->buf_index);
        return 0;
 }
 
@@ -2149,7 +2146,7 @@ static ssize_t io_import_fixed(struct io_kiocb *req, int rw,
        struct io_ring_ctx *ctx = req->ctx;
        size_t len = req->rw.len;
        struct io_mapped_ubuf *imu;
-       unsigned index, buf_index;
+       u16 index, buf_index;
        size_t offset;
        u64 buf_addr;
 
@@ -2157,7 +2154,7 @@ static ssize_t io_import_fixed(struct io_kiocb *req, int rw,
        if (unlikely(!ctx->user_bufs))
                return -EFAULT;
 
-       buf_index = (unsigned long) req->rw.kiocb.private;
+       buf_index = req->buf_index;
        if (unlikely(buf_index >= ctx->nr_user_bufs))
                return -EFAULT;
 
@@ -2273,10 +2270,10 @@ static void __user *io_rw_buffer_select(struct io_kiocb *req, size_t *len,
                                        bool needs_lock)
 {
        struct io_buffer *kbuf;
-       int bgid;
+       u16 bgid;
 
        kbuf = (struct io_buffer *) (unsigned long) req->rw.addr;
-       bgid = (int) (unsigned long) req->rw.kiocb.private;
+       bgid = req->buf_index;
        kbuf = io_buffer_select(req, len, bgid, kbuf, needs_lock);
        if (IS_ERR(kbuf))
                return kbuf;
@@ -2367,7 +2364,7 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
        }
 
        /* buffer index only valid with fixed read/write, or buffer select  */
-       if (req->rw.kiocb.private && !(req->flags & REQ_F_BUFFER_SELECT))
+       if (req->buf_index && !(req->flags & REQ_F_BUFFER_SELECT))
                return -EINVAL;
 
        if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
@@ -2767,16 +2764,16 @@ static int io_splice(struct io_kiocb *req, bool force_nonblock)
        struct file *out = sp->file_out;
        unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
        loff_t *poff_in, *poff_out;
-       long ret;
+       long ret = 0;
 
        if (force_nonblock)
                return -EAGAIN;
 
        poff_in = (sp->off_in == -1) ? NULL : &sp->off_in;
        poff_out = (sp->off_out == -1) ? NULL : &sp->off_out;
-       ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
-       if (force_nonblock && ret == -EAGAIN)
-               return -EAGAIN;
+
+       if (sp->len)
+               ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
 
        io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED));
        req->flags &= ~REQ_F_NEED_CLEANUP;
@@ -4138,12 +4135,14 @@ static int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll,
        req->result = mask;
        init_task_work(&req->task_work, func);
        /*
-        * If this fails, then the task is exiting. Punt to one of the io-wq
-        * threads to ensure the work gets run, we can't always rely on exit
-        * cancelation taking care of this.
+        * If this fails, then the task is exiting. When a task exits, the
+        * work gets canceled, so just cancel this request as well instead
+        * of executing it. We can't safely execute it anyway, as we may not
+        * have the needed state needed for it anyway.
         */
        ret = task_work_add(tsk, &req->task_work, true);
        if (unlikely(ret)) {
+               WRITE_ONCE(poll->canceled, true);
                tsk = io_wq_get_task(req->ctx->io_wq);
                task_work_add(tsk, &req->task_work, true);
        }
@@ -5014,12 +5013,13 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
        if (!req_need_defer(req) && list_empty_careful(&ctx->defer_list))
                return 0;
 
-       if (!req->io && io_alloc_async_ctx(req))
-               return -EAGAIN;
-
-       ret = io_req_defer_prep(req, sqe);
-       if (ret < 0)
-               return ret;
+       if (!req->io) {
+               if (io_alloc_async_ctx(req))
+                       return -EAGAIN;
+               ret = io_req_defer_prep(req, sqe);
+               if (ret < 0)
+                       return ret;
+       }
 
        spin_lock_irq(&ctx->completion_lock);
        if (!req_need_defer(req) && list_empty(&ctx->defer_list)) {
@@ -5306,7 +5306,8 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
        if (ret)
                return ret;
 
-       if (ctx->flags & IORING_SETUP_IOPOLL) {
+       /* If the op doesn't have a file, we're not polling for it */
+       if ((ctx->flags & IORING_SETUP_IOPOLL) && req->file) {
                const bool in_async = io_wq_current_is_worker();
 
                if (req->result == -EAGAIN)
@@ -5607,9 +5608,15 @@ fail_req:
                        io_double_put_req(req);
                }
        } else if (req->flags & REQ_F_FORCE_ASYNC) {
-               ret = io_req_defer_prep(req, sqe);
-               if (unlikely(ret < 0))
-                       goto fail_req;
+               if (!req->io) {
+                       ret = -EAGAIN;
+                       if (io_alloc_async_ctx(req))
+                               goto fail_req;
+                       ret = io_req_defer_prep(req, sqe);
+                       if (unlikely(ret < 0))
+                               goto fail_req;
+               }
+
                /*
                 * Never try inline submit of IOSQE_ASYNC is set, go straight
                 * to async execution.
@@ -6025,6 +6032,7 @@ static int io_sq_thread(void *data)
                                finish_wait(&ctx->sqo_wait, &wait);
 
                                ctx->rings->sq_flags &= ~IORING_SQ_NEED_WAKEUP;
+                               ret = 0;
                                continue;
                        }
                        finish_wait(&ctx->sqo_wait, &wait);
@@ -6838,7 +6846,6 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
 {
        int ret;
 
-       init_waitqueue_head(&ctx->sqo_wait);
        mmgrab(current->mm);
        ctx->sqo_mm = current->mm;
 
index 1abf126..a60df88 100644 (file)
@@ -118,8 +118,6 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int
 
        nfss->fscache_key = NULL;
        nfss->fscache = NULL;
-       if (!(nfss->options & NFS_OPTION_FSCACHE))
-               return;
        if (!uniq) {
                uniq = "";
                ulen = 1;
@@ -188,7 +186,8 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int
        /* create a cache index for looking up filehandles */
        nfss->fscache = fscache_acquire_cookie(nfss->nfs_client->fscache,
                                               &nfs_fscache_super_index_def,
-                                              key, sizeof(*key) + ulen,
+                                              &key->key,
+                                              sizeof(key->key) + ulen,
                                               NULL, 0,
                                               nfss, 0, true);
        dfprintk(FSCACHE, "NFS: get superblock cookie (0x%p/0x%p)\n",
@@ -226,6 +225,19 @@ void nfs_fscache_release_super_cookie(struct super_block *sb)
        }
 }
 
+static void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata,
+                                 struct nfs_inode *nfsi)
+{
+       memset(auxdata, 0, sizeof(*auxdata));
+       auxdata->mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
+       auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
+       auxdata->ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
+       auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
+
+       if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
+               auxdata->change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
+}
+
 /*
  * Initialise the per-inode cache cookie pointer for an NFS inode.
  */
@@ -239,14 +251,7 @@ void nfs_fscache_init_inode(struct inode *inode)
        if (!(nfss->fscache && S_ISREG(inode->i_mode)))
                return;
 
-       memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
-       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
-       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
-       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
-
-       if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
-               auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
+       nfs_fscache_update_auxdata(&auxdata, nfsi);
 
        nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache,
                                               &nfs_fscache_inode_object_def,
@@ -266,11 +271,7 @@ void nfs_fscache_clear_inode(struct inode *inode)
 
        dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
 
-       memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
-       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
-       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
-       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
+       nfs_fscache_update_auxdata(&auxdata, nfsi);
        fscache_relinquish_cookie(cookie, &auxdata, false);
        nfsi->fscache = NULL;
 }
@@ -310,11 +311,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
        if (!fscache_cookie_valid(cookie))
                return;
 
-       memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
-       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
-       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
-       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
+       nfs_fscache_update_auxdata(&auxdata, nfsi);
 
        if (inode_is_open_for_write(inode)) {
                dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
index 35c8cb2..dda5c3e 100644 (file)
@@ -30,6 +30,7 @@
 #define encode_dirpath_sz      (1 + XDR_QUADLEN(MNTPATHLEN))
 #define MNT_status_sz          (1)
 #define MNT_fhandle_sz         XDR_QUADLEN(NFS2_FHSIZE)
+#define MNT_fhandlev3_sz       XDR_QUADLEN(NFS3_FHSIZE)
 #define MNT_authflav3_sz       (1 + NFS_MAX_SECFLAVORS)
 
 /*
@@ -37,7 +38,7 @@
  */
 #define MNT_enc_dirpath_sz     encode_dirpath_sz
 #define MNT_dec_mountres_sz    (MNT_status_sz + MNT_fhandle_sz)
-#define MNT_dec_mountres3_sz   (MNT_status_sz + MNT_fhandle_sz + \
+#define MNT_dec_mountres3_sz   (MNT_status_sz + MNT_fhandlev3_sz + \
                                 MNT_authflav3_sz)
 
 /*
index a0c1e65..9056f3d 100644 (file)
@@ -6347,7 +6347,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred,
                .rpc_client = server->client,
                .rpc_message = &msg,
                .callback_ops = &nfs4_delegreturn_ops,
-               .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF | RPC_TASK_TIMEOUT,
+               .flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT,
        };
        int status = 0;
 
index ac93715..a8dc25c 100644 (file)
@@ -734,9 +734,9 @@ nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
                state = new;
                state->owner = owner;
                atomic_inc(&owner->so_count);
-               list_add_rcu(&state->inode_states, &nfsi->open_states);
                ihold(inode);
                state->inode = inode;
+               list_add_rcu(&state->inode_states, &nfsi->open_states);
                spin_unlock(&inode->i_lock);
                /* Note: The reclaim code dictates that we add stateless
                 * and read-only stateids to the end of the list */
index f61f966..6ca421c 100644 (file)
@@ -752,7 +752,7 @@ int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr,
                .callback_ops = call_ops,
                .callback_data = hdr,
                .workqueue = nfsiod_workqueue,
-               .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF | flags,
+               .flags = RPC_TASK_ASYNC | flags,
        };
 
        hdr->rw_ops->rw_initiate(hdr, &msg, rpc_ops, &task_setup_data, how);
@@ -950,7 +950,8 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc)
                                        hdr->cred,
                                        NFS_PROTO(hdr->inode),
                                        desc->pg_rpc_callops,
-                                       desc->pg_ioflags, 0);
+                                       desc->pg_ioflags,
+                                       RPC_TASK_CRED_NOREF);
        return ret;
 }
 
index e7ddbce..679767a 100644 (file)
@@ -536,7 +536,8 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
                        nfs_init_commit(data, NULL, NULL, cinfo);
                        nfs_initiate_commit(NFS_CLIENT(inode), data,
                                            NFS_PROTO(data->inode),
-                                           data->mds_ops, how, 0);
+                                           data->mds_ops, how,
+                                           RPC_TASK_CRED_NOREF);
                } else {
                        nfs_init_commit(data, NULL, data->lseg, cinfo);
                        initiate_commit(data, how);
index bdb6d0c..7a70287 100644 (file)
@@ -1189,7 +1189,6 @@ static void nfs_get_cache_cookie(struct super_block *sb,
                        uniq = ctx->fscache_uniq;
                        ulen = strlen(ctx->fscache_uniq);
                }
-               return;
        }
 
        nfs_fscache_get_super_cookie(sb, uniq, ulen);
index df4b87c..1e767f7 100644 (file)
@@ -1695,7 +1695,7 @@ int nfs_initiate_commit(struct rpc_clnt *clnt, struct nfs_commit_data *data,
                .callback_ops = call_ops,
                .callback_data = data,
                .workqueue = nfsiod_workqueue,
-               .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF | flags,
+               .flags = RPC_TASK_ASYNC | flags,
                .priority = priority,
        };
        /* Set up the initial task struct.  */
@@ -1813,7 +1813,7 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
        nfs_init_commit(data, head, NULL, cinfo);
        atomic_inc(&cinfo->mds->rpcs_out);
        return nfs_initiate_commit(NFS_CLIENT(inode), data, NFS_PROTO(inode),
-                                  data->mds_ops, how, 0);
+                                  data->mds_ops, how, RPC_TASK_CRED_NOREF);
 }
 
 /*
index 475c61f..ed5c107 100644 (file)
@@ -783,6 +783,9 @@ static struct ovl_fh *ovl_fid_to_fh(struct fid *fid, int buflen, int fh_type)
        if (fh_type != OVL_FILEID_V0)
                return ERR_PTR(-EINVAL);
 
+       if (buflen <= OVL_FH_WIRE_OFFSET)
+               return ERR_PTR(-EINVAL);
+
        fh = kzalloc(buflen, GFP_KERNEL);
        if (!fh)
                return ERR_PTR(-ENOMEM);
index b0d42ec..981f11e 100644 (file)
@@ -58,6 +58,24 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
                if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
                        attr->ia_valid &= ~ATTR_MODE;
 
+               /*
+                * We might have to translate ovl file into real file object
+                * once use cases emerge.  For now, simply don't let underlying
+                * filesystem rely on attr->ia_file
+                */
+               attr->ia_valid &= ~ATTR_FILE;
+
+               /*
+                * If open(O_TRUNC) is done, VFS calls ->setattr with ATTR_OPEN
+                * set.  Overlayfs does not pass O_TRUNC flag to underlying
+                * filesystem during open -> do not pass ATTR_OPEN.  This
+                * disables optimization in fuse which assumes open(O_TRUNC)
+                * already set file size to 0.  But we never passed O_TRUNC to
+                * fuse.  So by clearing ATTR_OPEN, fuse will be forced to send
+                * setattr request to server.
+                */
+               attr->ia_valid &= ~ATTR_OPEN;
+
                inode_lock(upperdentry->d_inode);
                old_cred = ovl_override_creds(dentry->d_sb);
                err = notify_change(upperdentry, attr, NULL);
index fd0a1e7..4e53efb 100644 (file)
@@ -1494,7 +1494,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
         * Check pipe occupancy without the inode lock first. This function
         * is speculative anyways, so missing one is ok.
         */
-       if (pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+       if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage))
                return 0;
 
        ret = 0;
index 8cdbd53..f985a3f 100644 (file)
@@ -79,13 +79,9 @@ int ubifs_prepare_auth_node(struct ubifs_info *c, void *node,
                             struct shash_desc *inhash)
 {
        struct ubifs_auth_node *auth = node;
-       u8 *hash;
+       u8 hash[UBIFS_HASH_ARR_SZ];
        int err;
 
-       hash = kmalloc(crypto_shash_descsize(c->hash_tfm), GFP_NOFS);
-       if (!hash)
-               return -ENOMEM;
-
        {
                SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm);
 
@@ -94,21 +90,16 @@ int ubifs_prepare_auth_node(struct ubifs_info *c, void *node,
 
                err = crypto_shash_final(hash_desc, hash);
                if (err)
-                       goto out;
+                       return err;
        }
 
        err = ubifs_hash_calc_hmac(c, hash, auth->hmac);
        if (err)
-               goto out;
+               return err;
 
        auth->ch.node_type = UBIFS_AUTH_NODE;
        ubifs_prepare_node(c, auth, ubifs_auth_node_sz(c), 0);
-
-       err = 0;
-out:
-       kfree(hash);
-
-       return err;
+       return 0;
 }
 
 static struct shash_desc *ubifs_get_desc(const struct ubifs_info *c,
index 743928e..49fe062 100644 (file)
@@ -1375,7 +1375,6 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
        struct ubifs_info *c = inode->i_sb->s_fs_info;
        struct ubifs_budget_req req = { .dirtied_ino = 1,
                        .dirtied_ino_d = ALIGN(ui->data_len, 8) };
-       int iflags = I_DIRTY_TIME;
        int err, release;
 
        if (!IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))
@@ -1393,11 +1392,8 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
        if (flags & S_MTIME)
                inode->i_mtime = *time;
 
-       if (!(inode->i_sb->s_flags & SB_LAZYTIME))
-               iflags |= I_DIRTY_SYNC;
-
        release = ui->dirty;
-       __mark_inode_dirty(inode, iflags);
+       __mark_inode_dirty(inode, I_DIRTY_SYNC);
        mutex_unlock(&ui->ui_mutex);
        if (release)
                ubifs_release_budget(c, &req);
index b28ac4d..01fcf79 100644 (file)
@@ -601,18 +601,12 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
        struct ubifs_scan_node *snod;
        int n_nodes = 0;
        int err;
-       u8 *hash, *hmac;
+       u8 hash[UBIFS_HASH_ARR_SZ];
+       u8 hmac[UBIFS_HMAC_ARR_SZ];
 
        if (!ubifs_authenticated(c))
                return sleb->nodes_cnt;
 
-       hash = kmalloc(crypto_shash_descsize(c->hash_tfm), GFP_NOFS);
-       hmac = kmalloc(c->hmac_desc_len, GFP_NOFS);
-       if (!hash || !hmac) {
-               err = -ENOMEM;
-               goto out;
-       }
-
        list_for_each_entry(snod, &sleb->nodes, list) {
 
                n_nodes++;
@@ -662,9 +656,6 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
                err = 0;
        }
 out:
-       kfree(hash);
-       kfree(hmac);
-
        return err ? err : n_nodes - n_not_auth;
 }
 
index 99134d4..320f811 100644 (file)
@@ -48,7 +48,7 @@ struct videomode;
  * @MODE_HSYNC: hsync out of range
  * @MODE_VSYNC: vsync out of range
  * @MODE_H_ILLEGAL: mode has illegal horizontal timings
- * @MODE_V_ILLEGAL: mode has illegal horizontal timings
+ * @MODE_V_ILLEGAL: mode has illegal vertical timings
  * @MODE_BAD_WIDTH: requires an unsupported linepitch
  * @MODE_NOMODE: no mode with a matching name
  * @MODE_NO_INTERLACE: interlaced mode not supported
index 6462c54..f4b7701 100644 (file)
 #define BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN        (1 << 0)
 #define BCM54810_SHD_CLK_CTL                   0x3
 #define BCM54810_SHD_CLK_CTL_GTXCLK_EN         (1 << 9)
+#define BCM54810_SHD_SCR3_TRDDAPD              0x0100
 
 /* BCM54612E Registers */
 #define BCM54612E_EXP_SPARE0           (MII_BCM54XX_EXP_SEL_ETC + 0x34)
index 034b0a6..448c91b 100644 (file)
@@ -356,4 +356,10 @@ static inline void *offset_to_ptr(const int *off)
 /* &a[0] degrades to a pointer: a different type from an array */
 #define __must_be_array(a)     BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 
+/*
+ * This is needed in functions which generate the stack canary, see
+ * arch/x86/kernel/smpboot.c::start_secondary() for an example.
+ */
+#define prevent_tail_call_optimization()       mb()
+
 #endif /* __LINUX_COMPILER_H */
index db95244..ab4bd15 100644 (file)
@@ -210,6 +210,29 @@ struct ftrace_ops {
 #endif
 };
 
+extern struct ftrace_ops __rcu *ftrace_ops_list;
+extern struct ftrace_ops ftrace_list_end;
+
+/*
+ * Traverse the ftrace_global_list, invoking all entries.  The reason that we
+ * can use rcu_dereference_raw_check() is that elements removed from this list
+ * are simply leaked, so there is no need to interact with a grace-period
+ * mechanism.  The rcu_dereference_raw_check() calls are needed to handle
+ * concurrent insertions into the ftrace_global_list.
+ *
+ * Silly Alpha and silly pointer-speculation compiler optimizations!
+ */
+#define do_for_each_ftrace_op(op, list)                        \
+       op = rcu_dereference_raw_check(list);                   \
+       do
+
+/*
+ * Optimized for just a single item in the list (as that is the normal case).
+ */
+#define while_for_each_ftrace_op(op)                           \
+       while (likely(op = rcu_dereference_raw_check((op)->next)) &&    \
+              unlikely((op) != &ftrace_list_end))
+
 /*
  * Type of the current tracing.
  */
index 62d216f..c230b4e 100644 (file)
@@ -17,9 +17,12 @@ enum host1x_class {
        HOST1X_CLASS_GR3D = 0x60,
 };
 
+struct host1x;
 struct host1x_client;
 struct iommu_group;
 
+u64 host1x_get_dma_mask(struct host1x *host1x);
+
 /**
  * struct host1x_client_ops - host1x client operations
  * @init: host1x client initialization code
index c5a9773..98ef73b 100644 (file)
@@ -29,7 +29,7 @@ struct i2c_mux_core {
 
        int num_adapters;
        int max_adapters;
-       struct i2c_adapter *adapter[0];
+       struct i2c_adapter *adapter[];
 };
 
 struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
index 45d36ba..49d2905 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * i2c.h - definitions for the Linux i2c bus interface
  * Copyright (C) 1995-2000 Simon G. Vogl
- * Copyright (C) 2013-2019 Wolfram Sang <wsa@the-dreams.de>
+ * Copyright (C) 2013-2019 Wolfram Sang <wsa@kernel.org>
  *
  * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
  * Frodo Looijaard <frodol@dds.nl>
index 01276e3..131cc15 100644 (file)
@@ -813,8 +813,11 @@ void kvm_flush_remote_tlbs(struct kvm *kvm);
 void kvm_reload_remote_mmus(struct kvm *kvm);
 
 bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
+                                struct kvm_vcpu *except,
                                 unsigned long *vcpu_bitmap, cpumask_var_t tmp);
 bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
+bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
+                                     struct kvm_vcpu *except);
 bool kvm_make_cpus_request_mask(struct kvm *kvm, unsigned int req,
                                unsigned long *vcpu_bitmap);
 
index 1bdd027..5616b25 100644 (file)
@@ -243,7 +243,7 @@ LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, char *name,
         char **value)
 LSM_HOOK(int, -EINVAL, setprocattr, const char *name, void *value, size_t size)
 LSM_HOOK(int, 0, ismaclabel, const char *name)
-LSM_HOOK(int, 0, secid_to_secctx, u32 secid, char **secdata,
+LSM_HOOK(int, -EOPNOTSUPP, secid_to_secctx, u32 secid, char **secdata,
         u32 *seclen)
 LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
 LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen)
index d275c72..977edd3 100644 (file)
@@ -783,6 +783,8 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg,
                atomic_long_inc(&memcg->memory_events[event]);
                cgroup_file_notify(&memcg->events_file);
 
+               if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
+                       break;
                if (cgrp_dfl_root.flags & CGRP_ROOT_MEMORY_LOCAL_EVENTS)
                        break;
        } while ((memcg = parent_mem_cgroup(memcg)) &&
index 121a7ed..c602670 100644 (file)
@@ -105,10 +105,10 @@ struct ptp_system_timestamp {
  *            parameter func: the desired function to use.
  *            parameter chan: the function channel index to use.
  *
- * @do_work:  Request driver to perform auxiliary (periodic) operations
- *           Driver should return delay of the next auxiliary work scheduling
- *           time (>=0) or negative value in case further scheduling
- *           is not required.
+ * @do_aux_work:  Request driver to perform auxiliary (periodic) operations
+ *                Driver should return delay of the next auxiliary work
+ *                scheduling time (>=0) or negative value in case further
+ *                scheduling is not required.
  *
  * Drivers should embed their ptp_clock_info within a private
  * structure, obtaining a reference to it using container_of().
index 8a709f6..ad31c9f 100644 (file)
@@ -187,6 +187,7 @@ static inline void sk_msg_xfer(struct sk_msg *dst, struct sk_msg *src,
        dst->sg.data[which] = src->sg.data[which];
        dst->sg.data[which].length  = size;
        dst->sg.size               += size;
+       src->sg.size               -= size;
        src->sg.data[which].length -= size;
        src->sg.data[which].offset += size;
 }
index 48c1b16..bc07e51 100644 (file)
@@ -21,6 +21,7 @@
 struct gss_ctx {
        struct gss_api_mech     *mech_type;
        void                    *internal_ctx_id;
+       unsigned int            slack, align;
 };
 
 #define GSS_C_NO_BUFFER                ((struct xdr_netobj) 0)
@@ -66,6 +67,7 @@ u32 gss_wrap(
 u32 gss_unwrap(
                struct gss_ctx          *ctx_id,
                int                     offset,
+               int                     len,
                struct xdr_buf          *inbuf);
 u32 gss_delete_sec_context(
                struct gss_ctx          **ctx_id);
@@ -126,6 +128,7 @@ struct gss_api_ops {
        u32 (*gss_unwrap)(
                        struct gss_ctx          *ctx_id,
                        int                     offset,
+                       int                     len,
                        struct xdr_buf          *buf);
        void (*gss_delete_sec_context)(
                        void                    *internal_ctx_id);
index c1d77dd..e8f8ffe 100644 (file)
@@ -83,7 +83,7 @@ struct gss_krb5_enctype {
        u32 (*encrypt_v2) (struct krb5_ctx *kctx, u32 offset,
                           struct xdr_buf *buf,
                           struct page **pages); /* v2 encryption function */
-       u32 (*decrypt_v2) (struct krb5_ctx *kctx, u32 offset,
+       u32 (*decrypt_v2) (struct krb5_ctx *kctx, u32 offset, u32 len,
                           struct xdr_buf *buf, u32 *headskip,
                           u32 *tailskip);      /* v2 decryption function */
 };
@@ -255,7 +255,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx_id, int offset,
                struct xdr_buf *outbuf, struct page **pages);
 
 u32
-gss_unwrap_kerberos(struct gss_ctx *ctx_id, int offset,
+gss_unwrap_kerberos(struct gss_ctx *ctx_id, int offset, int len,
                struct xdr_buf *buf);
 
 
@@ -312,7 +312,7 @@ gss_krb5_aes_encrypt(struct krb5_ctx *kctx, u32 offset,
                     struct page **pages);
 
 u32
-gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset,
+gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len,
                     struct xdr_buf *buf, u32 *plainoffset,
                     u32 *plainlen);
 
index 01bb419..22c207b 100644 (file)
@@ -184,6 +184,7 @@ xdr_adjust_iovec(struct kvec *iov, __be32 *p)
 extern void xdr_shift_buf(struct xdr_buf *, size_t);
 extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *);
 extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int);
+extern void xdr_buf_trim(struct xdr_buf *, unsigned int);
 extern int read_bytes_from_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int);
 extern int write_bytes_to_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int);
 
index 9f551f3..90690e3 100644 (file)
@@ -87,7 +87,7 @@ struct nf_conn {
        struct hlist_node       nat_bysource;
 #endif
        /* all members below initialized via memset */
-       u8 __nfct_init_offset[0];
+       struct { } __nfct_init_offset;
 
        /* If we were expected by an expectation, this will be it */
        struct nf_conn *master;
index 6bf6965..c54a7f7 100644 (file)
@@ -127,6 +127,7 @@ enum nf_flow_flags {
        NF_FLOW_HW_DYING,
        NF_FLOW_HW_DEAD,
        NF_FLOW_HW_REFRESH,
+       NF_FLOW_HW_PENDING,
 };
 
 enum flow_offload_type {
index dcf9a72..6f8e60c 100644 (file)
@@ -1376,7 +1376,6 @@ static inline void tcp_sack_reset(struct tcp_options_received *rx_opt)
        rx_opt->num_sacks = 0;
 }
 
-u32 tcp_default_init_rwnd(u32 mss);
 void tcp_cwnd_restart(struct sock *sk, s32 delta);
 
 static inline void tcp_slow_start_after_idle_check(struct sock *sk)
@@ -1421,6 +1420,19 @@ static inline int tcp_full_space(const struct sock *sk)
        return tcp_win_from_space(sk, READ_ONCE(sk->sk_rcvbuf));
 }
 
+/* We provision sk_rcvbuf around 200% of sk_rcvlowat.
+ * If 87.5 % (7/8) of the space has been consumed, we want to override
+ * SO_RCVLOWAT constraint, since we are receiving skbs with too small
+ * len/truesize ratio.
+ */
+static inline bool tcp_rmem_pressure(const struct sock *sk)
+{
+       int rcvbuf = READ_ONCE(sk->sk_rcvbuf);
+       int threshold = rcvbuf - (rcvbuf >> 3);
+
+       return atomic_read(&sk->sk_rmem_alloc) > threshold;
+}
+
 extern void tcp_openreq_init_rwin(struct request_sock *req,
                                  const struct sock *sk_listener,
                                  const struct dst_entry *dst);
index 4b1f95e..e7312ce 100644 (file)
@@ -143,14 +143,12 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb
                         __be16 df, __be16 src_port, __be16 dst_port,
                         bool xnet, bool nocheck);
 
-#if IS_ENABLED(CONFIG_IPV6)
 int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
                         struct sk_buff *skb,
                         struct net_device *dev, struct in6_addr *saddr,
                         struct in6_addr *daddr,
                         __u8 prio, __u8 ttl, __be32 label,
                         __be16 src_port, __be16 dst_port, bool nocheck);
-#endif
 
 void udp_tunnel_sock_release(struct socket *sock);
 
index a36b722..334842d 100644 (file)
@@ -61,6 +61,7 @@ struct snd_rawmidi_runtime {
        size_t avail_min;       /* min avail for wakeup */
        size_t avail;           /* max used buffer for wakeup */
        size_t xruns;           /* over/underruns counter */
+       int buffer_ref;         /* buffer reference count */
        /* misc */
        spinlock_t lock;
        wait_queue_head_t sleep;
index ea37508..0be6852 100644 (file)
@@ -93,6 +93,64 @@ struct usb_raw_ep_io {
        __u8            data[0];
 };
 
+/* Maximum number of non-control endpoints in struct usb_raw_eps_info. */
+#define USB_RAW_EPS_NUM_MAX    30
+
+/* Maximum length of UDC endpoint name in struct usb_raw_ep_info. */
+#define USB_RAW_EP_NAME_MAX    16
+
+/* Used as addr in struct usb_raw_ep_info if endpoint accepts any address. */
+#define USB_RAW_EP_ADDR_ANY    0xff
+
+/*
+ * struct usb_raw_ep_caps - exposes endpoint capabilities from struct usb_ep
+ *     (technically from its member struct usb_ep_caps).
+ */
+struct usb_raw_ep_caps {
+       __u32   type_control    : 1;
+       __u32   type_iso        : 1;
+       __u32   type_bulk       : 1;
+       __u32   type_int        : 1;
+       __u32   dir_in          : 1;
+       __u32   dir_out         : 1;
+};
+
+/*
+ * struct usb_raw_ep_limits - exposes endpoint limits from struct usb_ep.
+ * @maxpacket_limit: Maximum packet size value supported by this endpoint.
+ * @max_streams: maximum number of streams supported by this endpoint
+ *     (actual number is 2^n).
+ * @reserved: Empty, reserved for potential future extensions.
+ */
+struct usb_raw_ep_limits {
+       __u16   maxpacket_limit;
+       __u16   max_streams;
+       __u32   reserved;
+};
+
+/*
+ * struct usb_raw_ep_info - stores information about a gadget endpoint.
+ * @name: Name of the endpoint as it is defined in the UDC driver.
+ * @addr: Address of the endpoint that must be specified in the endpoint
+ *     descriptor passed to USB_RAW_IOCTL_EP_ENABLE ioctl.
+ * @caps: Endpoint capabilities.
+ * @limits: Endpoint limits.
+ */
+struct usb_raw_ep_info {
+       __u8                            name[USB_RAW_EP_NAME_MAX];
+       __u32                           addr;
+       struct usb_raw_ep_caps          caps;
+       struct usb_raw_ep_limits        limits;
+};
+
+/*
+ * struct usb_raw_eps_info - argument for USB_RAW_IOCTL_EPS_INFO ioctl.
+ * eps: Structures that store information about non-control endpoints.
+ */
+struct usb_raw_eps_info {
+       struct usb_raw_ep_info  eps[USB_RAW_EPS_NUM_MAX];
+};
+
 /*
  * Initializes a Raw Gadget instance.
  * Accepts a pointer to the usb_raw_init struct as an argument.
@@ -115,37 +173,38 @@ struct usb_raw_ep_io {
 #define USB_RAW_IOCTL_EVENT_FETCH      _IOR('U', 2, struct usb_raw_event)
 
 /*
- * Queues an IN (OUT for READ) urb as a response to the last control request
- * received on endpoint 0, provided that was an IN (OUT for READ) request and
- * waits until the urb is completed. Copies received data to user for READ.
+ * Queues an IN (OUT for READ) request as a response to the last setup request
+ * received on endpoint 0 (provided that was an IN (OUT for READ) request), and
+ * waits until the request is completed. Copies received data to user for READ.
  * Accepts a pointer to the usb_raw_ep_io struct as an argument.
- * Returns length of trasferred data on success or negative error code on
+ * Returns length of transferred data on success or negative error code on
  * failure.
  */
 #define USB_RAW_IOCTL_EP0_WRITE                _IOW('U', 3, struct usb_raw_ep_io)
 #define USB_RAW_IOCTL_EP0_READ         _IOWR('U', 4, struct usb_raw_ep_io)
 
 /*
- * Finds an endpoint that supports the transfer type specified in the
- * descriptor and enables it.
- * Accepts a pointer to the usb_endpoint_descriptor struct as an argument.
+ * Finds an endpoint that satisfies the parameters specified in the provided
+ * descriptors (address, transfer type, etc.) and enables it.
+ * Accepts a pointer to the usb_raw_ep_descs struct as an argument.
  * Returns enabled endpoint handle on success or negative error code on failure.
  */
 #define USB_RAW_IOCTL_EP_ENABLE                _IOW('U', 5, struct usb_endpoint_descriptor)
 
-/* Disables specified endpoint.
+/*
+ * Disables specified endpoint.
  * Accepts endpoint handle as an argument.
  * Returns 0 on success or negative error code on failure.
  */
 #define USB_RAW_IOCTL_EP_DISABLE       _IOW('U', 6, __u32)
 
 /*
- * Queues an IN (OUT for READ) urb as a response to the last control request
- * received on endpoint usb_raw_ep_io.epprovided that was an IN (OUT for READ)
- * request and waits until the urb is completed. Copies received data to user
- * for READ.
+ * Queues an IN (OUT for READ) request as a response to the last setup request
+ * received on endpoint usb_raw_ep_io.ep (provided that was an IN (OUT for READ)
+ * request), and waits until the request is completed. Copies received data to
+ * user for READ.
  * Accepts a pointer to the usb_raw_ep_io struct as an argument.
- * Returns length of trasferred data on success or negative error code on
+ * Returns length of transferred data on success or negative error code on
  * failure.
  */
 #define USB_RAW_IOCTL_EP_WRITE         _IOW('U', 7, struct usb_raw_ep_io)
@@ -164,4 +223,27 @@ struct usb_raw_ep_io {
  */
 #define USB_RAW_IOCTL_VBUS_DRAW                _IOW('U', 10, __u32)
 
+/*
+ * Fills in the usb_raw_eps_info structure with information about non-control
+ * endpoints available for the currently connected UDC.
+ * Returns the number of available endpoints on success or negative error code
+ * on failure.
+ */
+#define USB_RAW_IOCTL_EPS_INFO         _IOR('U', 11, struct usb_raw_eps_info)
+
+/*
+ * Stalls a pending control request on endpoint 0.
+ * Returns 0 on success or negative error code on failure.
+ */
+#define USB_RAW_IOCTL_EP0_STALL                _IO('U', 12)
+
+/*
+ * Sets or clears halt or wedge status of the endpoint.
+ * Accepts endpoint handle as an argument.
+ * Returns 0 on success or negative error code on failure.
+ */
+#define USB_RAW_IOCTL_EP_SET_HALT      _IOW('U', 13, __u32)
+#define USB_RAW_IOCTL_EP_CLEAR_HALT    _IOW('U', 14, __u32)
+#define USB_RAW_IOCTL_EP_SET_WEDGE     _IOW('U', 15, __u32)
+
 #endif /* _UAPI__LINUX_USB_RAW_GADGET_H */
index 9278a60..74a5ac6 100644 (file)
@@ -2261,6 +2261,9 @@ config ASN1
 
 source "kernel/Kconfig.locks"
 
+config ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+       bool
+
 config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
        bool
 
index 1a5da2c..0337197 100644 (file)
@@ -400,9 +400,8 @@ static void __init setup_boot_config(const char *cmdline)
        char *data, *copy;
        int ret;
 
+       /* Cut out the bootconfig data even if we have no bootconfig option */
        data = get_boot_config_from_initrd(&size, &csum);
-       if (!data)
-               goto not_found;
 
        strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
        parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL,
@@ -411,6 +410,11 @@ static void __init setup_boot_config(const char *cmdline)
        if (!bootconfig_found)
                return;
 
+       if (!data) {
+               pr_err("'bootconfig' found on command line, but no bootconfig found\n");
+               return;
+       }
+
        if (size >= XBC_DATA_MAX) {
                pr_err("bootconfig size %d greater than max size %d\n",
                        size, XBC_DATA_MAX);
@@ -446,8 +450,6 @@ static void __init setup_boot_config(const char *cmdline)
                extra_init_args = xbc_make_cmdline("init");
        }
        return;
-not_found:
-       pr_err("'bootconfig' found on command line, but no bootconfig found\n");
 }
 
 #else
@@ -1036,6 +1038,8 @@ asmlinkage __visible void __init start_kernel(void)
 
        /* Do the rest non-__init'ed, we're now alive */
        arch_call_rest_init();
+
+       prevent_tail_call_optimization();
 }
 
 /* Call all constructor functions linked into the kernel. */
index 7acccfd..cfa0045 100644 (file)
@@ -764,21 +764,21 @@ static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
                        total++;
        }
 
-       *new_pos = pos + 1;
+       ipc = NULL;
        if (total >= ids->in_use)
-               return NULL;
+               goto out;
 
        for (; pos < ipc_mni; pos++) {
                ipc = idr_find(&ids->ipcs_idr, pos);
                if (ipc != NULL) {
                        rcu_read_lock();
                        ipc_lock_object(ipc);
-                       return ipc;
+                       break;
                }
        }
-
-       /* Out of range - return NULL to terminate iteration */
-       return NULL;
+out:
+       *new_pos = pos + 1;
+       return ipc;
 }
 
 static void *sysvipc_proc_next(struct seq_file *s, void *it, loff_t *pos)
index 95d7777..1d6120f 100644 (file)
@@ -486,7 +486,12 @@ static int array_map_mmap(struct bpf_map *map, struct vm_area_struct *vma)
        if (!(map->map_flags & BPF_F_MMAPABLE))
                return -EINVAL;
 
-       return remap_vmalloc_range(vma, array_map_vmalloc_addr(array), pgoff);
+       if (vma->vm_pgoff * PAGE_SIZE + (vma->vm_end - vma->vm_start) >
+           PAGE_ALIGN((u64)array->map.max_entries * array->elem_size))
+               return -EINVAL;
+
+       return remap_vmalloc_range(vma, array_map_vmalloc_addr(array),
+                                  vma->vm_pgoff + pgoff);
 }
 
 const struct bpf_map_ops array_map_ops = {
index 7626b80..2843bbb 100644 (file)
@@ -1485,8 +1485,10 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr)
        if (err)
                goto free_value;
 
-       if (copy_to_user(uvalue, value, value_size) != 0)
+       if (copy_to_user(uvalue, value, value_size) != 0) {
+               err = -EFAULT;
                goto free_value;
+       }
 
        err = 0;
 
index fa1d824..8d7ee40 100644 (file)
@@ -4340,7 +4340,9 @@ static void do_refine_retval_range(struct bpf_reg_state *regs, int ret_type,
 
        if (ret_type != RET_INTEGER ||
            (func_id != BPF_FUNC_get_stack &&
-            func_id != BPF_FUNC_probe_read_str))
+            func_id != BPF_FUNC_probe_read_str &&
+            func_id != BPF_FUNC_probe_read_kernel_str &&
+            func_id != BPF_FUNC_probe_read_user_str))
                return;
 
        ret_reg->smax_value = meta->msize_max_value;
@@ -7059,6 +7061,23 @@ static int check_return_code(struct bpf_verifier_env *env)
                        return 0;
                range = tnum_const(0);
                break;
+       case BPF_PROG_TYPE_TRACING:
+               switch (env->prog->expected_attach_type) {
+               case BPF_TRACE_FENTRY:
+               case BPF_TRACE_FEXIT:
+                       range = tnum_const(0);
+                       break;
+               case BPF_TRACE_RAW_TP:
+               case BPF_MODIFY_RETURN:
+                       return 0;
+               default:
+                       return -ENOTSUPP;
+               }
+               break;
+       case BPF_PROG_TYPE_EXT:
+               /* freplace program can return anything as its return value
+                * depends on the to-be-replaced kernel func or bpf program.
+                */
        default:
                return 0;
        }
index 8c700f8..48ed227 100644 (file)
@@ -2486,11 +2486,11 @@ long do_fork(unsigned long clone_flags,
              int __user *child_tidptr)
 {
        struct kernel_clone_args args = {
-               .flags          = (clone_flags & ~CSIGNAL),
+               .flags          = (lower_32_bits(clone_flags) & ~CSIGNAL),
                .pidfd          = parent_tidptr,
                .child_tid      = child_tidptr,
                .parent_tid     = parent_tidptr,
-               .exit_signal    = (clone_flags & CSIGNAL),
+               .exit_signal    = (lower_32_bits(clone_flags) & CSIGNAL),
                .stack          = stack_start,
                .stack_size     = stack_size,
        };
@@ -2508,8 +2508,9 @@ long do_fork(unsigned long clone_flags,
 pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
 {
        struct kernel_clone_args args = {
-               .flags          = ((flags | CLONE_VM | CLONE_UNTRACED) & ~CSIGNAL),
-               .exit_signal    = (flags & CSIGNAL),
+               .flags          = ((lower_32_bits(flags) | CLONE_VM |
+                                   CLONE_UNTRACED) & ~CSIGNAL),
+               .exit_signal    = (lower_32_bits(flags) & CSIGNAL),
                .stack          = (unsigned long)fn,
                .stack_size     = (unsigned long)arg,
        };
@@ -2570,11 +2571,11 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
 #endif
 {
        struct kernel_clone_args args = {
-               .flags          = (clone_flags & ~CSIGNAL),
+               .flags          = (lower_32_bits(clone_flags) & ~CSIGNAL),
                .pidfd          = parent_tidptr,
                .child_tid      = child_tidptr,
                .parent_tid     = parent_tidptr,
-               .exit_signal    = (clone_flags & CSIGNAL),
+               .exit_signal    = (lower_32_bits(clone_flags) & CSIGNAL),
                .stack          = newsp,
                .tls            = tls,
        };
index ca17967..a010edc 100644 (file)
@@ -323,17 +323,15 @@ static const struct bpf_func_proto *bpf_get_probe_write_proto(void)
 
 /*
  * Only limited trace_printk() conversion specifiers allowed:
- * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %s
+ * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %pks %pus %s
  */
 BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
           u64, arg2, u64, arg3)
 {
+       int i, mod[3] = {}, fmt_cnt = 0;
+       char buf[64], fmt_ptype;
+       void *unsafe_ptr = NULL;
        bool str_seen = false;
-       int mod[3] = {};
-       int fmt_cnt = 0;
-       u64 unsafe_addr;
-       char buf[64];
-       int i;
 
        /*
         * bpf_check()->check_func_arg()->check_stack_boundary()
@@ -359,40 +357,71 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
                if (fmt[i] == 'l') {
                        mod[fmt_cnt]++;
                        i++;
-               } else if (fmt[i] == 'p' || fmt[i] == 's') {
+               } else if (fmt[i] == 'p') {
                        mod[fmt_cnt]++;
+                       if ((fmt[i + 1] == 'k' ||
+                            fmt[i + 1] == 'u') &&
+                           fmt[i + 2] == 's') {
+                               fmt_ptype = fmt[i + 1];
+                               i += 2;
+                               goto fmt_str;
+                       }
+
                        /* disallow any further format extensions */
                        if (fmt[i + 1] != 0 &&
                            !isspace(fmt[i + 1]) &&
                            !ispunct(fmt[i + 1]))
                                return -EINVAL;
-                       fmt_cnt++;
-                       if (fmt[i] == 's') {
-                               if (str_seen)
-                                       /* allow only one '%s' per fmt string */
-                                       return -EINVAL;
-                               str_seen = true;
-
-                               switch (fmt_cnt) {
-                               case 1:
-                                       unsafe_addr = arg1;
-                                       arg1 = (long) buf;
-                                       break;
-                               case 2:
-                                       unsafe_addr = arg2;
-                                       arg2 = (long) buf;
-                                       break;
-                               case 3:
-                                       unsafe_addr = arg3;
-                                       arg3 = (long) buf;
-                                       break;
-                               }
-                               buf[0] = 0;
-                               strncpy_from_unsafe(buf,
-                                                   (void *) (long) unsafe_addr,
+
+                       goto fmt_next;
+               } else if (fmt[i] == 's') {
+                       mod[fmt_cnt]++;
+                       fmt_ptype = fmt[i];
+fmt_str:
+                       if (str_seen)
+                               /* allow only one '%s' per fmt string */
+                               return -EINVAL;
+                       str_seen = true;
+
+                       if (fmt[i + 1] != 0 &&
+                           !isspace(fmt[i + 1]) &&
+                           !ispunct(fmt[i + 1]))
+                               return -EINVAL;
+
+                       switch (fmt_cnt) {
+                       case 0:
+                               unsafe_ptr = (void *)(long)arg1;
+                               arg1 = (long)buf;
+                               break;
+                       case 1:
+                               unsafe_ptr = (void *)(long)arg2;
+                               arg2 = (long)buf;
+                               break;
+                       case 2:
+                               unsafe_ptr = (void *)(long)arg3;
+                               arg3 = (long)buf;
+                               break;
+                       }
+
+                       buf[0] = 0;
+                       switch (fmt_ptype) {
+                       case 's':
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+                               strncpy_from_unsafe(buf, unsafe_ptr,
                                                    sizeof(buf));
+                               break;
+#endif
+                       case 'k':
+                               strncpy_from_unsafe_strict(buf, unsafe_ptr,
+                                                          sizeof(buf));
+                               break;
+                       case 'u':
+                               strncpy_from_unsafe_user(buf,
+                                       (__force void __user *)unsafe_ptr,
+                                                        sizeof(buf));
+                               break;
                        }
-                       continue;
+                       goto fmt_next;
                }
 
                if (fmt[i] == 'l') {
@@ -403,6 +432,7 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
                if (fmt[i] != 'i' && fmt[i] != 'd' &&
                    fmt[i] != 'u' && fmt[i] != 'x')
                        return -EINVAL;
+fmt_next:
                fmt_cnt++;
        }
 
@@ -825,14 +855,16 @@ bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
                return &bpf_probe_read_user_proto;
        case BPF_FUNC_probe_read_kernel:
                return &bpf_probe_read_kernel_proto;
-       case BPF_FUNC_probe_read:
-               return &bpf_probe_read_compat_proto;
        case BPF_FUNC_probe_read_user_str:
                return &bpf_probe_read_user_str_proto;
        case BPF_FUNC_probe_read_kernel_str:
                return &bpf_probe_read_kernel_str_proto;
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+       case BPF_FUNC_probe_read:
+               return &bpf_probe_read_compat_proto;
        case BPF_FUNC_probe_read_str:
                return &bpf_probe_read_compat_str_proto;
+#endif
 #ifdef CONFIG_CGROUPS
        case BPF_FUNC_get_current_cgroup_id:
                return &bpf_get_current_cgroup_id_proto;
index 0456e0a..382775e 100644 (file)
@@ -4,28 +4,6 @@
 
 #ifdef CONFIG_FUNCTION_TRACER
 
-/*
- * Traverse the ftrace_global_list, invoking all entries.  The reason that we
- * can use rcu_dereference_raw_check() is that elements removed from this list
- * are simply leaked, so there is no need to interact with a grace-period
- * mechanism.  The rcu_dereference_raw_check() calls are needed to handle
- * concurrent insertions into the ftrace_global_list.
- *
- * Silly Alpha and silly pointer-speculation compiler optimizations!
- */
-#define do_for_each_ftrace_op(op, list)                        \
-       op = rcu_dereference_raw_check(list);                   \
-       do
-
-/*
- * Optimized for just a single item in the list (as that is the normal case).
- */
-#define while_for_each_ftrace_op(op)                           \
-       while (likely(op = rcu_dereference_raw_check((op)->next)) &&    \
-              unlikely((op) != &ftrace_list_end))
-
-extern struct ftrace_ops __rcu *ftrace_ops_list;
-extern struct ftrace_ops ftrace_list_end;
 extern struct mutex ftrace_lock;
 extern struct ftrace_ops global_ops;
 
index c4c86de..312d1a0 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/printk.h>
 #include <linux/string.h>
 #include <linux/sysfs.h>
+#include <linux/completion.h>
 
 static ulong delay = 100;
 static char test_mode[12] = "irq";
@@ -28,6 +29,8 @@ MODULE_PARM_DESC(delay, "Period in microseconds (100 us default)");
 MODULE_PARM_DESC(test_mode, "Mode of the test such as preempt, irq, or alternate (default irq)");
 MODULE_PARM_DESC(burst_size, "The size of a burst (default 1)");
 
+static struct completion done;
+
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
 
 static void busy_wait(ulong time)
@@ -114,6 +117,8 @@ static int preemptirq_delay_run(void *data)
        for (i = 0; i < s; i++)
                (testfuncs[i])(i);
 
+       complete(&done);
+
        set_current_state(TASK_INTERRUPTIBLE);
        while (!kthread_should_stop()) {
                schedule();
@@ -128,15 +133,18 @@ static int preemptirq_delay_run(void *data)
 static int preemptirq_run_test(void)
 {
        struct task_struct *task;
-
        char task_name[50];
 
+       init_completion(&done);
+
        snprintf(task_name, sizeof(task_name), "%s_test", test_mode);
        task =  kthread_run(preemptirq_delay_run, NULL, task_name);
        if (IS_ERR(task))
                return PTR_ERR(task);
-       if (task)
+       if (task) {
+               wait_for_completion(&done);
                kthread_stop(task);
+       }
        return 0;
 }
 
index 6f0b42c..b8e1ca4 100644 (file)
@@ -193,7 +193,7 @@ rb_event_length(struct ring_buffer_event *event)
        case RINGBUF_TYPE_DATA:
                return rb_event_data_length(event);
        default:
-               BUG();
+               WARN_ON_ONCE(1);
        }
        /* not hit */
        return 0;
@@ -249,7 +249,7 @@ rb_event_data(struct ring_buffer_event *event)
 {
        if (extended_time(event))
                event = skip_time_extend(event);
-       BUG_ON(event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX);
+       WARN_ON_ONCE(event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX);
        /* If length is in len field, then array[0] has the data */
        if (event->type_len)
                return (void *)&event->array[0];
@@ -3727,7 +3727,7 @@ rb_update_read_stamp(struct ring_buffer_per_cpu *cpu_buffer,
                return;
 
        default:
-               BUG();
+               RB_WARN_ON(cpu_buffer, 1);
        }
        return;
 }
@@ -3757,7 +3757,7 @@ rb_update_iter_read_stamp(struct ring_buffer_iter *iter,
                return;
 
        default:
-               BUG();
+               RB_WARN_ON(iter->cpu_buffer, 1);
        }
        return;
 }
@@ -4020,7 +4020,7 @@ rb_buffer_peek(struct ring_buffer_per_cpu *cpu_buffer, u64 *ts,
                return event;
 
        default:
-               BUG();
+               RB_WARN_ON(cpu_buffer, 1);
        }
 
        return NULL;
@@ -4034,7 +4034,6 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
        struct ring_buffer_per_cpu *cpu_buffer;
        struct ring_buffer_event *event;
        int nr_loops = 0;
-       bool failed = false;
 
        if (ts)
                *ts = 0;
@@ -4056,19 +4055,14 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
                return NULL;
 
        /*
-        * We repeat when a time extend is encountered or we hit
-        * the end of the page. Since the time extend is always attached
-        * to a data event, we should never loop more than three times.
-        * Once for going to next page, once on time extend, and
-        * finally once to get the event.
-        * We should never hit the following condition more than thrice,
-        * unless the buffer is very small, and there's a writer
-        * that is causing the reader to fail getting an event.
+        * As the writer can mess with what the iterator is trying
+        * to read, just give up if we fail to get an event after
+        * three tries. The iterator is not as reliable when reading
+        * the ring buffer with an active write as the consumer is.
+        * Do not warn if the three failures is reached.
         */
-       if (++nr_loops > 3) {
-               RB_WARN_ON(cpu_buffer, !failed);
+       if (++nr_loops > 3)
                return NULL;
-       }
 
        if (rb_per_cpu_empty(cpu_buffer))
                return NULL;
@@ -4079,10 +4073,8 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
        }
 
        event = rb_iter_head_event(iter);
-       if (!event) {
-               failed = true;
+       if (!event)
                goto again;
-       }
 
        switch (event->type_len) {
        case RINGBUF_TYPE_PADDING:
@@ -4117,7 +4109,7 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
                return event;
 
        default:
-               BUG();
+               RB_WARN_ON(cpu_buffer, 1);
        }
 
        return NULL;
index 11bf5ee..3474d6a 100644 (file)
@@ -475,6 +475,12 @@ static void umh_clean_and_save_pid(struct subprocess_info *info)
 {
        struct umh_info *umh_info = info->data;
 
+       /* cleanup if umh_pipe_setup() was successful but exec failed */
+       if (info->pid && info->retval) {
+               fput(umh_info->pipe_to_umh);
+               fput(umh_info->pipe_from_umh);
+       }
+
        argv_free(info->argv);
        umh_info->pid = info->pid;
 }
index 2d9f520..6b1622f 100644 (file)
@@ -214,6 +214,7 @@ test_string(void)
 #define PTR_STR "ffff0123456789ab"
 #define PTR_VAL_NO_CRNG "(____ptrval____)"
 #define ZEROS "00000000"       /* hex 32 zero bits */
+#define ONES "ffffffff"                /* hex 32 one bits */
 
 static int __init
 plain_format(void)
@@ -245,6 +246,7 @@ plain_format(void)
 #define PTR_STR "456789ab"
 #define PTR_VAL_NO_CRNG "(ptrval)"
 #define ZEROS ""
+#define ONES ""
 
 static int __init
 plain_format(void)
@@ -330,14 +332,28 @@ test_hashed(const char *fmt, const void *p)
        test(buf, fmt, p);
 }
 
+/*
+ * NULL pointers aren't hashed.
+ */
 static void __init
 null_pointer(void)
 {
-       test_hashed("%p", NULL);
+       test(ZEROS "00000000", "%p", NULL);
        test(ZEROS "00000000", "%px", NULL);
        test("(null)", "%pE", NULL);
 }
 
+/*
+ * Error pointers aren't hashed.
+ */
+static void __init
+error_pointer(void)
+{
+       test(ONES "fffffff5", "%p", ERR_PTR(-11));
+       test(ONES "fffffff5", "%px", ERR_PTR(-11));
+       test("(efault)", "%pE", ERR_PTR(-11));
+}
+
 #define PTR_INVALID ((void *)0x000000ab)
 
 static void __init
@@ -649,6 +665,7 @@ test_pointer(void)
 {
        plain();
        null_pointer();
+       error_pointer();
        invalid_pointer();
        symbol_ptr();
        kernel_ptr();
index 7c488a1..7c47ad5 100644 (file)
@@ -794,6 +794,13 @@ static char *ptr_to_id(char *buf, char *end, const void *ptr,
        unsigned long hashval;
        int ret;
 
+       /*
+        * Print the real pointer value for NULL and error pointers,
+        * as they are not actual addresses.
+        */
+       if (IS_ERR_OR_NULL(ptr))
+               return pointer_string(buf, end, ptr, spec);
+
        /* When debugging early boot use non-cryptographically secure hash. */
        if (unlikely(debug_boot_weak_hash)) {
                hashval = hash_long((unsigned long)ptr, 32);
@@ -2168,6 +2175,10 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,
  *             f full name
  *             P node name, including a possible unit address
  * - 'x' For printing the address. Equivalent to "%lx".
+ * - '[ku]s' For a BPF/tracing related format specifier, e.g. used out of
+ *           bpf_trace_printk() where [ku] prefix specifies either kernel (k)
+ *           or user (u) memory to probe, and:
+ *              s a string, equivalent to "%s" on direct vsnprintf() use
  *
  * ** When making changes please also update:
  *     Documentation/core-api/printk-formats.rst
@@ -2251,6 +2262,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                if (!IS_ERR(ptr))
                        break;
                return err_ptr(buf, end, ptr, spec);
+       case 'u':
+       case 'k':
+               switch (fmt[1]) {
+               case 's':
+                       return string(buf, end, ptr, spec);
+               default:
+                       return error_string(buf, end, "(einval)", spec);
+               }
        }
 
        /* default is to _not_ leak addresses, hash before printing */
index 50681f0..87a6a59 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1218,6 +1218,10 @@ retry:
        if (!vma_permits_fault(vma, fault_flags))
                return -EFAULT;
 
+       if ((fault_flags & FAULT_FLAG_KILLABLE) &&
+           fatal_signal_pending(current))
+               return -EINTR;
+
        ret = handle_mm_fault(vma, address, fault_flags);
        major |= ret & VM_FAULT_MAJOR;
        if (ret & VM_FAULT_ERROR) {
@@ -1230,11 +1234,9 @@ retry:
 
        if (ret & VM_FAULT_RETRY) {
                down_read(&mm->mmap_sem);
-               if (!(fault_flags & FAULT_FLAG_TRIED)) {
-                       *unlocked = true;
-                       fault_flags |= FAULT_FLAG_TRIED;
-                       goto retry;
-               }
+               *unlocked = true;
+               fault_flags |= FAULT_FLAG_TRIED;
+               goto retry;
        }
 
        if (tsk) {
index 08b43de..434d503 100644 (file)
@@ -1,23 +1,28 @@
 # SPDX-License-Identifier: GPL-2.0
 KASAN_SANITIZE := n
-UBSAN_SANITIZE_common.o := n
-UBSAN_SANITIZE_generic.o := n
-UBSAN_SANITIZE_generic_report.o := n
-UBSAN_SANITIZE_tags.o := n
+UBSAN_SANITIZE := n
 KCOV_INSTRUMENT := n
 
+# Disable ftrace to avoid recursion.
 CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_generic.o = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_generic_report.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_init.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_quarantine.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_report.o = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_tags.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_tags_report.o = $(CC_FLAGS_FTRACE)
 
 # Function splitter causes unnecessary splits in __asan_load1/__asan_store1
 # see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533
-
 CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
 CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
 CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
+CFLAGS_init.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
+CFLAGS_quarantine.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
+CFLAGS_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
 CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
+CFLAGS_tags_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
 
 obj-$(CONFIG_KASAN) := common.o init.o report.o
 obj-$(CONFIG_KASAN_GENERIC) += generic.o generic_report.o quarantine.o
index e8f3719..cfade64 100644 (file)
@@ -212,8 +212,6 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
 asmlinkage void kasan_unpoison_task_stack_below(const void *watermark);
 void __asan_register_globals(struct kasan_global *globals, size_t size);
 void __asan_unregister_globals(struct kasan_global *globals, size_t size);
-void __asan_loadN(unsigned long addr, size_t size);
-void __asan_storeN(unsigned long addr, size_t size);
 void __asan_handle_no_return(void);
 void __asan_alloca_poison(unsigned long addr, size_t size);
 void __asan_allocas_unpoison(const void *stack_top, const void *stack_bottom);
@@ -228,6 +226,8 @@ void __asan_load8(unsigned long addr);
 void __asan_store8(unsigned long addr);
 void __asan_load16(unsigned long addr);
 void __asan_store16(unsigned long addr);
+void __asan_loadN(unsigned long addr, size_t size);
+void __asan_storeN(unsigned long addr, size_t size);
 
 void __asan_load1_noabort(unsigned long addr);
 void __asan_store1_noabort(unsigned long addr);
@@ -239,6 +239,21 @@ void __asan_load8_noabort(unsigned long addr);
 void __asan_store8_noabort(unsigned long addr);
 void __asan_load16_noabort(unsigned long addr);
 void __asan_store16_noabort(unsigned long addr);
+void __asan_loadN_noabort(unsigned long addr, size_t size);
+void __asan_storeN_noabort(unsigned long addr, size_t size);
+
+void __asan_report_load1_noabort(unsigned long addr);
+void __asan_report_store1_noabort(unsigned long addr);
+void __asan_report_load2_noabort(unsigned long addr);
+void __asan_report_store2_noabort(unsigned long addr);
+void __asan_report_load4_noabort(unsigned long addr);
+void __asan_report_store4_noabort(unsigned long addr);
+void __asan_report_load8_noabort(unsigned long addr);
+void __asan_report_store8_noabort(unsigned long addr);
+void __asan_report_load16_noabort(unsigned long addr);
+void __asan_report_store16_noabort(unsigned long addr);
+void __asan_report_load_n_noabort(unsigned long addr, size_t size);
+void __asan_report_store_n_noabort(unsigned long addr, size_t size);
 
 void __asan_set_shadow_00(const void *addr, size_t size);
 void __asan_set_shadow_f1(const void *addr, size_t size);
@@ -247,4 +262,19 @@ void __asan_set_shadow_f3(const void *addr, size_t size);
 void __asan_set_shadow_f5(const void *addr, size_t size);
 void __asan_set_shadow_f8(const void *addr, size_t size);
 
+void __hwasan_load1_noabort(unsigned long addr);
+void __hwasan_store1_noabort(unsigned long addr);
+void __hwasan_load2_noabort(unsigned long addr);
+void __hwasan_store2_noabort(unsigned long addr);
+void __hwasan_load4_noabort(unsigned long addr);
+void __hwasan_store4_noabort(unsigned long addr);
+void __hwasan_load8_noabort(unsigned long addr);
+void __hwasan_store8_noabort(unsigned long addr);
+void __hwasan_load16_noabort(unsigned long addr);
+void __hwasan_store16_noabort(unsigned long addr);
+void __hwasan_loadN_noabort(unsigned long addr, size_t size);
+void __hwasan_storeN_noabort(unsigned long addr, size_t size);
+
+void __hwasan_tag_memory(unsigned long addr, u8 tag, unsigned long size);
+
 #endif
index c881abe..6aa6ea6 100644 (file)
@@ -794,7 +794,7 @@ out:
        if (locked && new_len > old_len)
                mm_populate(new_addr + old_len, new_len - old_len);
        userfaultfd_unmap_complete(mm, &uf_unmap_early);
-       mremap_userfaultfd_complete(&uf, addr, new_addr, old_len);
+       mremap_userfaultfd_complete(&uf, addr, ret, old_len);
        userfaultfd_unmap_complete(mm, &uf_unmap);
        return ret;
 }
index 5222881..6d327b7 100644 (file)
@@ -8907,11 +8907,13 @@ static void netdev_sync_lower_features(struct net_device *upper,
                        netdev_dbg(upper, "Disabling feature %pNF on lower dev %s.\n",
                                   &feature, lower->name);
                        lower->wanted_features &= ~feature;
-                       netdev_update_features(lower);
+                       __netdev_update_features(lower);
 
                        if (unlikely(lower->features & feature))
                                netdev_WARN(upper, "failed to disable %pNF on %s!\n",
                                            &feature, lower->name);
+                       else
+                               netdev_features_change(lower);
                }
        }
 }
index 7d6ceaa..5cc9276 100644 (file)
@@ -2590,8 +2590,8 @@ BPF_CALL_4(bpf_msg_pop_data, struct sk_msg *, msg, u32, start,
                        }
                        pop = 0;
                } else if (pop >= sge->length - a) {
-                       sge->length = a;
                        pop -= (sge->length - a);
+                       sge->length = a;
                }
        }
 
index 8881dd9..9bd4cab 100644 (file)
@@ -236,6 +236,8 @@ static void net_prio_attach(struct cgroup_taskset *tset)
        struct task_struct *p;
        struct cgroup_subsys_state *css;
 
+       cgroup_sk_alloc_disable();
+
        cgroup_taskset_for_each(p, css, tset) {
                void *v = (void *)(unsigned long)css->id;
 
index 0bd10a1..a23094b 100644 (file)
@@ -1258,7 +1258,8 @@ static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def,
                        return ret_val;
                }
 
-               secattr->flags |= NETLBL_SECATTR_MLS_CAT;
+               if (secattr->attr.mls.cat)
+                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;
        }
 
        return 0;
@@ -1439,7 +1440,8 @@ static int cipso_v4_parsetag_rng(const struct cipso_v4_doi *doi_def,
                        return ret_val;
                }
 
-               secattr->flags |= NETLBL_SECATTR_MLS_CAT;
+               if (secattr->attr.mls.cat)
+                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;
        }
 
        return 0;
index 9cf83cc..5c218db 100644 (file)
@@ -109,8 +109,10 @@ static void mroute_clean_tables(struct mr_table *mrt, int flags);
 static void ipmr_expire_process(struct timer_list *t);
 
 #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES
-#define ipmr_for_each_table(mrt, net) \
-       list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list)
+#define ipmr_for_each_table(mrt, net)                                  \
+       list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list,        \
+                               lockdep_rtnl_is_held() ||               \
+                               list_empty(&net->ipv4.mr_tables))
 
 static struct mr_table *ipmr_mr_table_iter(struct net *net,
                                           struct mr_table *mrt)
index 788c69d..fa829f3 100644 (file)
@@ -915,7 +915,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
        /* Check for load limit; set rate_last to the latest sent
         * redirect.
         */
-       if (peer->rate_tokens == 0 ||
+       if (peer->n_redirects == 0 ||
            time_after(jiffies,
                       (peer->rate_last +
                        (ip_rt_redirect_load << peer->n_redirects)))) {
index 6d87de4..dd40175 100644 (file)
@@ -476,9 +476,17 @@ static void tcp_tx_timestamp(struct sock *sk, u16 tsflags)
 static inline bool tcp_stream_is_readable(const struct tcp_sock *tp,
                                          int target, struct sock *sk)
 {
-       return (READ_ONCE(tp->rcv_nxt) - READ_ONCE(tp->copied_seq) >= target) ||
-               (sk->sk_prot->stream_memory_read ?
-               sk->sk_prot->stream_memory_read(sk) : false);
+       int avail = READ_ONCE(tp->rcv_nxt) - READ_ONCE(tp->copied_seq);
+
+       if (avail > 0) {
+               if (avail >= target)
+                       return true;
+               if (tcp_rmem_pressure(sk))
+                       return true;
+       }
+       if (sk->sk_prot->stream_memory_read)
+               return sk->sk_prot->stream_memory_read(sk);
+       return false;
 }
 
 /*
@@ -1756,10 +1764,11 @@ static int tcp_zerocopy_receive(struct sock *sk,
 
        down_read(&current->mm->mmap_sem);
 
-       ret = -EINVAL;
        vma = find_vma(current->mm, address);
-       if (!vma || vma->vm_start > address || vma->vm_ops != &tcp_vm_ops)
-               goto out;
+       if (!vma || vma->vm_start > address || vma->vm_ops != &tcp_vm_ops) {
+               up_read(&current->mm->mmap_sem);
+               return -EINVAL;
+       }
        zc->length = min_t(unsigned long, zc->length, vma->vm_end - address);
 
        tp = tcp_sk(sk);
@@ -2154,13 +2163,15 @@ skip_copy:
                        tp->urg_data = 0;
                        tcp_fast_path_check(sk);
                }
-               if (used + offset < skb->len)
-                       continue;
 
                if (TCP_SKB_CB(skb)->has_rxtstamp) {
                        tcp_update_recv_tstamps(skb, &tss);
                        cmsg_flags |= 2;
                }
+
+               if (used + offset < skb->len)
+                       continue;
+
                if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
                        goto found_fin_ok;
                if (!(flags & MSG_PEEK))
index 5a05327..629aaa9 100644 (file)
@@ -125,7 +125,6 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
 
        if (!ret) {
                msg->sg.start = i;
-               msg->sg.size -= apply_bytes;
                sk_psock_queue_msg(psock, tmp);
                sk_psock_data_ready(sk, psock);
        } else {
@@ -262,14 +261,17 @@ static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
        struct sk_psock *psock;
        int copied, ret;
 
+       if (unlikely(flags & MSG_ERRQUEUE))
+               return inet_recv_error(sk, msg, len, addr_len);
+
        psock = sk_psock_get(sk);
        if (unlikely(!psock))
                return tcp_recvmsg(sk, msg, len, nonblock, flags, addr_len);
-       if (unlikely(flags & MSG_ERRQUEUE))
-               return inet_recv_error(sk, msg, len, addr_len);
        if (!skb_queue_empty(&sk->sk_receive_queue) &&
-           sk_psock_queue_empty(psock))
+           sk_psock_queue_empty(psock)) {
+               sk_psock_put(sk, psock);
                return tcp_recvmsg(sk, msg, len, nonblock, flags, addr_len);
+       }
        lock_sock(sk);
 msg_bytes_ready:
        copied = __tcp_bpf_recvmsg(sk, psock, msg, len, flags);
index b996dc1..29c6fc8 100644 (file)
@@ -4757,7 +4757,8 @@ void tcp_data_ready(struct sock *sk)
        const struct tcp_sock *tp = tcp_sk(sk);
        int avail = tp->rcv_nxt - tp->copied_seq;
 
-       if (avail < sk->sk_rcvlowat && !sock_flag(sk, SOCK_DONE))
+       if (avail < sk->sk_rcvlowat && !tcp_rmem_pressure(sk) &&
+           !sock_flag(sk, SOCK_DONE))
                return;
 
        sk->sk_data_ready(sk);
index 221c81f..8d3f66c 100644 (file)
@@ -1047,7 +1047,8 @@ static int calipso_opt_getattr(const unsigned char *calipso,
                        goto getattr_return;
                }
 
-               secattr->flags |= NETLBL_SECATTR_MLS_CAT;
+               if (secattr->attr.mls.cat)
+                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;
        }
 
        secattr->type = NETLBL_NLTYPE_CALIPSO;
index 8d41803..ff847a3 100644 (file)
@@ -2722,8 +2722,10 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
        const struct in6_addr *daddr, *saddr;
        struct rt6_info *rt6 = (struct rt6_info *)dst;
 
-       if (dst_metric_locked(dst, RTAX_MTU))
-               return;
+       /* Note: do *NOT* check dst_metric_locked(dst, RTAX_MTU)
+        * IPv6 pmtu discovery isn't optional, so 'mtu lock' cannot disable it.
+        * [see also comment in rt6_mtu_change_route()]
+        */
 
        if (iph) {
                daddr = &iph->daddr;
index e1f2301..32ea8d3 100644 (file)
@@ -1629,6 +1629,8 @@ bool mptcp_finish_join(struct sock *sk)
 
        ret = mptcp_pm_allow_new_subflow(msk);
        if (ret) {
+               subflow->map_seq = msk->ack_seq;
+
                /* active connections are already on conn_list */
                spin_lock_bh(&msk->join_list_lock);
                if (!WARN_ON_ONCE(!list_empty(&subflow->node)))
index 67a4e35..4931a29 100644 (file)
@@ -1012,6 +1012,16 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
        if (err)
                return err;
 
+       /* the newly created socket really belongs to the owning MPTCP master
+        * socket, even if for additional subflows the allocation is performed
+        * by a kernel workqueue. Adjust inode references, so that the
+        * procfs/diag interaces really show this one belonging to the correct
+        * user.
+        */
+       SOCK_INODE(sf)->i_ino = SOCK_INODE(sk->sk_socket)->i_ino;
+       SOCK_INODE(sf)->i_uid = SOCK_INODE(sk->sk_socket)->i_uid;
+       SOCK_INODE(sf)->i_gid = SOCK_INODE(sk->sk_socket)->i_gid;
+
        subflow = mptcp_subflow_ctx(sf->sk);
        pr_debug("subflow=%p", subflow);
 
index c4582eb..1d57b95 100644 (file)
@@ -1519,9 +1519,9 @@ __nf_conntrack_alloc(struct net *net,
        ct->status = 0;
        ct->timeout = 0;
        write_pnet(&ct->ct_net, net);
-       memset(&ct->__nfct_init_offset[0], 0,
+       memset(&ct->__nfct_init_offset, 0,
               offsetof(struct nf_conn, proto) -
-              offsetof(struct nf_conn, __nfct_init_offset[0]));
+              offsetof(struct nf_conn, __nfct_init_offset));
 
        nf_ct_zone_add(ct, zone);
 
@@ -2139,8 +2139,19 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data),
                nf_conntrack_lock(lockp);
                if (*bucket < nf_conntrack_htable_size) {
                        hlist_nulls_for_each_entry(h, n, &nf_conntrack_hash[*bucket], hnnode) {
-                               if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
+                               if (NF_CT_DIRECTION(h) != IP_CT_DIR_REPLY)
                                        continue;
+                               /* All nf_conn objects are added to hash table twice, one
+                                * for original direction tuple, once for the reply tuple.
+                                *
+                                * Exception: In the IPS_NAT_CLASH case, only the reply
+                                * tuple is added (the original tuple already existed for
+                                * a different object).
+                                *
+                                * We only need to call the iterator once for each
+                                * conntrack, so we just use the 'reply' direction
+                                * tuple while iterating.
+                                */
                                ct = nf_ct_tuplehash_to_ctrack(h);
                                if (iter(ct, data))
                                        goto found;
index 4344e57..42da6e3 100644 (file)
@@ -284,7 +284,7 @@ static void flow_offload_del(struct nf_flowtable *flow_table,
 
        if (nf_flow_has_expired(flow))
                flow_offload_fixup_ct(flow->ct);
-       else if (test_bit(NF_FLOW_TEARDOWN, &flow->flags))
+       else
                flow_offload_fixup_ct_timeout(flow->ct);
 
        flow_offload_free(flow);
@@ -361,8 +361,10 @@ static void nf_flow_offload_gc_step(struct flow_offload *flow, void *data)
 {
        struct nf_flowtable *flow_table = data;
 
-       if (nf_flow_has_expired(flow) || nf_ct_is_dying(flow->ct) ||
-           test_bit(NF_FLOW_TEARDOWN, &flow->flags)) {
+       if (nf_flow_has_expired(flow) || nf_ct_is_dying(flow->ct))
+               set_bit(NF_FLOW_TEARDOWN, &flow->flags);
+
+       if (test_bit(NF_FLOW_TEARDOWN, &flow->flags)) {
                if (test_bit(NF_FLOW_HW, &flow->flags)) {
                        if (!test_bit(NF_FLOW_HW_DYING, &flow->flags))
                                nf_flow_offload_del(flow_table, flow);
index e3b099c..2276a73 100644 (file)
@@ -817,6 +817,7 @@ static void flow_offload_work_handler(struct work_struct *work)
                        WARN_ON_ONCE(1);
        }
 
+       clear_bit(NF_FLOW_HW_PENDING, &offload->flow->flags);
        kfree(offload);
 }
 
@@ -831,9 +832,14 @@ nf_flow_offload_work_alloc(struct nf_flowtable *flowtable,
 {
        struct flow_offload_work *offload;
 
+       if (test_and_set_bit(NF_FLOW_HW_PENDING, &flow->flags))
+               return NULL;
+
        offload = kmalloc(sizeof(struct flow_offload_work), GFP_ATOMIC);
-       if (!offload)
+       if (!offload) {
+               clear_bit(NF_FLOW_HW_PENDING, &flow->flags);
                return NULL;
+       }
 
        offload->cmd = cmd;
        offload->flow = flow;
@@ -1056,7 +1062,7 @@ static struct flow_indr_block_entry block_ing_entry = {
 int nf_flow_table_offload_init(void)
 {
        nf_flow_offload_wq  = alloc_workqueue("nf_flow_table_offload",
-                                             WQ_UNBOUND | WQ_MEM_RECLAIM, 0);
+                                             WQ_UNBOUND, 0);
        if (!nf_flow_offload_wq)
                return -ENOMEM;
 
index 3ffef45..62f416b 100644 (file)
@@ -79,6 +79,10 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
                                parent = rcu_dereference_raw(parent->rb_left);
                                continue;
                        }
+
+                       if (nft_set_elem_expired(&rbe->ext))
+                               return false;
+
                        if (nft_rbtree_interval_end(rbe)) {
                                if (nft_set_is_anonymous(set))
                                        return false;
@@ -94,6 +98,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
 
        if (set->flags & NFT_SET_INTERVAL && interval != NULL &&
            nft_set_elem_active(&interval->ext, genmask) &&
+           !nft_set_elem_expired(&interval->ext) &&
            nft_rbtree_interval_start(interval)) {
                *ext = &interval->ext;
                return true;
@@ -154,6 +159,9 @@ static bool __nft_rbtree_get(const struct net *net, const struct nft_set *set,
                                continue;
                        }
 
+                       if (nft_set_elem_expired(&rbe->ext))
+                               return false;
+
                        if (!nft_set_ext_exists(&rbe->ext, NFT_SET_EXT_FLAGS) ||
                            (*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END) ==
                            (flags & NFT_SET_ELEM_INTERVAL_END)) {
@@ -170,6 +178,7 @@ static bool __nft_rbtree_get(const struct net *net, const struct nft_set *set,
 
        if (set->flags & NFT_SET_INTERVAL && interval != NULL &&
            nft_set_elem_active(&interval->ext, genmask) &&
+           !nft_set_elem_expired(&interval->ext) &&
            ((!nft_rbtree_interval_end(interval) &&
              !(flags & NFT_SET_ELEM_INTERVAL_END)) ||
             (nft_rbtree_interval_end(interval) &&
@@ -418,6 +427,8 @@ static void nft_rbtree_walk(const struct nft_ctx *ctx,
 
                if (iter->count < iter->skip)
                        goto cont;
+               if (nft_set_elem_expired(&rbe->ext))
+                       goto cont;
                if (!nft_set_elem_active(&rbe->ext, iter->genmask))
                        goto cont;
 
index 409a3ae..5e1239c 100644 (file)
@@ -734,6 +734,12 @@ int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
        if ((off & (BITS_PER_LONG - 1)) != 0)
                return -EINVAL;
 
+       /* a null catmap is equivalent to an empty one */
+       if (!catmap) {
+               *offset = (u32)-1;
+               return 0;
+       }
+
        if (off < catmap->startbit) {
                off = catmap->startbit;
                *offset = off;
index 25fbd8d..ac5cac0 100644 (file)
@@ -2032,7 +2032,6 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred,
        struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
        struct kvec *head = rqstp->rq_rcv_buf.head;
        struct rpc_auth *auth = cred->cr_auth;
-       unsigned int savedlen = rcv_buf->len;
        u32 offset, opaque_len, maj_stat;
        __be32 *p;
 
@@ -2043,9 +2042,9 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred,
        offset = (u8 *)(p) - (u8 *)head->iov_base;
        if (offset + opaque_len > rcv_buf->len)
                goto unwrap_failed;
-       rcv_buf->len = offset + opaque_len;
 
-       maj_stat = gss_unwrap(ctx->gc_gss_ctx, offset, rcv_buf);
+       maj_stat = gss_unwrap(ctx->gc_gss_ctx, offset,
+                             offset + opaque_len, rcv_buf);
        if (maj_stat == GSS_S_CONTEXT_EXPIRED)
                clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
        if (maj_stat != GSS_S_COMPLETE)
@@ -2059,10 +2058,9 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred,
         */
        xdr_init_decode(xdr, rcv_buf, p, rqstp);
 
-       auth->au_rslack = auth->au_verfsize + 2 +
-                         XDR_QUADLEN(savedlen - rcv_buf->len);
-       auth->au_ralign = auth->au_verfsize + 2 +
-                         XDR_QUADLEN(savedlen - rcv_buf->len);
+       auth->au_rslack = auth->au_verfsize + 2 + ctx->gc_gss_ctx->slack;
+       auth->au_ralign = auth->au_verfsize + 2 + ctx->gc_gss_ctx->align;
+
        return 0;
 unwrap_failed:
        trace_rpcgss_unwrap_failed(task);
index 6f2d30d..e7180da 100644 (file)
@@ -851,8 +851,8 @@ out_err:
 }
 
 u32
-gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf,
-                    u32 *headskip, u32 *tailskip)
+gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len,
+                    struct xdr_buf *buf, u32 *headskip, u32 *tailskip)
 {
        struct xdr_buf subbuf;
        u32 ret = 0;
@@ -881,7 +881,7 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf,
 
        /* create a segment skipping the header and leaving out the checksum */
        xdr_buf_subsegment(buf, &subbuf, offset + GSS_KRB5_TOK_HDR_LEN,
-                                   (buf->len - offset - GSS_KRB5_TOK_HDR_LEN -
+                                   (len - offset - GSS_KRB5_TOK_HDR_LEN -
                                     kctx->gk5e->cksumlength));
 
        nblocks = (subbuf.len + blocksize - 1) / blocksize;
@@ -926,7 +926,7 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf,
                goto out_err;
 
        /* Get the packet's hmac value */
-       ret = read_bytes_from_xdr_buf(buf, buf->len - kctx->gk5e->cksumlength,
+       ret = read_bytes_from_xdr_buf(buf, len - kctx->gk5e->cksumlength,
                                      pkt_hmac, kctx->gk5e->cksumlength);
        if (ret)
                goto out_err;
index 6c1920e..cf0fd17 100644 (file)
@@ -261,7 +261,9 @@ gss_wrap_kerberos_v1(struct krb5_ctx *kctx, int offset,
 }
 
 static u32
-gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
+gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, int len,
+                      struct xdr_buf *buf, unsigned int *slack,
+                      unsigned int *align)
 {
        int                     signalg;
        int                     sealalg;
@@ -279,12 +281,13 @@ gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
        u32                     conflen = kctx->gk5e->conflen;
        int                     crypt_offset;
        u8                      *cksumkey;
+       unsigned int            saved_len = buf->len;
 
        dprintk("RPC:       gss_unwrap_kerberos\n");
 
        ptr = (u8 *)buf->head[0].iov_base + offset;
        if (g_verify_token_header(&kctx->mech_used, &bodysize, &ptr,
-                                       buf->len - offset))
+                                       len - offset))
                return GSS_S_DEFECTIVE_TOKEN;
 
        if ((ptr[0] != ((KG_TOK_WRAP_MSG >> 8) & 0xff)) ||
@@ -324,6 +327,7 @@ gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
            (!kctx->initiate && direction != 0))
                return GSS_S_BAD_SIG;
 
+       buf->len = len;
        if (kctx->enctype == ENCTYPE_ARCFOUR_HMAC) {
                struct crypto_sync_skcipher *cipher;
                int err;
@@ -376,11 +380,15 @@ gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
        data_len = (buf->head[0].iov_base + buf->head[0].iov_len) - data_start;
        memmove(orig_start, data_start, data_len);
        buf->head[0].iov_len -= (data_start - orig_start);
-       buf->len -= (data_start - orig_start);
+       buf->len = len - (data_start - orig_start);
 
        if (gss_krb5_remove_padding(buf, blocksize))
                return GSS_S_DEFECTIVE_TOKEN;
 
+       /* slack must include room for krb5 padding */
+       *slack = XDR_QUADLEN(saved_len - buf->len);
+       /* The GSS blob always precedes the RPC message payload */
+       *align = *slack;
        return GSS_S_COMPLETE;
 }
 
@@ -486,7 +494,9 @@ gss_wrap_kerberos_v2(struct krb5_ctx *kctx, u32 offset,
 }
 
 static u32
-gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
+gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, int len,
+                      struct xdr_buf *buf, unsigned int *slack,
+                      unsigned int *align)
 {
        time64_t        now;
        u8              *ptr;
@@ -532,7 +542,7 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
        if (rrc != 0)
                rotate_left(offset + 16, buf, rrc);
 
-       err = (*kctx->gk5e->decrypt_v2)(kctx, offset, buf,
+       err = (*kctx->gk5e->decrypt_v2)(kctx, offset, len, buf,
                                        &headskip, &tailskip);
        if (err)
                return GSS_S_FAILURE;
@@ -542,7 +552,7 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
         * it against the original
         */
        err = read_bytes_from_xdr_buf(buf,
-                               buf->len - GSS_KRB5_TOK_HDR_LEN - tailskip,
+                               len - GSS_KRB5_TOK_HDR_LEN - tailskip,
                                decrypted_hdr, GSS_KRB5_TOK_HDR_LEN);
        if (err) {
                dprintk("%s: error %u getting decrypted_hdr\n", __func__, err);
@@ -568,18 +578,19 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf)
         * Note that buf->head[0].iov_len may indicate the available
         * head buffer space rather than that actually occupied.
         */
-       movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len);
+       movelen = min_t(unsigned int, buf->head[0].iov_len, len);
        movelen -= offset + GSS_KRB5_TOK_HDR_LEN + headskip;
-       if (offset + GSS_KRB5_TOK_HDR_LEN + headskip + movelen >
-           buf->head[0].iov_len)
-               return GSS_S_FAILURE;
+       BUG_ON(offset + GSS_KRB5_TOK_HDR_LEN + headskip + movelen >
+                                                       buf->head[0].iov_len);
        memmove(ptr, ptr + GSS_KRB5_TOK_HDR_LEN + headskip, movelen);
        buf->head[0].iov_len -= GSS_KRB5_TOK_HDR_LEN + headskip;
-       buf->len -= GSS_KRB5_TOK_HDR_LEN + headskip;
+       buf->len = len - GSS_KRB5_TOK_HDR_LEN + headskip;
 
        /* Trim off the trailing "extra count" and checksum blob */
-       buf->len -= ec + GSS_KRB5_TOK_HDR_LEN + tailskip;
+       xdr_buf_trim(buf, ec + GSS_KRB5_TOK_HDR_LEN + tailskip);
 
+       *align = XDR_QUADLEN(GSS_KRB5_TOK_HDR_LEN + headskip);
+       *slack = *align + XDR_QUADLEN(ec + GSS_KRB5_TOK_HDR_LEN + tailskip);
        return GSS_S_COMPLETE;
 }
 
@@ -603,7 +614,8 @@ gss_wrap_kerberos(struct gss_ctx *gctx, int offset,
 }
 
 u32
-gss_unwrap_kerberos(struct gss_ctx *gctx, int offset, struct xdr_buf *buf)
+gss_unwrap_kerberos(struct gss_ctx *gctx, int offset,
+                   int len, struct xdr_buf *buf)
 {
        struct krb5_ctx *kctx = gctx->internal_ctx_id;
 
@@ -613,9 +625,11 @@ gss_unwrap_kerberos(struct gss_ctx *gctx, int offset, struct xdr_buf *buf)
        case ENCTYPE_DES_CBC_RAW:
        case ENCTYPE_DES3_CBC_RAW:
        case ENCTYPE_ARCFOUR_HMAC:
-               return gss_unwrap_kerberos_v1(kctx, offset, buf);
+               return gss_unwrap_kerberos_v1(kctx, offset, len, buf,
+                                             &gctx->slack, &gctx->align);
        case ENCTYPE_AES128_CTS_HMAC_SHA1_96:
        case ENCTYPE_AES256_CTS_HMAC_SHA1_96:
-               return gss_unwrap_kerberos_v2(kctx, offset, buf);
+               return gss_unwrap_kerberos_v2(kctx, offset, len, buf,
+                                             &gctx->slack, &gctx->align);
        }
 }
index db550bf..69316ab 100644 (file)
@@ -411,10 +411,11 @@ gss_wrap(struct gss_ctx   *ctx_id,
 u32
 gss_unwrap(struct gss_ctx      *ctx_id,
           int                  offset,
+          int                  len,
           struct xdr_buf       *buf)
 {
        return ctx_id->mech_type->gm_ops
-               ->gss_unwrap(ctx_id, offset, buf);
+               ->gss_unwrap(ctx_id, offset, len, buf);
 }
 
 
index 54ae5be..50d93c4 100644 (file)
@@ -906,7 +906,7 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g
        if (svc_getnl(&buf->head[0]) != seq)
                goto out;
        /* trim off the mic and padding at the end before returning */
-       buf->len -= 4 + round_up_to_quad(mic.len);
+       xdr_buf_trim(buf, round_up_to_quad(mic.len) + 4);
        stat = 0;
 out:
        kfree(mic.data);
@@ -934,7 +934,7 @@ static int
 unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
 {
        u32 priv_len, maj_stat;
-       int pad, saved_len, remaining_len, offset;
+       int pad, remaining_len, offset;
 
        clear_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
 
@@ -954,12 +954,8 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
        buf->len -= pad;
        fix_priv_head(buf, pad);
 
-       /* Maybe it would be better to give gss_unwrap a length parameter: */
-       saved_len = buf->len;
-       buf->len = priv_len;
-       maj_stat = gss_unwrap(ctx, 0, buf);
+       maj_stat = gss_unwrap(ctx, 0, priv_len, buf);
        pad = priv_len - buf->len;
-       buf->len = saved_len;
        buf->len -= pad;
        /* The upper layers assume the buffer is aligned on 4-byte boundaries.
         * In the krb5p case, at least, the data ends up offset, so we need to
index 8350d3a..61b21da 100644 (file)
@@ -889,7 +889,9 @@ static void rpc_free_client_work(struct work_struct *work)
         * here.
         */
        rpc_clnt_debugfs_unregister(clnt);
+       rpc_free_clid(clnt);
        rpc_clnt_remove_pipedir(clnt);
+       xprt_put(rcu_dereference_raw(clnt->cl_xprt));
 
        kfree(clnt);
        rpciod_down();
@@ -907,10 +909,8 @@ rpc_free_client(struct rpc_clnt *clnt)
        rpc_unregister_client(clnt);
        rpc_free_iostats(clnt->cl_metrics);
        clnt->cl_metrics = NULL;
-       xprt_put(rcu_dereference_raw(clnt->cl_xprt));
        xprt_iter_destroy(&clnt->cl_xpi);
        put_cred(clnt->cl_cred);
-       rpc_free_clid(clnt);
 
        INIT_WORK(&clnt->cl_work, rpc_free_client_work);
        schedule_work(&clnt->cl_work);
@@ -2433,6 +2433,11 @@ rpc_check_timeout(struct rpc_task *task)
 {
        struct rpc_clnt *clnt = task->tk_client;
 
+       if (RPC_SIGNALLED(task)) {
+               rpc_call_rpcerror(task, -ERESTARTSYS);
+               return;
+       }
+
        if (xprt_adjust_timeout(task->tk_rqstp) == 0)
                return;
 
index 15b58c5..6f7d82f 100644 (file)
@@ -1150,6 +1150,47 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
 }
 EXPORT_SYMBOL_GPL(xdr_buf_subsegment);
 
+/**
+ * xdr_buf_trim - lop at most "len" bytes off the end of "buf"
+ * @buf: buf to be trimmed
+ * @len: number of bytes to reduce "buf" by
+ *
+ * Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note
+ * that it's possible that we'll trim less than that amount if the xdr_buf is
+ * too small, or if (for instance) it's all in the head and the parser has
+ * already read too far into it.
+ */
+void xdr_buf_trim(struct xdr_buf *buf, unsigned int len)
+{
+       size_t cur;
+       unsigned int trim = len;
+
+       if (buf->tail[0].iov_len) {
+               cur = min_t(size_t, buf->tail[0].iov_len, trim);
+               buf->tail[0].iov_len -= cur;
+               trim -= cur;
+               if (!trim)
+                       goto fix_len;
+       }
+
+       if (buf->page_len) {
+               cur = min_t(unsigned int, buf->page_len, trim);
+               buf->page_len -= cur;
+               trim -= cur;
+               if (!trim)
+                       goto fix_len;
+       }
+
+       if (buf->head[0].iov_len) {
+               cur = min_t(size_t, buf->head[0].iov_len, trim);
+               buf->head[0].iov_len -= cur;
+               trim -= cur;
+       }
+fix_len:
+       buf->len -= (len - trim);
+}
+EXPORT_SYMBOL_GPL(xdr_buf_trim);
+
 static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len)
 {
        unsigned int this_len;
index 8746660..e370ad0 100644 (file)
@@ -1739,22 +1739,21 @@ static int tipc_sk_anc_data_recv(struct msghdr *m, struct sk_buff *skb,
        return 0;
 }
 
-static void tipc_sk_send_ack(struct tipc_sock *tsk)
+static struct sk_buff *tipc_sk_build_ack(struct tipc_sock *tsk)
 {
        struct sock *sk = &tsk->sk;
-       struct net *net = sock_net(sk);
        struct sk_buff *skb = NULL;
        struct tipc_msg *msg;
        u32 peer_port = tsk_peer_port(tsk);
        u32 dnode = tsk_peer_node(tsk);
 
        if (!tipc_sk_connected(sk))
-               return;
+               return NULL;
        skb = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0,
                              dnode, tsk_own_node(tsk), peer_port,
                              tsk->portid, TIPC_OK);
        if (!skb)
-               return;
+               return NULL;
        msg = buf_msg(skb);
        msg_set_conn_ack(msg, tsk->rcv_unacked);
        tsk->rcv_unacked = 0;
@@ -1764,7 +1763,19 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk)
                tsk->rcv_win = tsk_adv_blocks(tsk->sk.sk_rcvbuf);
                msg_set_adv_win(msg, tsk->rcv_win);
        }
-       tipc_node_xmit_skb(net, skb, dnode, msg_link_selector(msg));
+       return skb;
+}
+
+static void tipc_sk_send_ack(struct tipc_sock *tsk)
+{
+       struct sk_buff *skb;
+
+       skb = tipc_sk_build_ack(tsk);
+       if (!skb)
+               return;
+
+       tipc_node_xmit_skb(sock_net(&tsk->sk), skb, tsk_peer_node(tsk),
+                          msg_link_selector(buf_msg(skb)));
 }
 
 static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
@@ -1938,7 +1949,6 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m,
        bool peek = flags & MSG_PEEK;
        int offset, required, copy, copied = 0;
        int hlen, dlen, err, rc;
-       bool ack = false;
        long timeout;
 
        /* Catch invalid receive attempts */
@@ -1983,7 +1993,6 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m,
 
                /* Copy data if msg ok, otherwise return error/partial data */
                if (likely(!err)) {
-                       ack = msg_ack_required(hdr);
                        offset = skb_cb->bytes_read;
                        copy = min_t(int, dlen - offset, buflen - copied);
                        rc = skb_copy_datagram_msg(skb, hlen + offset, m, copy);
@@ -2011,7 +2020,7 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m,
 
                /* Send connection flow control advertisement when applicable */
                tsk->rcv_unacked += tsk_inc(tsk, hlen + dlen);
-               if (ack || tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE)
+               if (tsk->rcv_unacked >= tsk->rcv_win / TIPC_ACK_RATE)
                        tipc_sk_send_ack(tsk);
 
                /* Exit if all requested data or FIN/error received */
@@ -2105,9 +2114,11 @@ static void tipc_sk_proto_rcv(struct sock *sk,
  * tipc_sk_filter_connect - check incoming message for a connection-based socket
  * @tsk: TIPC socket
  * @skb: pointer to message buffer.
+ * @xmitq: for Nagle ACK if any
  * Returns true if message should be added to receive queue, false otherwise
  */
-static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
+static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,
+                                  struct sk_buff_head *xmitq)
 {
        struct sock *sk = &tsk->sk;
        struct net *net = sock_net(sk);
@@ -2171,8 +2182,17 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
                if (!skb_queue_empty(&sk->sk_write_queue))
                        tipc_sk_push_backlog(tsk);
                /* Accept only connection-based messages sent by peer */
-               if (likely(con_msg && !err && pport == oport && pnode == onode))
+               if (likely(con_msg && !err && pport == oport &&
+                          pnode == onode)) {
+                       if (msg_ack_required(hdr)) {
+                               struct sk_buff *skb;
+
+                               skb = tipc_sk_build_ack(tsk);
+                               if (skb)
+                                       __skb_queue_tail(xmitq, skb);
+                       }
                        return true;
+               }
                if (!tsk_peer_msg(tsk, hdr))
                        return false;
                if (!err)
@@ -2267,7 +2287,7 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,
        while ((skb = __skb_dequeue(&inputq))) {
                hdr = buf_msg(skb);
                limit = rcvbuf_limit(sk, skb);
-               if ((sk_conn && !tipc_sk_filter_connect(tsk, skb)) ||
+               if ((sk_conn && !tipc_sk_filter_connect(tsk, skb, xmitq)) ||
                    (!sk_conn && msg_connected(hdr)) ||
                    (!grp && msg_in_group(hdr)))
                        err = TIPC_ERR_NO_PORT;
index aa015c2..6ebbec1 100644 (file)
@@ -96,6 +96,16 @@ void tipc_sub_get(struct tipc_subscription *subscription);
                (swap_ ? swab32(val__) : val__);                        \
        })
 
+/* tipc_sub_write - write val_ to field_ of struct sub_ in user endian format
+ */
+#define tipc_sub_write(sub_, field_, val_)                             \
+       ({                                                              \
+               struct tipc_subscr *sub__ = sub_;                       \
+               u32 val__ = val_;                                       \
+               int swap_ = !((sub__)->filter & TIPC_FILTER_MASK);      \
+               (sub__)->field_ = swap_ ? swab32(val__) : val__;        \
+       })
+
 /* tipc_evt_write - write val_ to field_ of struct evt_ in user endian format
  */
 #define tipc_evt_write(evt_, field_, val_)                             \
index 73dbed0..446af7b 100644 (file)
@@ -237,8 +237,8 @@ static void tipc_conn_delete_sub(struct tipc_conn *con, struct tipc_subscr *s)
                if (!s || !memcmp(s, &sub->evt.s, sizeof(*s))) {
                        tipc_sub_unsubscribe(sub);
                        atomic_dec(&tn->subscription_count);
-               } else if (s) {
-                       break;
+                       if (s)
+                               break;
                }
        }
        spin_unlock_bh(&con->sub_lock);
@@ -362,9 +362,10 @@ static int tipc_conn_rcv_sub(struct tipc_topsrv *srv,
 {
        struct tipc_net *tn = tipc_net(srv->net);
        struct tipc_subscription *sub;
+       u32 s_filter = tipc_sub_read(s, filter);
 
-       if (tipc_sub_read(s, filter) & TIPC_SUB_CANCEL) {
-               s->filter &= __constant_ntohl(~TIPC_SUB_CANCEL);
+       if (s_filter & TIPC_SUB_CANCEL) {
+               tipc_sub_write(s, filter, s_filter & ~TIPC_SUB_CANCEL);
                tipc_conn_delete_sub(con, s);
                return 0;
        }
@@ -400,7 +401,9 @@ static int tipc_conn_rcv_from_sock(struct tipc_conn *con)
                return -EWOULDBLOCK;
        if (ret == sizeof(s)) {
                read_lock_bh(&sk->sk_callback_lock);
-               ret = tipc_conn_rcv_sub(srv, con, &s);
+               /* RACE: the connection can be closed in the meantime */
+               if (likely(connected(con)))
+                       ret = tipc_conn_rcv_sub(srv, con, &s);
                read_unlock_bh(&sk->sk_callback_lock);
                if (!ret)
                        return 0;
index 587b68b..430a4b7 100644 (file)
@@ -15,8 +15,6 @@
 #define MAX_INDEX 64
 #define MAX_STARS 38
 
-char bpf_log_buf[BPF_LOG_BUF_SIZE];
-
 static void stars(char *str, long val, long max, int width)
 {
        int i;
index 280741f..f6a3ecf 100644 (file)
@@ -454,7 +454,7 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
         */
        error = aa_may_manage_policy(label, ns, mask);
        if (error)
-               return error;
+               goto end_section;
 
        data = aa_simple_write_to_buffer(buf, size, size, pos);
        error = PTR_ERR(data);
@@ -462,6 +462,7 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
                error = aa_replace_profiles(ns, label, mask, data);
                aa_put_loaddata(data);
        }
+end_section:
        end_current_label_crit_section(label);
 
        return error;
index 5a98661..5977325 100644 (file)
@@ -197,8 +197,9 @@ int aa_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
        rule->label = aa_label_parse(&root_ns->unconfined->label, rulestr,
                                     GFP_KERNEL, true, false);
        if (IS_ERR(rule->label)) {
+               int err = PTR_ERR(rule->label);
                aa_audit_rule_free(rule);
-               return PTR_ERR(rule->label);
+               return err;
        }
 
        *vrule = rule;
index 6ceb74e..a84ef03 100644 (file)
@@ -1328,6 +1328,7 @@ int aa_change_profile(const char *fqname, int flags)
                ctx->nnp = aa_get_label(label);
 
        if (!fqname || !*fqname) {
+               aa_put_label(label);
                AA_DEBUG("no profile name");
                return -EINVAL;
        }
@@ -1346,8 +1347,6 @@ int aa_change_profile(const char *fqname, int flags)
                        op = OP_CHANGE_PROFILE;
        }
 
-       label = aa_get_current_label();
-
        if (*fqname == '&') {
                stack = true;
                /* don't have label_parse() do stacking */
index 3568285..764b896 100644 (file)
@@ -73,7 +73,7 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
 {
        long rc;
        const char *algo;
-       struct crypto_shash **tfm;
+       struct crypto_shash **tfm, *tmp_tfm;
        struct shash_desc *desc;
 
        if (type == EVM_XATTR_HMAC) {
@@ -91,31 +91,31 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
                algo = hash_algo_name[hash_algo];
        }
 
-       if (*tfm == NULL) {
-               mutex_lock(&mutex);
-               if (*tfm)
-                       goto out;
-               *tfm = crypto_alloc_shash(algo, 0, CRYPTO_NOLOAD);
-               if (IS_ERR(*tfm)) {
-                       rc = PTR_ERR(*tfm);
-                       pr_err("Can not allocate %s (reason: %ld)\n", algo, rc);
-                       *tfm = NULL;
+       if (*tfm)
+               goto alloc;
+       mutex_lock(&mutex);
+       if (*tfm)
+               goto unlock;
+
+       tmp_tfm = crypto_alloc_shash(algo, 0, CRYPTO_NOLOAD);
+       if (IS_ERR(tmp_tfm)) {
+               pr_err("Can not allocate %s (reason: %ld)\n", algo,
+                      PTR_ERR(tmp_tfm));
+               mutex_unlock(&mutex);
+               return ERR_CAST(tmp_tfm);
+       }
+       if (type == EVM_XATTR_HMAC) {
+               rc = crypto_shash_setkey(tmp_tfm, evmkey, evmkey_len);
+               if (rc) {
+                       crypto_free_shash(tmp_tfm);
                        mutex_unlock(&mutex);
                        return ERR_PTR(rc);
                }
-               if (type == EVM_XATTR_HMAC) {
-                       rc = crypto_shash_setkey(*tfm, evmkey, evmkey_len);
-                       if (rc) {
-                               crypto_free_shash(*tfm);
-                               *tfm = NULL;
-                               mutex_unlock(&mutex);
-                               return ERR_PTR(rc);
-                       }
-               }
-out:
-               mutex_unlock(&mutex);
        }
-
+       *tfm = tmp_tfm;
+unlock:
+       mutex_unlock(&mutex);
+alloc:
        desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(*tfm),
                        GFP_KERNEL);
        if (!desc)
@@ -207,7 +207,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
        data->hdr.length = crypto_shash_digestsize(desc->tfm);
 
        error = -ENODATA;
-       list_for_each_entry_rcu(xattr, &evm_config_xattrnames, list) {
+       list_for_each_entry_lockless(xattr, &evm_config_xattrnames, list) {
                bool is_ima = false;
 
                if (strcmp(xattr->name, XATTR_NAME_IMA) == 0)
index d361d7f..0d36259 100644 (file)
@@ -97,7 +97,7 @@ static int evm_find_protected_xattrs(struct dentry *dentry)
        if (!(inode->i_opflags & IOP_XATTR))
                return -EOPNOTSUPP;
 
-       list_for_each_entry_rcu(xattr, &evm_config_xattrnames, list) {
+       list_for_each_entry_lockless(xattr, &evm_config_xattrnames, list) {
                error = __vfs_getxattr(dentry, inode, xattr->name, NULL, 0);
                if (error < 0) {
                        if (error == -ENODATA)
@@ -228,7 +228,7 @@ static int evm_protected_xattr(const char *req_xattr_name)
        struct xattr_list *xattr;
 
        namelen = strlen(req_xattr_name);
-       list_for_each_entry_rcu(xattr, &evm_config_xattrnames, list) {
+       list_for_each_entry_lockless(xattr, &evm_config_xattrnames, list) {
                if ((strlen(xattr->name) == namelen)
                    && (strncmp(req_xattr_name, xattr->name, namelen) == 0)) {
                        found = 1;
index 39ad103..cfc3075 100644 (file)
@@ -232,7 +232,14 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
                goto out;
        }
 
-       /* Guard against races in evm_read_xattrs */
+       /*
+        * xattr_list_mutex guards against races in evm_read_xattrs().
+        * Entries are only added to the evm_config_xattrnames list
+        * and never deleted. Therefore, the list is traversed
+        * using list_for_each_entry_lockless() without holding
+        * the mutex in evm_calc_hmac_or_hash(), evm_find_protected_xattrs()
+        * and evm_protected_xattr().
+        */
        mutex_lock(&xattr_list_mutex);
        list_for_each_entry(tmp, &evm_config_xattrnames, list) {
                if (strcmp(xattr->name, tmp->name) == 0) {
index 423c84f..88b5e28 100644 (file)
@@ -411,7 +411,7 @@ int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash)
        loff_t i_size;
        int rc;
        struct file *f = file;
-       bool new_file_instance = false, modified_flags = false;
+       bool new_file_instance = false, modified_mode = false;
 
        /*
         * For consistency, fail file's opened with the O_DIRECT flag on
@@ -431,13 +431,13 @@ int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash)
                f = dentry_open(&file->f_path, flags, file->f_cred);
                if (IS_ERR(f)) {
                        /*
-                        * Cannot open the file again, lets modify f_flags
+                        * Cannot open the file again, lets modify f_mode
                         * of original and continue
                         */
                        pr_info_ratelimited("Unable to reopen file for reading.\n");
                        f = file;
-                       f->f_flags |= FMODE_READ;
-                       modified_flags = true;
+                       f->f_mode |= FMODE_READ;
+                       modified_mode = true;
                } else {
                        new_file_instance = true;
                }
@@ -455,8 +455,8 @@ int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash)
 out:
        if (new_file_instance)
                fput(f);
-       else if (modified_flags)
-               f->f_flags &= ~FMODE_READ;
+       else if (modified_mode)
+               f->f_mode &= ~FMODE_READ;
        return rc;
 }
 
index a71e822..3efc830 100644 (file)
@@ -338,8 +338,7 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
                integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL,
                                    "policy_update", "signed policy required",
                                    1, 0);
-               if (ima_appraise & IMA_APPRAISE_ENFORCE)
-                       result = -EACCES;
+               result = -EACCES;
        } else {
                result = ima_parse_add_rule(data);
        }
index 872a852..d531e1b 100644 (file)
@@ -433,6 +433,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 
  no_delta_check:
        if (runtime->status->hw_ptr == new_hw_ptr) {
+               runtime->hw_ptr_jiffies = curr_jiffies;
                update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
                return 0;
        }
index 20dd08e..2a688b7 100644 (file)
@@ -120,6 +120,17 @@ static void snd_rawmidi_input_event_work(struct work_struct *work)
                runtime->event(runtime->substream);
 }
 
+/* buffer refcount management: call with runtime->lock held */
+static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime)
+{
+       runtime->buffer_ref++;
+}
+
+static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime)
+{
+       runtime->buffer_ref--;
+}
+
 static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
 {
        struct snd_rawmidi_runtime *runtime;
@@ -669,6 +680,11 @@ static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime,
                if (!newbuf)
                        return -ENOMEM;
                spin_lock_irq(&runtime->lock);
+               if (runtime->buffer_ref) {
+                       spin_unlock_irq(&runtime->lock);
+                       kvfree(newbuf);
+                       return -EBUSY;
+               }
                oldbuf = runtime->buffer;
                runtime->buffer = newbuf;
                runtime->buffer_size = params->buffer_size;
@@ -1019,8 +1035,10 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
        long result = 0, count1;
        struct snd_rawmidi_runtime *runtime = substream->runtime;
        unsigned long appl_ptr;
+       int err = 0;
 
        spin_lock_irqsave(&runtime->lock, flags);
+       snd_rawmidi_buffer_ref(runtime);
        while (count > 0 && runtime->avail) {
                count1 = runtime->buffer_size - runtime->appl_ptr;
                if (count1 > count)
@@ -1039,16 +1057,19 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
                if (userbuf) {
                        spin_unlock_irqrestore(&runtime->lock, flags);
                        if (copy_to_user(userbuf + result,
-                                        runtime->buffer + appl_ptr, count1)) {
-                               return result > 0 ? result : -EFAULT;
-                       }
+                                        runtime->buffer + appl_ptr, count1))
+                               err = -EFAULT;
                        spin_lock_irqsave(&runtime->lock, flags);
+                       if (err)
+                               goto out;
                }
                result += count1;
                count -= count1;
        }
+ out:
+       snd_rawmidi_buffer_unref(runtime);
        spin_unlock_irqrestore(&runtime->lock, flags);
-       return result;
+       return result > 0 ? result : err;
 }
 
 long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
@@ -1342,6 +1363,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
                        return -EAGAIN;
                }
        }
+       snd_rawmidi_buffer_ref(runtime);
        while (count > 0 && runtime->avail > 0) {
                count1 = runtime->buffer_size - runtime->appl_ptr;
                if (count1 > count)
@@ -1373,6 +1395,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
        }
       __end:
        count1 = runtime->avail < runtime->buffer_size;
+       snd_rawmidi_buffer_unref(runtime);
        spin_unlock_irqrestore(&runtime->lock, flags);
        if (count1)
                snd_rawmidi_output_trigger(substream, 1);
index 16c7f66..26e7cb5 100644 (file)
@@ -66,8 +66,7 @@ TRACE_EVENT(amdtp_packet,
                __entry->irq,
                __entry->index,
                __print_array(__get_dynamic_array(cip_header),
-                             __get_dynamic_array_len(cip_header),
-                             sizeof(u8)))
+                             __get_dynamic_array_len(cip_header), 1))
 );
 
 #endif
index c16f639..041d2a3 100644 (file)
@@ -2457,6 +2457,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
        SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
        SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950),
+       SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
@@ -2472,6 +2473,9 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
        SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
        SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
        SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
@@ -5856,6 +5860,15 @@ static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
        }
 }
 
+static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
+                                     const struct hda_fixup *fix, int action)
+{
+       if (action != HDA_FIXUP_ACT_PRE_PROBE)
+               return;
+
+       codec->power_save_node = 1;
+}
+
 /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
                                    const struct hda_fixup *fix, int action)
@@ -5960,6 +5973,7 @@ enum {
        ALC269_FIXUP_HP_LINE1_MIC1_LED,
        ALC269_FIXUP_INV_DMIC,
        ALC269_FIXUP_LENOVO_DOCK,
+       ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
        ALC269_FIXUP_NO_SHUTUP,
        ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
        ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
@@ -6045,6 +6059,7 @@ enum {
        ALC233_FIXUP_ACER_HEADSET_MIC,
        ALC294_FIXUP_LENOVO_MIC_LOCATION,
        ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
+       ALC225_FIXUP_S3_POP_NOISE,
        ALC700_FIXUP_INTEL_REFERENCE,
        ALC274_FIXUP_DELL_BIND_DACS,
        ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
@@ -6080,9 +6095,12 @@ enum {
        ALC294_FIXUP_ASUS_DUAL_SPK,
        ALC285_FIXUP_THINKPAD_HEADSET_JACK,
        ALC294_FIXUP_ASUS_HPE,
+       ALC294_FIXUP_ASUS_COEF_1B,
        ALC285_FIXUP_HP_GPIO_LED,
        ALC285_FIXUP_HP_MUTE_LED,
        ALC236_FIXUP_HP_MUTE_LED,
+       ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
+       ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -6280,6 +6298,12 @@ static const struct hda_fixup alc269_fixups[] = {
                .chained = true,
                .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
        },
+       [ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc269_fixup_limit_int_mic_boost,
+               .chained = true,
+               .chain_id = ALC269_FIXUP_LENOVO_DOCK,
+       },
        [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
@@ -6932,6 +6956,12 @@ static const struct hda_fixup alc269_fixups[] = {
                        { }
                },
                .chained = true,
+               .chain_id = ALC225_FIXUP_S3_POP_NOISE
+       },
+       [ALC225_FIXUP_S3_POP_NOISE] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc225_fixup_s3_pop_noise,
+               .chained = true,
                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
        },
        [ALC700_FIXUP_INTEL_REFERENCE] = {
@@ -7204,6 +7234,17 @@ static const struct hda_fixup alc269_fixups[] = {
                .chained = true,
                .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
        },
+       [ALC294_FIXUP_ASUS_COEF_1B] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       /* Set bit 10 to correct noisy output after reboot from
+                        * Windows 10 (due to pop noise reduction?)
+                        */
+                       { 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
+                       { 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
+                       { }
+               },
+       },
        [ALC285_FIXUP_HP_GPIO_LED] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc285_fixup_hp_gpio_led,
@@ -7216,6 +7257,22 @@ static const struct hda_fixup alc269_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc236_fixup_hp_mute_led,
        },
+       [ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
+                       { }
+               },
+       },
+       [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
+                       { }
+               },
+               .chained = true,
+               .chain_id = ALC269_FIXUP_HEADSET_MODE
+       },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7383,8 +7440,10 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
        SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
        SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
+       SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
        SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
+       SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
        SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
        SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -7410,6 +7469,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
        SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
        SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
+       SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
+       SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
        SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
        SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
        SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
@@ -7426,7 +7487,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
        SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
        SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
-       SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
+       SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
        SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
        SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
        SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
@@ -7565,6 +7626,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
        {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
        {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
        {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
+       {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
        {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
        {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
        {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
@@ -7993,6 +8055,18 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
                {0x12, 0x90a60130},
                {0x17, 0x90170110},
                {0x21, 0x03211020}),
+       SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
+               {0x12, 0x90a60120},
+               {0x17, 0x90170110},
+               {0x21, 0x04211030}),
+       SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
+               {0x12, 0x90a60130},
+               {0x17, 0x90170110},
+               {0x21, 0x03211020}),
+       SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
+               {0x12, 0x90a60130},
+               {0x17, 0x90170110},
+               {0x21, 0x03211020}),
        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
                {0x14, 0x90170110},
                {0x21, 0x04211020}),
@@ -8209,8 +8283,6 @@ static int patch_alc269(struct hda_codec *codec)
                spec->gen.mixer_nid = 0;
                break;
        case 0x10ec0225:
-               codec->power_save_node = 1;
-               /* fall through */
        case 0x10ec0295:
        case 0x10ec0299:
                spec->codec_variant = ALC269_TYPE_ALC225;
index 884d0cd..73e1e54 100644 (file)
@@ -2332,7 +2332,8 @@ static int snd_ice1712_chip_init(struct snd_ice1712 *ice)
        pci_write_config_byte(ice->pci, 0x61, ice->eeprom.data[ICE_EEP1_ACLINK]);
        pci_write_config_byte(ice->pci, 0x62, ice->eeprom.data[ICE_EEP1_I2SID]);
        pci_write_config_byte(ice->pci, 0x63, ice->eeprom.data[ICE_EEP1_SPDIF]);
-       if (ice->eeprom.subvendor != ICE1712_SUBDEVICE_STDSP24) {
+       if (ice->eeprom.subvendor != ICE1712_SUBDEVICE_STDSP24 &&
+           ice->eeprom.subvendor != ICE1712_SUBDEVICE_STAUDIO_ADCIII) {
                ice->gpio.write_mask = ice->eeprom.gpiomask;
                ice->gpio.direction = ice->eeprom.gpiodir;
                snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK,
index 0260c75..bfdc6ad 100644 (file)
@@ -549,6 +549,11 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = {
                .map = trx40_mobo_map,
                .connector_map = trx40_mobo_connector_map,
        },
+       {       /* Asrock TRX40 Creator */
+               .id = USB_ID(0x26ce, 0x0a01),
+               .map = trx40_mobo_map,
+               .connector_map = trx40_mobo_connector_map,
+       },
        { 0 } /* terminator */
 };
 
index a1df4c5..6313c30 100644 (file)
@@ -3563,6 +3563,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
 ALC1220_VB_DESKTOP(0x0414, 0xa002), /* Gigabyte TRX40 Aorus Pro WiFi */
 ALC1220_VB_DESKTOP(0x0db0, 0x0d64), /* MSI TRX40 Creator */
 ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */
+ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
 #undef ALC1220_VB_DESKTOP
 
 #undef USB_DEVICE_VENDOR_SPEC
index 848a4cc..d8a765b 100644 (file)
@@ -1636,13 +1636,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
            && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                msleep(20);
 
-       /* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here,
-        * otherwise requests like get/set frequency return as failed despite
-        * actually succeeding.
+       /* Zoom R16/24, Logitech H650e, Jabra 550a, Kingston HyperX needs a tiny
+        * delay here, otherwise requests like get/set frequency return as
+        * failed despite actually succeeding.
         */
        if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
             chip->usb_id == USB_ID(0x046d, 0x0a46) ||
-            chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
+            chip->usb_id == USB_ID(0x0b0e, 0x0349) ||
+            chip->usb_id == USB_ID(0x0951, 0x16ad)) &&
            (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                usleep_range(1000, 2000);
 }
index 001076c..0efaf45 100644 (file)
@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)
                pr_err("Failed to apply a boot config magic: %d\n", ret);
                goto out;
        }
+       ret = 0;
 out:
        close(fd);
        free(data);
index f3f3c3f..48a9c7c 100644 (file)
@@ -148,11 +148,11 @@ struct pt_regs;
 #define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[4])
 #define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[5])
 #define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[6])
-#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), grps[14])
+#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[14])
 #define PT_REGS_FP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[11])
 #define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[2])
 #define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), gprs[15])
-#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), pdw.addr)
+#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_S390 *)(x), psw.addr)
 
 #elif defined(bpf_target_arm)
 
index 56d80ad..6b9dce4 100644 (file)
@@ -217,6 +217,14 @@ void test_mmap(void)
 
        munmap(tmp2, 4 * page_size);
 
+       /* map all 4 pages, but with pg_off=1 page, should fail */
+       tmp1 = mmap(NULL, 4 * page_size, PROT_READ, MAP_SHARED | MAP_FIXED,
+                   data_map_fd, page_size /* initial page shift */);
+       if (CHECK(tmp1 != MAP_FAILED, "adv_mmap7", "unexpected success")) {
+               munmap(tmp1, 4 * page_size);
+               goto cleanup;
+       }
+
        tmp1 = mmap(NULL, map_sz, PROT_READ, MAP_SHARED, data_map_fd, 0);
        if (CHECK(tmp1 == MAP_FAILED, "last_mmap", "failed %d\n", errno))
                goto cleanup;
index 56a50b2..abb7344 100644 (file)
@@ -30,13 +30,13 @@ int prog3(struct bpf_raw_tracepoint_args *ctx)
 SEC("fentry/__set_task_comm")
 int BPF_PROG(prog4, struct task_struct *tsk, const char *buf, bool exec)
 {
-       return !tsk;
+       return 0;
 }
 
 SEC("fexit/__set_task_comm")
 int BPF_PROG(prog5, struct task_struct *tsk, const char *buf, bool exec)
 {
-       return !tsk;
+       return 0;
 }
 
 char _license[] SEC("license") = "GPL";
index cd5e1f6..909da9c 100644 (file)
@@ -351,6 +351,7 @@ static int test_alloc_errors(char *heap_name)
        }
 
        printf("Expected error checking passed\n");
+       ret = 0;
 out:
        if (dmabuf_fd >= 0)
                close(dmabuf_fd);
index cbd1743..2b82c80 100644 (file)
@@ -17,7 +17,14 @@ unsup() { #msg
     exit_unsupported
 }
 
-modprobe $MOD || unsup "$MOD module not available"
+unres() { #msg
+    reset_tracer
+    rmmod $MOD || true
+    echo $1
+    exit_unresolved
+}
+
+modprobe $MOD || unres "$MOD module not available"
 rmmod $MOD
 
 grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled"
index b728c0a..42f4f49 100644 (file)
@@ -54,6 +54,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test
 TEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
 TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
 TEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test
+TEST_GEN_PROGS_x86_64 += x86_64/debug_regs
 TEST_GEN_PROGS_x86_64 += clear_dirty_log_test
 TEST_GEN_PROGS_x86_64 += demand_paging_test
 TEST_GEN_PROGS_x86_64 += dirty_log_test
index a99b875..92e184a 100644 (file)
@@ -143,6 +143,8 @@ struct kvm_run *vcpu_state(struct kvm_vm *vm, uint32_t vcpuid);
 void vcpu_run(struct kvm_vm *vm, uint32_t vcpuid);
 int _vcpu_run(struct kvm_vm *vm, uint32_t vcpuid);
 void vcpu_run_complete_io(struct kvm_vm *vm, uint32_t vcpuid);
+void vcpu_set_guest_debug(struct kvm_vm *vm, uint32_t vcpuid,
+                         struct kvm_guest_debug *debug);
 void vcpu_set_mp_state(struct kvm_vm *vm, uint32_t vcpuid,
                       struct kvm_mp_state *mp_state);
 void vcpu_regs_get(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_regs *regs);
index 8a3523d..9622431 100644 (file)
@@ -1201,6 +1201,15 @@ void vcpu_run_complete_io(struct kvm_vm *vm, uint32_t vcpuid)
                    ret, errno);
 }
 
+void vcpu_set_guest_debug(struct kvm_vm *vm, uint32_t vcpuid,
+                         struct kvm_guest_debug *debug)
+{
+       struct vcpu *vcpu = vcpu_find(vm, vcpuid);
+       int ret = ioctl(vcpu->fd, KVM_SET_GUEST_DEBUG, debug);
+
+       TEST_ASSERT(ret == 0, "KVM_SET_GUEST_DEBUG failed: %d", ret);
+}
+
 /*
  * VM VCPU Set MP State
  *
diff --git a/tools/testing/selftests/kvm/x86_64/debug_regs.c b/tools/testing/selftests/kvm/x86_64/debug_regs.c
new file mode 100644 (file)
index 0000000..8162c58
--- /dev/null
@@ -0,0 +1,202 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * KVM guest debug register tests
+ *
+ * Copyright (C) 2020, Red Hat, Inc.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "kvm_util.h"
+#include "processor.h"
+
+#define VCPU_ID 0
+
+#define DR6_BD         (1 << 13)
+#define DR7_GD         (1 << 13)
+
+/* For testing data access debug BP */
+uint32_t guest_value;
+
+extern unsigned char sw_bp, hw_bp, write_data, ss_start, bd_start;
+
+static void guest_code(void)
+{
+       /*
+        * Software BP tests.
+        *
+        * NOTE: sw_bp need to be before the cmd here, because int3 is an
+        * exception rather than a normal trap for KVM_SET_GUEST_DEBUG (we
+        * capture it using the vcpu exception bitmap).
+        */
+       asm volatile("sw_bp: int3");
+
+       /* Hardware instruction BP test */
+       asm volatile("hw_bp: nop");
+
+       /* Hardware data BP test */
+       asm volatile("mov $1234,%%rax;\n\t"
+                    "mov %%rax,%0;\n\t write_data:"
+                    : "=m" (guest_value) : : "rax");
+
+       /* Single step test, covers 2 basic instructions and 2 emulated */
+       asm volatile("ss_start: "
+                    "xor %%rax,%%rax\n\t"
+                    "cpuid\n\t"
+                    "movl $0x1a0,%%ecx\n\t"
+                    "rdmsr\n\t"
+                    : : : "rax", "ecx");
+
+       /* DR6.BD test */
+       asm volatile("bd_start: mov %%dr0, %%rax" : : : "rax");
+       GUEST_DONE();
+}
+
+#define  CLEAR_DEBUG()  memset(&debug, 0, sizeof(debug))
+#define  APPLY_DEBUG()  vcpu_set_guest_debug(vm, VCPU_ID, &debug)
+#define  CAST_TO_RIP(v)  ((unsigned long long)&(v))
+#define  SET_RIP(v)  do {                              \
+               vcpu_regs_get(vm, VCPU_ID, &regs);      \
+               regs.rip = (v);                         \
+               vcpu_regs_set(vm, VCPU_ID, &regs);      \
+       } while (0)
+#define  MOVE_RIP(v)  SET_RIP(regs.rip + (v));
+
+int main(void)
+{
+       struct kvm_guest_debug debug;
+       unsigned long long target_dr6, target_rip;
+       struct kvm_regs regs;
+       struct kvm_run *run;
+       struct kvm_vm *vm;
+       struct ucall uc;
+       uint64_t cmd;
+       int i;
+       /* Instruction lengths starting at ss_start */
+       int ss_size[4] = {
+               3,              /* xor */
+               2,              /* cpuid */
+               5,              /* mov */
+               2,              /* rdmsr */
+       };
+
+       if (!kvm_check_cap(KVM_CAP_SET_GUEST_DEBUG)) {
+               print_skip("KVM_CAP_SET_GUEST_DEBUG not supported");
+               return 0;
+       }
+
+       vm = vm_create_default(VCPU_ID, 0, guest_code);
+       vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
+       run = vcpu_state(vm, VCPU_ID);
+
+       /* Test software BPs - int3 */
+       CLEAR_DEBUG();
+       debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP;
+       APPLY_DEBUG();
+       vcpu_run(vm, VCPU_ID);
+       TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
+                   run->debug.arch.exception == BP_VECTOR &&
+                   run->debug.arch.pc == CAST_TO_RIP(sw_bp),
+                   "INT3: exit %d exception %d rip 0x%llx (should be 0x%llx)",
+                   run->exit_reason, run->debug.arch.exception,
+                   run->debug.arch.pc, CAST_TO_RIP(sw_bp));
+       MOVE_RIP(1);
+
+       /* Test instruction HW BP over DR[0-3] */
+       for (i = 0; i < 4; i++) {
+               CLEAR_DEBUG();
+               debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW_BP;
+               debug.arch.debugreg[i] = CAST_TO_RIP(hw_bp);
+               debug.arch.debugreg[7] = 0x400 | (1UL << (2*i+1));
+               APPLY_DEBUG();
+               vcpu_run(vm, VCPU_ID);
+               target_dr6 = 0xffff0ff0 | (1UL << i);
+               TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
+                           run->debug.arch.exception == DB_VECTOR &&
+                           run->debug.arch.pc == CAST_TO_RIP(hw_bp) &&
+                           run->debug.arch.dr6 == target_dr6,
+                           "INS_HW_BP (DR%d): exit %d exception %d rip 0x%llx "
+                           "(should be 0x%llx) dr6 0x%llx (should be 0x%llx)",
+                           i, run->exit_reason, run->debug.arch.exception,
+                           run->debug.arch.pc, CAST_TO_RIP(hw_bp),
+                           run->debug.arch.dr6, target_dr6);
+       }
+       /* Skip "nop" */
+       MOVE_RIP(1);
+
+       /* Test data access HW BP over DR[0-3] */
+       for (i = 0; i < 4; i++) {
+               CLEAR_DEBUG();
+               debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW_BP;
+               debug.arch.debugreg[i] = CAST_TO_RIP(guest_value);
+               debug.arch.debugreg[7] = 0x00000400 | (1UL << (2*i+1)) |
+                   (0x000d0000UL << (4*i));
+               APPLY_DEBUG();
+               vcpu_run(vm, VCPU_ID);
+               target_dr6 = 0xffff0ff0 | (1UL << i);
+               TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
+                           run->debug.arch.exception == DB_VECTOR &&
+                           run->debug.arch.pc == CAST_TO_RIP(write_data) &&
+                           run->debug.arch.dr6 == target_dr6,
+                           "DATA_HW_BP (DR%d): exit %d exception %d rip 0x%llx "
+                           "(should be 0x%llx) dr6 0x%llx (should be 0x%llx)",
+                           i, run->exit_reason, run->debug.arch.exception,
+                           run->debug.arch.pc, CAST_TO_RIP(write_data),
+                           run->debug.arch.dr6, target_dr6);
+               /* Rollback the 4-bytes "mov" */
+               MOVE_RIP(-7);
+       }
+       /* Skip the 4-bytes "mov" */
+       MOVE_RIP(7);
+
+       /* Test single step */
+       target_rip = CAST_TO_RIP(ss_start);
+       target_dr6 = 0xffff4ff0ULL;
+       vcpu_regs_get(vm, VCPU_ID, &regs);
+       for (i = 0; i < (sizeof(ss_size) / sizeof(ss_size[0])); i++) {
+               target_rip += ss_size[i];
+               CLEAR_DEBUG();
+               debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP;
+               debug.arch.debugreg[7] = 0x00000400;
+               APPLY_DEBUG();
+               vcpu_run(vm, VCPU_ID);
+               TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
+                           run->debug.arch.exception == DB_VECTOR &&
+                           run->debug.arch.pc == target_rip &&
+                           run->debug.arch.dr6 == target_dr6,
+                           "SINGLE_STEP[%d]: exit %d exception %d rip 0x%llx "
+                           "(should be 0x%llx) dr6 0x%llx (should be 0x%llx)",
+                           i, run->exit_reason, run->debug.arch.exception,
+                           run->debug.arch.pc, target_rip, run->debug.arch.dr6,
+                           target_dr6);
+       }
+
+       /* Finally test global disable */
+       CLEAR_DEBUG();
+       debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW_BP;
+       debug.arch.debugreg[7] = 0x400 | DR7_GD;
+       APPLY_DEBUG();
+       vcpu_run(vm, VCPU_ID);
+       target_dr6 = 0xffff0ff0 | DR6_BD;
+       TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
+                   run->debug.arch.exception == DB_VECTOR &&
+                   run->debug.arch.pc == CAST_TO_RIP(bd_start) &&
+                   run->debug.arch.dr6 == target_dr6,
+                           "DR7.GD: exit %d exception %d rip 0x%llx "
+                           "(should be 0x%llx) dr6 0x%llx (should be 0x%llx)",
+                           run->exit_reason, run->debug.arch.exception,
+                           run->debug.arch.pc, target_rip, run->debug.arch.dr6,
+                           target_dr6);
+
+       /* Disable all debug controls, run to the end */
+       CLEAR_DEBUG();
+       APPLY_DEBUG();
+
+       vcpu_run(vm, VCPU_ID);
+       TEST_ASSERT(run->exit_reason == KVM_EXIT_IO, "KVM_EXIT_IO");
+       cmd = get_ucall(vm, VCPU_ID, &uc);
+       TEST_ASSERT(cmd == UCALL_DONE, "UCALL_DONE");
+
+       kvm_vm_free(vm);
+
+       return 0;
+}
index dadf819..ee64ff8 100755 (executable)
@@ -25,13 +25,13 @@ fi
 # Figure out which test to run from our script name.
 test=$(basename $0 .sh)
 # Look up details about the test from master list of LKDTM tests.
-line=$(egrep '^#?'"$test"'\b' tests.txt)
+line=$(grep -E '^#?'"$test"'\b' tests.txt)
 if [ -z "$line" ]; then
        echo "Skipped: missing test '$test' in tests.txt"
        exit $KSELFTEST_SKIP_TEST
 fi
 # Check that the test is known to LKDTM.
-if ! egrep -q '^'"$test"'$' "$TRIGGER" ; then
+if ! grep -E -q '^'"$test"'$' "$TRIGGER" ; then
        echo "Skipped: test '$test' missing in $TRIGGER!"
        exit $KSELFTEST_SKIP_TEST
 fi
@@ -59,30 +59,32 @@ if [ -z "$expect" ]; then
        expect="call trace:"
 fi
 
-# Clear out dmesg for output reporting
-dmesg -c >/dev/null
-
 # Prepare log for report checking
-LOG=$(mktemp --tmpdir -t lkdtm-XXXXXX)
+LOG=$(mktemp --tmpdir -t lkdtm-log-XXXXXX)
+DMESG=$(mktemp --tmpdir -t lkdtm-dmesg-XXXXXX)
 cleanup() {
-       rm -f "$LOG"
+       rm -f "$LOG" "$DMESG"
 }
 trap cleanup EXIT
 
+# Save existing dmesg so we can detect new content below
+dmesg > "$DMESG"
+
 # Most shells yell about signals and we're expecting the "cat" process
 # to usually be killed by the kernel. So we have to run it in a sub-shell
 # and silence errors.
 ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true
 
 # Record and dump the results
-dmesg -c >"$LOG"
+dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true
+
 cat "$LOG"
 # Check for expected output
-if egrep -qi "$expect" "$LOG" ; then
+if grep -E -qi "$expect" "$LOG" ; then
        echo "$test: saw '$expect': ok"
        exit 0
 else
-       if egrep -qi XFAIL: "$LOG" ; then
+       if grep -E -qi XFAIL: "$LOG" ; then
                echo "$test: saw 'XFAIL': [SKIP]"
                exit $KSELFTEST_SKIP_TEST
        else
index 9172746..15f4f46 100755 (executable)
@@ -30,7 +30,7 @@ ret=0
 
 cleanup()
 {
-       rm -f $out
+       rm -f $err
        ip netns del $ns1
 }
 
index e0d86e1..e3c772c 100644 (file)
@@ -27,7 +27,7 @@
 #define __stack_aligned__      __attribute__((aligned(16)))
 struct cr_clone_arg {
        char stack[128] __stack_aligned__;
-       char stack_ptr[0];
+       char stack_ptr[];
 };
 
 static int child(void *args)
index 74bdb7b..731c1e5 100644 (file)
@@ -259,6 +259,7 @@ static inline bool kvm_kick_many_cpus(const struct cpumask *cpus, bool wait)
 }
 
 bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
+                                struct kvm_vcpu *except,
                                 unsigned long *vcpu_bitmap, cpumask_var_t tmp)
 {
        int i, cpu, me;
@@ -268,7 +269,8 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
        me = get_cpu();
 
        kvm_for_each_vcpu(i, vcpu, kvm) {
-               if (vcpu_bitmap && !test_bit(i, vcpu_bitmap))
+               if ((vcpu_bitmap && !test_bit(i, vcpu_bitmap)) ||
+                   vcpu == except)
                        continue;
 
                kvm_make_request(req, vcpu);
@@ -288,19 +290,25 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
        return called;
 }
 
-bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
+bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
+                                     struct kvm_vcpu *except)
 {
        cpumask_var_t cpus;
        bool called;
 
        zalloc_cpumask_var(&cpus, GFP_ATOMIC);
 
-       called = kvm_make_vcpus_request_mask(kvm, req, NULL, cpus);
+       called = kvm_make_vcpus_request_mask(kvm, req, except, NULL, cpus);
 
        free_cpumask_var(cpus);
        return called;
 }
 
+bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
+{
+       return kvm_make_all_cpus_request_except(kvm, req, NULL);
+}
+
 #ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL
 void kvm_flush_remote_tlbs(struct kvm *kvm)
 {