Merge branches 'arm/exynos', 'arm/renesas', 'arm/rockchip', 'arm/omap', 'arm/mediatek...
authorJoerg Roedel <jroedel@suse.de>
Fri, 1 Sep 2017 09:31:42 +0000 (11:31 +0200)
committerJoerg Roedel <jroedel@suse.de>
Fri, 1 Sep 2017 09:31:42 +0000 (11:31 +0200)
444 files changed:
Documentation/devicetree/bindings/iommu/qcom,iommu.txt [new file with mode: 0644]
Documentation/devicetree/bindings/iommu/rockchip,iommu.txt
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
Documentation/networking/switchdev.txt
Documentation/printk-formats.txt
Documentation/sysctl/net.txt
MAINTAINERS
Makefile
arch/arc/Kconfig
arch/arc/Makefile
arch/arc/boot/dts/axc001.dtsi
arch/arc/boot/dts/axc003.dtsi
arch/arc/boot/dts/axc003_idu.dtsi
arch/arc/boot/dts/axs10x_mb.dtsi
arch/arc/configs/haps_hs_defconfig
arch/arc/configs/haps_hs_smp_defconfig
arch/arc/configs/nps_defconfig
arch/arc/configs/nsim_700_defconfig
arch/arc/configs/nsim_hs_defconfig
arch/arc/configs/nsim_hs_smp_defconfig
arch/arc/configs/nsimosci_defconfig
arch/arc/configs/nsimosci_hs_defconfig
arch/arc/configs/nsimosci_hs_smp_defconfig
arch/arc/configs/tb10x_defconfig
arch/arc/include/asm/cache.h
arch/arc/include/asm/mmu.h
arch/arc/kernel/intc-arcv2.c
arch/arc/kernel/intc-compact.c
arch/arc/mm/cache.c
arch/arc/mm/dma.c
arch/arc/mm/tlb.c
arch/arc/plat-sim/Kconfig [deleted file]
arch/arc/plat-sim/platform.c
arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
arch/arm/boot/dts/imx25.dtsi
arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
arch/arm/boot/dts/imx7d-sdb.dts
arch/arm/boot/dts/sama5d2.dtsi
arch/arm/mach-at91/Kconfig
arch/arm/mach-at91/pm.c
arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
arch/arm64/boot/dts/renesas/salvator-common.dtsi
arch/arm64/include/asm/arch_timer.h
arch/arm64/include/asm/elf.h
arch/arm64/kernel/fpsimd.c
arch/arm64/kernel/head.S
arch/arm64/kernel/kaslr.c
arch/arm64/mm/fault.c
arch/powerpc/Kconfig
arch/powerpc/include/asm/mmu_context.h
arch/powerpc/include/asm/pgtable-be-types.h
arch/powerpc/include/asm/pgtable-types.h
arch/powerpc/kernel/process.c
arch/powerpc/kvm/book3s_64_vio.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S
arch/powerpc/kvm/book3s_xive_template.c
arch/s390/include/asm/pci.h
arch/s390/kvm/sthyi.c
arch/s390/pci/pci.c
arch/sparc/include/asm/page_32.h
arch/sparc/kernel/pci_sun4v.c
arch/sparc/kernel/pcic.c
arch/sparc/lib/multi3.S
arch/x86/Kconfig
arch/x86/crypto/sha1_avx2_x86_64_asm.S
arch/x86/crypto/sha1_ssse3_glue.c
arch/x86/entry/entry_64.S
arch/x86/events/core.c
arch/x86/events/intel/bts.c
arch/x86/events/intel/p4.c
arch/x86/events/intel/rapl.c
arch/x86/events/intel/uncore.c
arch/x86/events/intel/uncore_nhmex.c
arch/x86/events/intel/uncore_snb.c
arch/x86/events/intel/uncore_snbep.c
arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/elf.h
arch/x86/include/asm/fpu/internal.h
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/mmu_context.h
arch/x86/kernel/cpu/aperfmperf.c
arch/x86/kernel/cpu/mcheck/therm_throt.c
arch/x86/kernel/cpu/microcode/core.c
arch/x86/kernel/cpu/mtrr/main.c
arch/x86/kernel/head64.c
arch/x86/kernel/ksysfs.c
arch/x86/kernel/smpboot.c
arch/x86/kvm/cpuid.c
arch/x86/kvm/kvm_cache_regs.h
arch/x86/kvm/mmu.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/mm/mmap.c
arch/x86/platform/uv/tlb_uv.c
block/blk-mq-debugfs.c
block/blk-mq-pci.c
block/blk-mq.c
block/blk-throttle.c
block/bsg-lib.c
drivers/acpi/acpica/nsxfeval.c
drivers/acpi/ec.c
drivers/acpi/internal.h
drivers/acpi/property.c
drivers/acpi/scan.c
drivers/android/binder.c
drivers/block/loop.c
drivers/block/loop.h
drivers/block/virtio_blk.c
drivers/block/xen-blkfront.c
drivers/clocksource/Kconfig
drivers/clocksource/arm_arch_timer.c
drivers/clocksource/em_sti.c
drivers/clocksource/timer-of.c
drivers/cpufreq/intel_pstate.c
drivers/crypto/ixp4xx_crypto.c
drivers/dma/tegra210-adma.c
drivers/gpio/gpio-mvebu.c
drivers/gpio/gpiolib-sysfs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_plane.c
drivers/gpu/drm/i915/gvt/cmd_parser.c
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_render_state.c
drivers/gpu/drm/i915/intel_bios.c
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
drivers/gpu/drm/i915/intel_dsi_vbt.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_lrc.h
drivers/gpu/drm/i915/intel_lspcon.c
drivers/gpu/drm/imx/ipuv3-plane.c
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
drivers/gpu/drm/sun4i/sun4i_drv.c
drivers/gpu/ipu-v3/Kconfig
drivers/i2c/busses/i2c-aspeed.c
drivers/i2c/busses/i2c-designware-platdrv.c
drivers/i2c/busses/i2c-designware-slave.c
drivers/i2c/busses/i2c-simtec.c
drivers/i2c/i2c-core-base.c
drivers/iio/adc/ina2xx-adc.c
drivers/iio/adc/stm32-adc-core.c
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
drivers/iio/imu/adis16480.c
drivers/iio/magnetometer/st_magn_core.c
drivers/iio/pressure/bmp280-core.c
drivers/iio/pressure/bmp280.h
drivers/iio/trigger/stm32-timer-trigger.c
drivers/infiniband/core/device.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/core/verbs.c
drivers/infiniband/hw/cxgb4/mem.c
drivers/infiniband/hw/hns/hns_roce_ah.c
drivers/infiniband/hw/i40iw/i40iw_ctrl.c
drivers/infiniband/hw/i40iw/i40iw_d.h
drivers/infiniband/hw/i40iw/i40iw_puda.c
drivers/infiniband/hw/i40iw/i40iw_status.h
drivers/infiniband/hw/i40iw/i40iw_uk.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
drivers/input/misc/soc_button_array.c
drivers/input/mouse/alps.c
drivers/input/mouse/alps.h
drivers/input/mouse/elan_i2c_core.c
drivers/input/mouse/trackpoint.c
drivers/input/mouse/trackpoint.h
drivers/iommu/Kconfig
drivers/iommu/Makefile
drivers/iommu/amd_iommu.c
drivers/iommu/amd_iommu_init.c
drivers/iommu/amd_iommu_proto.h
drivers/iommu/amd_iommu_types.h
drivers/iommu/amd_iommu_v2.c
drivers/iommu/arm-smmu-regs.h [new file with mode: 0644]
drivers/iommu/arm-smmu.c
drivers/iommu/dmar.c
drivers/iommu/exynos-iommu.c
drivers/iommu/fsl_pamu.c
drivers/iommu/fsl_pamu_domain.c
drivers/iommu/intel-iommu.c
drivers/iommu/intel-svm.c
drivers/iommu/iommu-sysfs.c
drivers/iommu/iommu.c
drivers/iommu/iova.c
drivers/iommu/ipmmu-vmsa.c
drivers/iommu/msm_iommu.c
drivers/iommu/mtk_iommu.c
drivers/iommu/mtk_iommu.h
drivers/iommu/of_iommu.c
drivers/iommu/omap-iommu.c
drivers/iommu/omap-iommu.h
drivers/iommu/qcom_iommu.c [new file with mode: 0644]
drivers/iommu/rockchip-iommu.c
drivers/iommu/s390-iommu.c
drivers/iommu/tegra-gart.c
drivers/iommu/tegra-smmu.c
drivers/irqchip/irq-atmel-aic-common.c
drivers/irqchip/irq-atmel-aic-common.h
drivers/irqchip/irq-atmel-aic.c
drivers/irqchip/irq-atmel-aic5.c
drivers/irqchip/irq-brcmstb-l2.c
drivers/irqchip/irq-gic-v3-its-platform-msi.c
drivers/irqchip/irq-gic-v3-its.c
drivers/irqchip/irq-gic-v3.c
drivers/irqchip/irq-gic.c
drivers/isdn/mISDN/fsm.c
drivers/isdn/mISDN/fsm.h
drivers/isdn/mISDN/layer1.c
drivers/isdn/mISDN/layer2.c
drivers/isdn/mISDN/tei.c
drivers/md/md.c
drivers/md/raid5-cache.c
drivers/memory/atmel-ebi.c
drivers/memory/mtk-smi.c
drivers/mfd/atmel-smc.c
drivers/mfd/da9062-core.c
drivers/mmc/core/block.c
drivers/mtd/nand/atmel/nand-controller.c
drivers/mtd/nand/nandsim.c
drivers/net/bonding/bond_main.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/sge.c
drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
drivers/net/ethernet/chelsio/cxgb4vf/sge.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/netronome/nfp/flower/cmsg.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
drivers/net/ethernet/sfc/mcdi_port.c
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
drivers/net/tun.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
drivers/net/wireless/intel/iwlwifi/cfg/9000.c
drivers/net/wireless/intel/iwlwifi/fw/file.h
drivers/net/wireless/intel/iwlwifi/iwl-config.h
drivers/net/wireless/intel/iwlwifi/iwl-drv.c
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/rs.c
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/ntb/ntb_transport.c
drivers/ntb/test/ntb_tool.c
drivers/nvme/host/fabrics.c
drivers/nvme/host/pci.c
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/fc.c
drivers/of/device.c
drivers/parisc/dino.c
drivers/pci/msi.c
drivers/pci/pci.c
drivers/pci/probe.c
drivers/pci/quirks.c
drivers/rtc/rtc-ds1307.c
drivers/scsi/Kconfig
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/aacraid.h
drivers/scsi/csiostor/csio_hw.c
drivers/scsi/csiostor/csio_init.c
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
drivers/scsi/ipr.c
drivers/scsi/ipr.h
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/qla2xxx/qla_tmpl.c
drivers/scsi/scsi.c
drivers/scsi/sd.c
drivers/scsi/sd_zbc.c
drivers/scsi/ses.c
drivers/scsi/st.c
drivers/soc/imx/gpcv2.c
drivers/soc/ti/knav_qmss_queue.c
drivers/soc/ti/ti_sci_pm_domains.c
drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/tty/pty.c
drivers/tty/tty_io.c
drivers/virtio/virtio_pci_common.c
drivers/xen/Makefile
drivers/xen/biomerge.c
fs/binfmt_elf.c
fs/btrfs/disk-io.c
fs/btrfs/inode.c
fs/btrfs/raid56.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h
fs/cifs/dir.c
fs/cifs/smb2pdu.c
fs/dax.c
fs/devpts/inode.c
fs/ext4/mballoc.c
fs/ext4/xattr.c
fs/iomap.c
fs/nfsd/nfs4xdr.c
fs/quota/dquot.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/xfs_log.c
fs/xfs/xfs_mount.c
include/asm-generic/vmlinux.lds.h
include/dt-bindings/memory/mt8173-larb-port.h
include/linux/blkdev.h
include/linux/bsg-lib.h
include/linux/devpts_fs.h
include/linux/fs.h
include/linux/iio/iio.h
include/linux/iio/trigger.h
include/linux/iommu.h
include/linux/iova.h
include/linux/memblock.h
include/linux/memcontrol.h
include/linux/net.h
include/linux/nmi.h
include/linux/oom.h
include/linux/pci.h
include/linux/perf_event.h
include/linux/pid.h
include/linux/ptr_ring.h
include/linux/sched.h
include/linux/skb_array.h
include/linux/wait.h
include/net/addrconf.h
include/net/bonding.h
include/net/busy_poll.h
include/net/ip.h
include/net/mac80211.h
include/net/sch_generic.h
include/net/sock.h
include/net/udp.h
include/rdma/ib_verbs.h
include/scsi/scsi_cmnd.h
include/soc/mediatek/smi.h
include/uapi/linux/loop.h
kernel/audit_watch.c
kernel/events/core.c
kernel/fork.c
kernel/irq/chip.c
kernel/irq/ipi.c
kernel/kmod.c
kernel/pid.c
kernel/sched/wait.c
kernel/signal.c
kernel/time/timer.c
kernel/trace/bpf_trace.c
kernel/trace/ftrace.c
kernel/trace/ring_buffer.c
kernel/trace/ring_buffer_benchmark.c
kernel/trace/trace.c
kernel/trace/trace_events_filter.c
kernel/trace/tracing_map.c
kernel/watchdog.c
kernel/watchdog_hld.c
lib/Kconfig.debug
mm/cma_debug.c
mm/filemap.c
mm/huge_memory.c
mm/madvise.c
mm/memblock.c
mm/memcontrol.c
mm/memory.c
mm/mempolicy.c
mm/migrate.c
mm/nobootmem.c
mm/page-writeback.c
mm/page_alloc.c
mm/shmem.c
mm/slub.c
mm/vmalloc.c
net/core/datagram.c
net/core/filter.c
net/dccp/proto.c
net/dsa/tag_ksz.c
net/ipv4/fib_semantics.c
net/ipv4/igmp.c
net/ipv4/route.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_ulp.c
net/ipv4/udp.c
net/ipv6/ip6_fib.c
net/ipv6/route.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/irda/af_irda.c
net/key/af_key.c
net/mac80211/agg-rx.c
net/openvswitch/actions.c
net/openvswitch/datapath.c
net/openvswitch/datapath.h
net/rxrpc/call_accept.c
net/sched/act_ipt.c
net/sched/cls_api.c
net/sched/sch_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_sfq.c
net/sctp/ipv6.c
net/sunrpc/svcsock.c
net/tipc/bearer.c
net/tipc/msg.c
net/tipc/netlink_compat.c
net/unix/af_unix.c
scripts/Kbuild.include
scripts/Makefile.asm-generic
scripts/Makefile.build
scripts/Makefile.dtbinst
scripts/basic/Makefile
scripts/basic/fixdep.c
sound/core/control.c
sound/core/seq/Kconfig
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_queue.c
sound/core/seq/seq_queue.h
sound/firewire/iso-resources.c
sound/firewire/motu/motu.c
sound/pci/emu10k1/emufx.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c
sound/soc/codecs/rt5677.c
sound/usb/mixer.c
sound/usb/mixer.h
sound/usb/mixer_quirks.c
sound/usb/quirks.c
tools/lib/bpf/libbpf.c
tools/objtool/arch/x86/decode.c
tools/testing/selftests/futex/Makefile
tools/testing/selftests/kmod/kmod.sh [changed mode: 0644->0755]
tools/testing/selftests/ntb/ntb_test.sh
tools/testing/selftests/sysctl/sysctl.sh [changed mode: 0644->0755]
tools/testing/selftests/timers/freq-step.c

diff --git a/Documentation/devicetree/bindings/iommu/qcom,iommu.txt b/Documentation/devicetree/bindings/iommu/qcom,iommu.txt
new file mode 100644 (file)
index 0000000..b2641ce
--- /dev/null
@@ -0,0 +1,121 @@
+* QCOM IOMMU v1 Implementation
+
+Qualcomm "B" family devices which are not compatible with arm-smmu have
+a similar looking IOMMU but without access to the global register space,
+and optionally requiring additional configuration to route context irqs
+to non-secure vs secure interrupt line.
+
+** Required properties:
+
+- compatible       : Should be one of:
+
+                        "qcom,msm8916-iommu"
+
+                     Followed by "qcom,msm-iommu-v1".
+
+- clock-names      : Should be a pair of "iface" (required for IOMMUs
+                     register group access) and "bus" (required for
+                     the IOMMUs underlying bus access).
+
+- clocks           : Phandles for respective clocks described by
+                     clock-names.
+
+- #address-cells   : must be 1.
+
+- #size-cells      : must be 1.
+
+- #iommu-cells     : Must be 1.  Index identifies the context-bank #.
+
+- ranges           : Base address and size of the iommu context banks.
+
+- qcom,iommu-secure-id  : secure-id.
+
+- List of sub-nodes, one per translation context bank.  Each sub-node
+  has the following required properties:
+
+  - compatible     : Should be one of:
+        - "qcom,msm-iommu-v1-ns"  : non-secure context bank
+        - "qcom,msm-iommu-v1-sec" : secure context bank
+  - reg            : Base address and size of context bank within the iommu
+  - interrupts     : The context fault irq.
+
+** Optional properties:
+
+- reg              : Base address and size of the SMMU local base, should
+                     be only specified if the iommu requires configuration
+                     for routing of context bank irq's to secure vs non-
+                     secure lines.  (Ie. if the iommu contains secure
+                     context banks)
+
+
+** Examples:
+
+       apps_iommu: iommu@1e20000 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               #iommu-cells = <1>;
+               compatible = "qcom,msm8916-iommu", "qcom,msm-iommu-v1";
+               ranges = <0 0x1e20000 0x40000>;
+               reg = <0x1ef0000 0x3000>;
+               clocks = <&gcc GCC_SMMU_CFG_CLK>,
+                        <&gcc GCC_APSS_TCU_CLK>;
+               clock-names = "iface", "bus";
+               qcom,iommu-secure-id = <17>;
+
+               // mdp_0:
+               iommu-ctx@4000 {
+                       compatible = "qcom,msm-iommu-v1-ns";
+                       reg = <0x4000 0x1000>;
+                       interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
+               };
+
+               // venus_ns:
+               iommu-ctx@5000 {
+                       compatible = "qcom,msm-iommu-v1-sec";
+                       reg = <0x5000 0x1000>;
+                       interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
+               };
+       };
+
+       gpu_iommu: iommu@1f08000 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               #iommu-cells = <1>;
+               compatible = "qcom,msm8916-iommu", "qcom,msm-iommu-v1";
+               ranges = <0 0x1f08000 0x10000>;
+               clocks = <&gcc GCC_SMMU_CFG_CLK>,
+                        <&gcc GCC_GFX_TCU_CLK>;
+               clock-names = "iface", "bus";
+               qcom,iommu-secure-id = <18>;
+
+               // gfx3d_user:
+               iommu-ctx@1000 {
+                       compatible = "qcom,msm-iommu-v1-ns";
+                       reg = <0x1000 0x1000>;
+                       interrupts = <GIC_SPI 241 IRQ_TYPE_LEVEL_HIGH>;
+               };
+
+               // gfx3d_priv:
+               iommu-ctx@2000 {
+                       compatible = "qcom,msm-iommu-v1-ns";
+                       reg = <0x2000 0x1000>;
+                       interrupts = <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>;
+               };
+       };
+
+       ...
+
+       venus: video-codec@1d00000 {
+               ...
+               iommus = <&apps_iommu 5>;
+       };
+
+       mdp: mdp@1a01000 {
+               ...
+               iommus = <&apps_iommu 4>;
+       };
+
+       gpu@01c00000 {
+               ...
+               iommus = <&gpu_iommu 1>, <&gpu_iommu 2>;
+       };
index 9a55ac3735e541360287125dbcd2876212fa8264..2098f7732264e41fddb8e58c22a309f2693715e7 100644 (file)
@@ -15,6 +15,11 @@ Required properties:
                     to associate with its master device.  See:
                     Documentation/devicetree/bindings/iommu/iommu.txt
 
+Optional properties:
+- rockchip,disable-mmu-reset : Don't use the mmu reset operation.
+                              Some mmu instances may produce unexpected results
+                              when the reset operation is used.
+
 Example:
 
        vopl_mmu: iommu@ff940300 {
index 21277a56e94c7c790656fc9fad7bb3f3e7442da7..ddf46b8856a565da83744c4402ec9ae738e67b9e 100644 (file)
@@ -15,6 +15,9 @@ Required properties:
            the register.
   - "smi" : It's the clock for transfer data and command.
 
+Required property for mt2701:
+- mediatek,larb-id :the hardware id of this larb.
+
 Example:
        larb1: larb@16010000 {
                compatible = "mediatek,mt8173-smi-larb";
@@ -25,3 +28,15 @@ Example:
                         <&vdecsys CLK_VDEC_LARB_CKEN>;
                clock-names = "apb", "smi";
        };
+
+Example for mt2701:
+       larb0: larb@14010000 {
+               compatible = "mediatek,mt2701-smi-larb";
+               reg = <0 0x14010000 0 0x1000>;
+               mediatek,smi = <&smi_common>;
+               mediatek,larb-id = <0>;
+               clocks = <&mmsys CLK_MM_SMI_LARB0>,
+                        <&mmsys CLK_MM_SMI_LARB0>;
+               clock-names = "apb", "smi";
+               power-domains = <&scpsys MT2701_POWER_DOMAIN_DISP>;
+       };
index 3e7b946dea2778441ce0599643535188699e16ca..5e40e1f68873b0f2b594c22a6e69ddb218ce56ec 100644 (file)
@@ -228,7 +228,7 @@ Learning on the device port should be enabled, as well as learning_sync:
        bridge link set dev DEV learning on self
        bridge link set dev DEV learning_sync on self
 
-Learning_sync attribute enables syncing of the learned/forgotton FDB entry to
+Learning_sync attribute enables syncing of the learned/forgotten FDB entry to
 the bridge's FDB.  It's possible, but not optimal, to enable learning on the
 device port and on the bridge port, and disable learning_sync.
 
@@ -245,7 +245,7 @@ the responsibility of the port driver/device to age out these entries.  If the
 port device supports ageing, when the FDB entry expires, it will notify the
 driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL.  If the
 device does not support ageing, the driver can simulate ageing using a
-garbage collection timer to monitor FBD entries.  Expired entries will be
+garbage collection timer to monitor FDB entries.  Expired entries will be
 notified to the bridge using SWITCHDEV_FDB_DEL.  See rocker driver for
 example of driver running ageing timer.
 
index 65ea5915178b4b9842474b7908d06660444aae34..074670b98bac784c27eecc18f672b2f1ad24f489 100644 (file)
@@ -58,20 +58,23 @@ Symbols/Function Pointers
        %ps     versatile_init
        %pB     prev_fn_of_versatile_init+0x88/0x88
 
-For printing symbols and function pointers. The ``S`` and ``s`` specifiers
-result in the symbol name with (``S``) or without (``s``) offsets. Where
-this is used on a kernel without KALLSYMS - the symbol address is
-printed instead.
+The ``F`` and ``f`` specifiers are for printing function pointers,
+for example, f->func, &gettimeofday. They have the same result as
+``S`` and ``s`` specifiers. But they do an extra conversion on
+ia64, ppc64 and parisc64 architectures where the function pointers
+are actually function descriptors.
+
+The ``S`` and ``s`` specifiers can be used for printing symbols
+from direct addresses, for example, __builtin_return_address(0),
+(void *)regs->ip. They result in the symbol name with (``S``) or
+without (``s``) offsets. If KALLSYMS are disabled then the symbol
+address is printed instead.
 
 The ``B`` specifier results in the symbol name with offsets and should be
 used when printing stack backtraces. The specifier takes into
 consideration the effect of compiler optimisations which may occur
 when tail-call``s are used and marked with the noreturn GCC attribute.
 
-On ia64, ppc64 and parisc64 architectures function pointers are
-actually function descriptors which must first be resolved. The ``F`` and
-``f`` specifiers perform this resolution and then provide the same
-functionality as the ``S`` and ``s`` specifiers.
 
 Kernel Pointers
 ===============
index 14db18c970b1b048c0ecc50d75e10efb674715ca..28596e03220b5528891c19316b7cfe2b53fcf331 100644 (file)
@@ -35,9 +35,34 @@ Table : Subdirectories in /proc/sys/net
 bpf_jit_enable
 --------------
 
-This enables Berkeley Packet Filter Just in Time compiler.
-Currently supported on x86_64 architecture, bpf_jit provides a framework
-to speed packet filtering, the one used by tcpdump/libpcap for example.
+This enables the BPF Just in Time (JIT) compiler. BPF is a flexible
+and efficient infrastructure allowing to execute bytecode at various
+hook points. It is used in a number of Linux kernel subsystems such
+as networking (e.g. XDP, tc), tracing (e.g. kprobes, uprobes, tracepoints)
+and security (e.g. seccomp). LLVM has a BPF back end that can compile
+restricted C into a sequence of BPF instructions. After program load
+through bpf(2) and passing a verifier in the kernel, a JIT will then
+translate these BPF proglets into native CPU instructions. There are
+two flavors of JITs, the newer eBPF JIT currently supported on:
+  - x86_64
+  - arm64
+  - ppc64
+  - sparc64
+  - mips64
+  - s390x
+
+And the older cBPF JIT supported on the following archs:
+  - arm
+  - mips
+  - ppc
+  - sparc
+
+eBPF JITs are a superset of cBPF JITs, meaning the kernel will
+migrate cBPF instructions into eBPF instructions and then JIT
+compile them transparently. Older cBPF JITs can only translate
+tcpdump filters, seccomp rules, etc, but not mentioned eBPF
+programs loaded through bpf(2).
+
 Values :
        0 - disable the JIT (default value)
        1 - enable the JIT
@@ -46,9 +71,9 @@ Values :
 bpf_jit_harden
 --------------
 
-This enables hardening for the Berkeley Packet Filter Just in Time compiler.
-Supported are eBPF JIT backends. Enabling hardening trades off performance,
-but can mitigate JIT spraying.
+This enables hardening for the BPF JIT compiler. Supported are eBPF
+JIT backends. Enabling hardening trades off performance, but can
+mitigate JIT spraying.
 Values :
        0 - disable JIT hardening (default value)
        1 - enable JIT hardening for unprivileged users only
@@ -57,11 +82,11 @@ Values :
 bpf_jit_kallsyms
 ----------------
 
-When Berkeley Packet Filter Just in Time compiler is enabled, then compiled
-images are unknown addresses to the kernel, meaning they neither show up in
-traces nor in /proc/kallsyms. This enables export of these addresses, which
-can be used for debugging/tracing. If bpf_jit_harden is enabled, this feature
-is disabled.
+When BPF JIT compiler is enabled, then compiled images are unknown
+addresses to the kernel, meaning they neither show up in traces nor
+in /proc/kallsyms. This enables export of these addresses, which can
+be used for debugging/tracing. If bpf_jit_harden is enabled, this
+feature is disabled.
 Values :
        0 - disable JIT kallsyms export (default value)
        1 - enable JIT kallsyms export for privileged users only
index 6f7721d1634c2eb7247538f2cb4d85fa1be1a458..48ebccbd96064ad365a55421e3d389c55aac4c8b 100644 (file)
@@ -7110,7 +7110,6 @@ M:        Marc Zyngier <marc.zyngier@arm.com>
 L:     linux-kernel@vger.kernel.org
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
-T:     git git://git.infradead.org/users/jcooper/linux.git irqchip/core
 F:     Documentation/devicetree/bindings/interrupt-controller/
 F:     drivers/irqchip/
 
@@ -10941,6 +10940,13 @@ T:     git git://git.kernel.org/pub/scm/linux/kernel/git/rkuo/linux-hexagon-kernel.g
 S:     Supported
 F:     arch/hexagon/
 
+QUALCOMM IOMMU
+M:     Rob Clark <robdclark@gmail.com>
+L:     iommu@lists.linux-foundation.org
+L:     linux-arm-msm@vger.kernel.org
+S:     Maintained
+F:     drivers/iommu/qcom_iommu.c
+
 QUALCOMM VENUS VIDEO ACCELERATOR DRIVER
 M:     Stanimir Varbanov <stanimir.varbanov@linaro.org>
 L:     linux-media@vger.kernel.org
index 90da7bdc3f4552d10bbd82c4fd0a88ed2f41db37..8db6be7dca731f4cb5a552c45811ce334747dff9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 4
 PATCHLEVEL = 13
 SUBLEVEL = 0
-EXTRAVERSION = -rc5
+EXTRAVERSION = -rc7
 NAME = Fearless Coyote
 
 # *DOCUMENTATION*
@@ -396,7 +396,7 @@ LINUXINCLUDE    := \
 KBUILD_CPPFLAGS := -D__KERNEL__
 
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-                  -fno-strict-aliasing -fno-common \
+                  -fno-strict-aliasing -fno-common -fshort-wchar \
                   -Werror-implicit-function-declaration \
                   -Wno-format-security \
                   -std=gnu89 $(call cc-option,-fno-PIE)
@@ -442,7 +442,7 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
 # ===========================================================================
 # Rules shared between *config targets and build targets
 
-# Basic helpers built in scripts/
+# Basic helpers built in scripts/basic/
 PHONY += scripts_basic
 scripts_basic:
        $(Q)$(MAKE) $(build)=scripts/basic
@@ -505,7 +505,7 @@ ifeq ($(KBUILD_EXTMOD),)
                 endif
         endif
 endif
-# install and module_install need also be processed one by one
+# install and modules_install need also be processed one by one
 ifneq ($(filter install,$(MAKECMDGOALS)),)
         ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
                mixed-targets := 1
@@ -964,7 +964,7 @@ export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-
 export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
-# used by scripts/pacmage/Makefile
+# used by scripts/package/Makefile
 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
 
 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS)
@@ -992,8 +992,8 @@ include/generated/autoksyms.h: FORCE
 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
 
 # Final link of vmlinux with optional arch pass after final link
-    cmd_link-vmlinux =                                                 \
-       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;       \
+cmd_link-vmlinux =                                                 \
+       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;    \
        $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
 vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE
@@ -1184,6 +1184,7 @@ PHONY += kselftest
 kselftest:
        $(Q)$(MAKE) -C tools/testing/selftests run_tests
 
+PHONY += kselftest-clean
 kselftest-clean:
        $(Q)$(MAKE) -C tools/testing/selftests clean
 
index a5459698f0ee3762917c82c8cbf133e34643f021..7db85ab00c522315c3108930365fc57c59fd311c 100644 (file)
@@ -96,7 +96,6 @@ menu "ARC Architecture Configuration"
 
 menu "ARC Platform/SoC/Board"
 
-source "arch/arc/plat-sim/Kconfig"
 source "arch/arc/plat-tb10x/Kconfig"
 source "arch/arc/plat-axs10x/Kconfig"
 #New platform adds here
index 44ef35d339564623b2beb4a380a81da6a7790087..3a61cfcc38c0dd78f58247512a4d31231a2daa4b 100644 (file)
@@ -107,7 +107,7 @@ core-y              += arch/arc/
 # w/o this dtb won't embed into kernel binary
 core-y         += arch/arc/boot/dts/
 
-core-$(CONFIG_ARC_PLAT_SIM)    += arch/arc/plat-sim/
+core-y                         += arch/arc/plat-sim/
 core-$(CONFIG_ARC_PLAT_TB10X)  += arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
 core-$(CONFIG_ARC_PLAT_EZNPS)  += arch/arc/plat-eznps/
index 53ce226f77a59857615f8fc53fca3ba1c4f09749..a380ffa1a4589b11de92a5a0c21bc831e6dc751b 100644 (file)
 
 / {
        compatible = "snps,arc";
-       #address-cells = <1>;
-       #size-cells = <1>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_card {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
 
-               ranges = <0x00000000 0xf0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xf0000000 0x10000000>;
 
                core_clk: core_clk {
                        #clock-cells = <0>;
        mb_intc: dw-apb-ictl@0xe0012000 {
                #interrupt-cells = <1>;
                compatible = "snps,dw-apb-ictl";
-               reg = < 0xe0012000 0x200 >;
+               reg = < 0x0 0xe0012000 0x0 0x200 >;
                interrupt-controller;
                interrupt-parent = <&core_intc>;
                interrupts = < 7 >;
        };
 
        memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges = <0x00000000 0x80000000 0x20000000>;
                device_type = "memory";
-               reg = <0x80000000 0x1b000000>;  /* (512 - 32) MiB */
+               /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */
+               reg = <0x0 0x80000000 0x0 0x1b000000>;  /* (512 - 32) MiB */
        };
 
        reserved-memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                ranges;
                /*
                 * We just move frame buffer area to the very end of
                 */
                frame_buffer: frame_buffer@9e000000 {
                        compatible = "shared-dma-pool";
-                       reg = <0x9e000000 0x2000000>;
+                       reg = <0x0 0x9e000000 0x0 0x2000000>;
                        no-map;
                };
        };
index 14df46f141bf3450b8df0660bc0f248beef4669b..cc9239ef8d08c9f6efbe6dbee0323f283c4f5e37 100644 (file)
 
 / {
        compatible = "snps,arc";
-       #address-cells = <1>;
-       #size-cells = <1>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_card {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
 
-               ranges = <0x00000000 0xf0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xf0000000 0x10000000>;
 
                core_clk: core_clk {
                        #clock-cells = <0>;
        mb_intc: dw-apb-ictl@0xe0012000 {
                #interrupt-cells = <1>;
                compatible = "snps,dw-apb-ictl";
-               reg = < 0xe0012000 0x200 >;
+               reg = < 0x0 0xe0012000 0x0 0x200 >;
                interrupt-controller;
                interrupt-parent = <&core_intc>;
                interrupts = < 24 >;
        };
 
        memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges = <0x00000000 0x80000000 0x40000000>;
                device_type = "memory";
-               reg = <0x80000000 0x20000000>;  /* 512MiB */
+               /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */
+               reg = <0x0 0x80000000 0x0 0x20000000    /* 512 MiB low mem */
+                      0x1 0xc0000000 0x0 0x40000000>;  /* 1 GiB highmem */
        };
 
        reserved-memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                ranges;
                /*
                 * Move frame buffer out of IOC aperture (0x8z-0xAz).
                 */
                frame_buffer: frame_buffer@be000000 {
                        compatible = "shared-dma-pool";
-                       reg = <0xbe000000 0x2000000>;
+                       reg = <0x0 0xbe000000 0x0 0x2000000>;
                        no-map;
                };
        };
index 695f9fa1996bcbb2689e1bf98dc8fa661cc1c216..4ebb2170abecc7e00cd581a7ca6dcef6e94231e0 100644 (file)
 
 / {
        compatible = "snps,arc";
-       #address-cells = <1>;
-       #size-cells = <1>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_card {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
 
-               ranges = <0x00000000 0xf0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xf0000000 0x10000000>;
 
                core_clk: core_clk {
                        #clock-cells = <0>;
        mb_intc: dw-apb-ictl@0xe0012000 {
                #interrupt-cells = <1>;
                compatible = "snps,dw-apb-ictl";
-               reg = < 0xe0012000 0x200 >;
+               reg = < 0x0 0xe0012000 0x0 0x200 >;
                interrupt-controller;
                interrupt-parent = <&idu_intc>;
                interrupts = <0>;
        };
 
        memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges = <0x00000000 0x80000000 0x40000000>;
                device_type = "memory";
-               reg = <0x80000000 0x20000000>;  /* 512MiB */
+               /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */
+               reg = <0x0 0x80000000 0x0 0x20000000    /* 512 MiB low mem */
+                      0x1 0xc0000000 0x0 0x40000000>;  /* 1 GiB highmem */
        };
 
        reserved-memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                ranges;
                /*
                 * Move frame buffer out of IOC aperture (0x8z-0xAz).
                 */
                frame_buffer: frame_buffer@be000000 {
                        compatible = "shared-dma-pool";
-                       reg = <0xbe000000 0x2000000>;
+                       reg = <0x0 0xbe000000 0x0 0x2000000>;
                        no-map;
                };
        };
index 41cfb29b62c142ca48193359e8fedf20151cc9bf..0ff7e07edcd4d28bcf6266cedd590034b8aebd13 100644 (file)
@@ -13,7 +13,7 @@
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
-               ranges = <0x00000000 0xe0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xe0000000 0x10000000>;
                interrupt-parent = <&mb_intc>;
 
                i2sclk: i2sclk@100a0 {
index 57b3e599322f83d5babd0014c7d9ccf3a03578eb..db04ea4dd2d97237b843fd4b90706f2e0c8ef6d9 100644 (file)
@@ -21,7 +21,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs"
 CONFIG_PREEMPT=y
index f85985adebb245981d8a4130e8c0b91a45abe7dd..821a2e562f3f12422844556630d7136ad63097a8 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs_idu"
index ede625c76216616b097365a3274e09ccea97d3d6..7c9c706ae7f66eb29d4cf48ca0b95d5dd44630f5 100644 (file)
@@ -39,7 +39,6 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
index b0066a749d4c49d8a23e3bd33b4a52789789c913..6dff83a238b8591ba08f889e7d7013734ff587db 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_700"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
index ebe9ebb92933302af79f98dae000e8567b86ec6b..31ee51b987e7c5b97c2f044794f9d1c5b4eea73e 100644 (file)
@@ -26,7 +26,6 @@ CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs"
 CONFIG_PREEMPT=y
index 4bde43278be6757c5c739bfd58a9f030a80c7568..8d3b1f67cae421c423e55c2622b5a78ea3d67794 100644 (file)
@@ -24,7 +24,6 @@ CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs_idu"
index f6fb3d26557eb7c63b2f77263acfed80f0b45387..6168ce2ac2efdd869705a8a75e78f7f9b9c55af4 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci"
 # CONFIG_COMPACTION is not set
 CONFIG_NET=y
index b9f0fe00044b6c44d62a81a91064583cd9badee3..a70bdeb2b3fd03bdefd10388e69cd8e5b120ac0f 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci_hs"
 # CONFIG_COMPACTION is not set
index 155add7761ed63080bd81e830c819483fb55ee61..ef96406c446e823d4706e5c84b6ac0626d4b5812 100644 (file)
@@ -18,7 +18,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 # CONFIG_ARC_TIMERS_64BIT is not set
index 4c5118384eb5f1c393208cde601fddc1be773494..f3018254939508e373662a2ae98f9d08be9425a2 100644 (file)
@@ -38,7 +38,6 @@ CONFIG_IP_MULTICAST=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
index 19ebddffb279db05ca8e53e2c4753665376cc9ad..02fd1cece6ef339209c993a6b56b87312e39d648 100644 (file)
@@ -96,7 +96,9 @@ extern unsigned long perip_base, perip_end;
 #define ARC_REG_SLC_FLUSH      0x904
 #define ARC_REG_SLC_INVALIDATE 0x905
 #define ARC_REG_SLC_RGN_START  0x914
+#define ARC_REG_SLC_RGN_START1 0x915
 #define ARC_REG_SLC_RGN_END    0x916
+#define ARC_REG_SLC_RGN_END1   0x917
 
 /* Bit val in SLC_CONTROL */
 #define SLC_CTRL_DIS           0x001
index db7319e9b506e9ece826fde788aba60adada59cb..efb79fafff1d12214dc41923a75b237a969214f5 100644 (file)
@@ -94,6 +94,8 @@ static inline int is_pae40_enabled(void)
        return IS_ENABLED(CONFIG_ARC_HAS_PAE40);
 }
 
+extern int pae40_exist_but_not_enab(void);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
index f928795fd07a813e9f6f3e6d86f325b45561b3dc..cf90714a676d6baabbdc1beb2119fe530e1c84f3 100644 (file)
@@ -75,10 +75,13 @@ void arc_init_IRQ(void)
         * Set a default priority for all available interrupts to prevent
         * switching of register banks if Fast IRQ and multiple register banks
         * are supported by CPU.
+        * Also disable all IRQ lines so faulty external hardware won't
+        * trigger interrupt that kernel is not ready to handle.
         */
        for (i = NR_EXCEPTIONS; i < irq_bcr.irqs + NR_EXCEPTIONS; i++) {
                write_aux_reg(AUX_IRQ_SELECT, i);
                write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
+               write_aux_reg(AUX_IRQ_ENABLE, 0);
        }
 
        /* setup status32, don't enable intr yet as kernel doesn't want */
index 7e608c6b0a018697fb22c52c7fb4ac46a45fe2f0..cef388025adf43aed091869f102e01e1bee72092 100644 (file)
@@ -27,7 +27,7 @@
  */
 void arc_init_IRQ(void)
 {
-       int level_mask = 0;
+       int level_mask = 0, i;
 
        /* Is timer high priority Interrupt (Level2 in ARCompact jargon) */
        level_mask |= IS_ENABLED(CONFIG_ARC_COMPACT_IRQ_LEVELS) << TIMER0_IRQ;
@@ -40,6 +40,18 @@ void arc_init_IRQ(void)
 
        if (level_mask)
                pr_info("Level-2 interrupts bitset %x\n", level_mask);
+
+       /*
+        * Disable all IRQ lines so faulty external hardware won't
+        * trigger interrupt that kernel is not ready to handle.
+        */
+       for (i = TIMER0_IRQ; i < NR_CPU_IRQS; i++) {
+               unsigned int ienb;
+
+               ienb = read_aux_reg(AUX_IENABLE);
+               ienb &= ~(1 << i);
+               write_aux_reg(AUX_IENABLE, ienb);
+       }
 }
 
 /*
index a867575a758b9845c09a84fb4515f17f08f1272b..7db283b46ebde8daccf779525e82526e47ad2722 100644 (file)
@@ -665,6 +665,7 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op)
        static DEFINE_SPINLOCK(lock);
        unsigned long flags;
        unsigned int ctrl;
+       phys_addr_t end;
 
        spin_lock_irqsave(&lock, flags);
 
@@ -694,8 +695,19 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op)
         * END needs to be setup before START (latter triggers the operation)
         * END can't be same as START, so add (l2_line_sz - 1) to sz
         */
-       write_aux_reg(ARC_REG_SLC_RGN_END, (paddr + sz + l2_line_sz - 1));
-       write_aux_reg(ARC_REG_SLC_RGN_START, paddr);
+       end = paddr + sz + l2_line_sz - 1;
+       if (is_pae40_enabled())
+               write_aux_reg(ARC_REG_SLC_RGN_END1, upper_32_bits(end));
+
+       write_aux_reg(ARC_REG_SLC_RGN_END, lower_32_bits(end));
+
+       if (is_pae40_enabled())
+               write_aux_reg(ARC_REG_SLC_RGN_START1, upper_32_bits(paddr));
+
+       write_aux_reg(ARC_REG_SLC_RGN_START, lower_32_bits(paddr));
+
+       /* Make sure "busy" bit reports correct stataus, see STAR 9001165532 */
+       read_aux_reg(ARC_REG_SLC_CTRL);
 
        while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY);
 
@@ -1111,6 +1123,13 @@ noinline void __init arc_ioc_setup(void)
        __dc_enable();
 }
 
+/*
+ * Cache related boot time checks/setups only needed on master CPU:
+ *  - Geometry checks (kernel build and hardware agree: e.g. L1_CACHE_BYTES)
+ *    Assume SMP only, so all cores will have same cache config. A check on
+ *    one core suffices for all
+ *  - IOC setup / dma callbacks only need to be done once
+ */
 void __init arc_cache_init_master(void)
 {
        unsigned int __maybe_unused cpu = smp_processor_id();
@@ -1190,12 +1209,27 @@ void __ref arc_cache_init(void)
 
        printk(arc_cache_mumbojumbo(0, str, sizeof(str)));
 
-       /*
-        * Only master CPU needs to execute rest of function:
-        *  - Assume SMP so all cores will have same cache config so
-        *    any geomtry checks will be same for all
-        *  - IOC setup / dma callbacks only need to be setup once
-        */
        if (!cpu)
                arc_cache_init_master();
+
+       /*
+        * In PAE regime, TLB and cache maintenance ops take wider addresses
+        * And even if PAE is not enabled in kernel, the upper 32-bits still need
+        * to be zeroed to keep the ops sane.
+        * As an optimization for more common !PAE enabled case, zero them out
+        * once at init, rather than checking/setting to 0 for every runtime op
+        */
+       if (is_isa_arcv2() && pae40_exist_but_not_enab()) {
+
+               if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE))
+                       write_aux_reg(ARC_REG_IC_PTAG_HI, 0);
+
+               if (IS_ENABLED(CONFIG_ARC_HAS_DCACHE))
+                       write_aux_reg(ARC_REG_DC_PTAG_HI, 0);
+
+               if (l2_line_sz) {
+                       write_aux_reg(ARC_REG_SLC_RGN_END1, 0);
+                       write_aux_reg(ARC_REG_SLC_RGN_START1, 0);
+               }
+       }
 }
index 71d3efff99d35c56c6f30bea8a6ab1cf1702d753..e9d93604ad0ff7b76a5458235b3ab4d0ef18aefb 100644 (file)
@@ -153,6 +153,19 @@ static void _dma_cache_sync(phys_addr_t paddr, size_t size,
        }
 }
 
+/*
+ * arc_dma_map_page - map a portion of a page for streaming DMA
+ *
+ * Ensure that any data held in the cache is appropriately discarded
+ * or written back.
+ *
+ * The device owns this memory once this call has completed.  The CPU
+ * can regain ownership by calling dma_unmap_page().
+ *
+ * Note: while it takes struct page as arg, caller can "abuse" it to pass
+ * a region larger than PAGE_SIZE, provided it is physically contiguous
+ * and this still works correctly
+ */
 static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
                unsigned long offset, size_t size, enum dma_data_direction dir,
                unsigned long attrs)
@@ -165,6 +178,24 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
        return plat_phys_to_dma(dev, paddr);
 }
 
+/*
+ * arc_dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
+ *
+ * After this call, reads by the CPU to the buffer are guaranteed to see
+ * whatever the device wrote there.
+ *
+ * Note: historically this routine was not implemented for ARC
+ */
+static void arc_dma_unmap_page(struct device *dev, dma_addr_t handle,
+                              size_t size, enum dma_data_direction dir,
+                              unsigned long attrs)
+{
+       phys_addr_t paddr = plat_dma_to_phys(dev, handle);
+
+       if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+               _dma_cache_sync(paddr, size, dir);
+}
+
 static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
           int nents, enum dma_data_direction dir, unsigned long attrs)
 {
@@ -178,6 +209,18 @@ static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
        return nents;
 }
 
+static void arc_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+                            int nents, enum dma_data_direction dir,
+                            unsigned long attrs)
+{
+       struct scatterlist *s;
+       int i;
+
+       for_each_sg(sg, s, nents, i)
+               arc_dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir,
+                                  attrs);
+}
+
 static void arc_dma_sync_single_for_cpu(struct device *dev,
                dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
 {
@@ -223,7 +266,9 @@ const struct dma_map_ops arc_dma_ops = {
        .free                   = arc_dma_free,
        .mmap                   = arc_dma_mmap,
        .map_page               = arc_dma_map_page,
+       .unmap_page             = arc_dma_unmap_page,
        .map_sg                 = arc_dma_map_sg,
+       .unmap_sg               = arc_dma_unmap_sg,
        .sync_single_for_device = arc_dma_sync_single_for_device,
        .sync_single_for_cpu    = arc_dma_sync_single_for_cpu,
        .sync_sg_for_cpu        = arc_dma_sync_sg_for_cpu,
index d0126fdfe2d8546d62883cbef419e4b76589cf18..b181f3ee38aab54565d8de8c1e5136375c6358cc 100644 (file)
 /* A copy of the ASID from the PID reg is kept in asid_cache */
 DEFINE_PER_CPU(unsigned int, asid_cache) = MM_CTXT_FIRST_CYCLE;
 
+static int __read_mostly pae_exists;
+
 /*
  * Utility Routine to erase a J-TLB entry
  * Caller needs to setup Index Reg (manually or via getIndex)
@@ -784,7 +786,7 @@ void read_decode_mmu_bcr(void)
                mmu->u_dtlb = mmu4->u_dtlb * 4;
                mmu->u_itlb = mmu4->u_itlb * 4;
                mmu->sasid = mmu4->sasid;
-               mmu->pae = mmu4->pae;
+               pae_exists = mmu->pae = mmu4->pae;
        }
 }
 
@@ -809,6 +811,11 @@ char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len)
        return buf;
 }
 
+int pae40_exist_but_not_enab(void)
+{
+       return pae_exists && !is_pae40_enabled();
+}
+
 void arc_mmu_init(void)
 {
        char str[256];
@@ -859,6 +866,9 @@ void arc_mmu_init(void)
        /* swapper_pg_dir is the pgd for the kernel, used by vmalloc */
        write_aux_reg(ARC_REG_SCRATCH_DATA0, swapper_pg_dir);
 #endif
+
+       if (pae40_exist_but_not_enab())
+               write_aux_reg(ARC_REG_TLBPD1HI, 0);
 }
 
 /*
diff --git a/arch/arc/plat-sim/Kconfig b/arch/arc/plat-sim/Kconfig
deleted file mode 100644 (file)
index ac6af96..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Copyright (C) 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-
-menuconfig ARC_PLAT_SIM
-       bool "ARC nSIM based simulation virtual platforms"
-       help
-         Support for nSIM based ARC simulation platforms
-         This includes the standalone nSIM (uart only) vs. System C OSCI VP
index aea87389e44bd517b196ec87de0edb4c0216b4b1..5cda56b1a2ead7bc54ca1ac63296fcd1f54fc43f 100644 (file)
  */
 
 static const char *simulation_compat[] __initconst = {
+#ifdef CONFIG_ISA_ARCOMPACT
        "snps,nsim",
-       "snps,nsim_hs",
        "snps,nsimosci",
+#else
+       "snps,nsim_hs",
        "snps,nsimosci_hs",
        "snps,zebu_hs",
+#endif
        NULL,
 };
 
index f92f957412073279a3be9713794bb2336dbf4752..a183b56283f8ff9e9d41d616edfc00a82d200267 100644 (file)
 
 &hdmicec {
        status = "okay";
+       needs-hpd;
 };
 
 &hsi2c_4 {
index dfcc8e00cf1c53a753dc753c2c5598b220b480a1..0ade3619f3c3f1332b8d89c8d06ed4a67f29025b 100644 (file)
                                #address-cells = <1>;
                                #size-cells = <1>;
                                status = "disabled";
+                               ranges;
 
                                adc: adc@50030800 {
                                        compatible = "fsl,imx25-gcq";
index aeaa5a6e4fcf462bc8a381ab20ba85c3579dea5c..a24e4f1911abe77917726d8ff8342f7dcb88dab2 100644 (file)
        pinctrl_pcie: pciegrp {
                fsl,pins = <
                        /* PCIe reset */
-                       MX6QDL_PAD_EIM_BCLK__GPIO6_IO31 0x030b0
+                       MX6QDL_PAD_EIM_DA0__GPIO3_IO00  0x030b0
                        MX6QDL_PAD_EIM_DA4__GPIO3_IO04  0x030b0
                >;
        };
 &pcie {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_pcie>;
-       reset-gpio = <&gpio6 31 GPIO_ACTIVE_LOW>;
+       reset-gpio = <&gpio3 0 GPIO_ACTIVE_LOW>;
        status = "okay";
 };
 
index 54c45402286b10dc06240aef9ec7d015a3fd5a58..0a24d1bf3c393463148919e685a879df39af58ef 100644 (file)
                        >;
                };
 
+               pinctrl_spi4: spi4grp {
+                       fsl,pins = <
+                               MX7D_PAD_GPIO1_IO09__GPIO1_IO9  0x59
+                               MX7D_PAD_GPIO1_IO12__GPIO1_IO12 0x59
+                               MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x59
+                       >;
+               };
+
                pinctrl_tsc2046_pendown: tsc2046_pendown {
                        fsl,pins = <
                                MX7D_PAD_EPDC_BDR1__GPIO2_IO29          0x59
                fsl,pins = <
                        MX7D_PAD_LPSR_GPIO1_IO01__PWM1_OUT              0x110b0
                >;
-
-               pinctrl_spi4: spi4grp {
-                       fsl,pins = <
-                               MX7D_PAD_GPIO1_IO09__GPIO1_IO9  0x59
-                               MX7D_PAD_GPIO1_IO12__GPIO1_IO12 0x59
-                               MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x59
-                       >;
-               };
        };
 };
index cc06da3943668415e9b6379dbe38d2fde36518ec..60e69aeacbdbf4dff78923f227f96f8bc49c1fbc 100644 (file)
                        #size-cells = <1>;
                        atmel,smc = <&hsmc>;
                        reg = <0x10000000 0x10000000
-                              0x40000000 0x30000000>;
+                              0x60000000 0x30000000>;
                        ranges = <0x0 0x0 0x10000000 0x10000000
                                  0x1 0x0 0x60000000 0x10000000
                                  0x2 0x0 0x70000000 0x10000000
                        };
 
                        hsmc: hsmc@f8014000 {
-                               compatible = "atmel,sama5d3-smc", "syscon", "simple-mfd";
+                               compatible = "atmel,sama5d2-smc", "syscon", "simple-mfd";
                                reg = <0xf8014000 0x1000>;
-                               interrupts = <5 IRQ_TYPE_LEVEL_HIGH 6>;
+                               interrupts = <17 IRQ_TYPE_LEVEL_HIGH 6>;
                                clocks = <&hsmc_clk>;
                                #address-cells = <1>;
                                #size-cells = <1>;
                                ranges;
 
-                               pmecc: ecc-engine@ffffc070 {
+                               pmecc: ecc-engine@f8014070 {
                                        compatible = "atmel,sama5d2-pmecc";
-                                       reg = <0xffffc070 0x490>,
-                                             <0xffffc500 0x100>;
+                                       reg = <0xf8014070 0x490>,
+                                             <0xf8014500 0x100>;
                                };
                        };
 
index d735e5fc47727b0536c943b6fdb15223d7394360..195da38cb9a220f22c2f890c5bcb8fc1f2c7c621 100644 (file)
@@ -1,7 +1,7 @@
 menuconfig ARCH_AT91
        bool "Atmel SoCs"
        depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 || ARCH_MULTI_V7 || ARM_SINGLE_ARMV7M
-       select ARM_CPU_SUSPEND if PM
+       select ARM_CPU_SUSPEND if PM && ARCH_MULTI_V7
        select COMMON_CLK_AT91
        select GPIOLIB
        select PINCTRL
index 667fddac38561eff3f25788ccbf9e05ac8214d84..5036f996e694a533d66f82743b901385ae048007 100644 (file)
@@ -608,6 +608,9 @@ static void __init at91_pm_init(void (*pm_idle)(void))
 
 void __init at91rm9200_pm_init(void)
 {
+       if (!IS_ENABLED(CONFIG_SOC_AT91RM9200))
+               return;
+
        at91_dt_ramc();
 
        /*
@@ -620,18 +623,27 @@ void __init at91rm9200_pm_init(void)
 
 void __init at91sam9_pm_init(void)
 {
+       if (!IS_ENABLED(CONFIG_SOC_AT91SAM9))
+               return;
+
        at91_dt_ramc();
        at91_pm_init(at91sam9_idle);
 }
 
 void __init sama5_pm_init(void)
 {
+       if (!IS_ENABLED(CONFIG_SOC_SAMA5))
+               return;
+
        at91_dt_ramc();
        at91_pm_init(NULL);
 }
 
 void __init sama5d2_pm_init(void)
 {
+       if (!IS_ENABLED(CONFIG_SOC_SAMA5D2))
+               return;
+
        at91_pm_backup_init();
        sama5_pm_init();
 }
index 0d1f026d831aac7b7ecda69ac5ec0f57e693ec2b..ba2fde2909f949531bf4e63e25fe22856b0cec3b 100644 (file)
@@ -51,6 +51,7 @@
        compatible = "sinovoip,bananapi-m64", "allwinner,sun50i-a64";
 
        aliases {
+               ethernet0 = &emac;
                serial0 = &uart0;
                serial1 = &uart1;
        };
index 08cda24ea194cbffd08fc8de50dc7a4d525e5019..827168bc22ed2c6f9b831e4b3b92d75980becf1d 100644 (file)
@@ -51,6 +51,7 @@
        compatible = "pine64,pine64", "allwinner,sun50i-a64";
 
        aliases {
+               ethernet0 = &emac;
                serial0 = &uart0;
                serial1 = &uart1;
                serial2 = &uart2;
index 17eb1cc5bf6b4061a8ea8cf40e54b4eb52c1ebe3..216e3a5dafaef892fc764a076a0e0e5bdfaf396e 100644 (file)
@@ -53,6 +53,7 @@
                     "allwinner,sun50i-a64";
 
        aliases {
+               ethernet0 = &emac;
                serial0 = &uart0;
        };
 
index 732e2e06f503c83e42c0c4925b06295e6e47dc64..d9a720bff05d39ae93941140a3a8298f0bfa6570 100644 (file)
 };
 
 &pio {
+       interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
+                    <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
+                    <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
        compatible = "allwinner,sun50i-h5-pinctrl";
 };
index a451996f590a5173a3e9dbe56831a623e3c0639a..f903957da504a9e02fa910243b60388dc85ec959 100644 (file)
@@ -45,7 +45,7 @@
                stdout-path = "serial0:115200n8";
        };
 
-       audio_clkout: audio_clkout {
+       audio_clkout: audio-clkout {
                /*
                 * This is same as <&rcar_sound 0>
                 * but needed to avoid cs2000/rcar_sound probe dead-lock
index 74d08e44a651b9e58de7d8a6075f6101083f5262..a652ce0a5cb2c33178ac2e447fad1159efb0c6a9 100644 (file)
@@ -65,13 +65,13 @@ DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
        u64 _val;                                                       \
        if (needs_unstable_timer_counter_workaround()) {                \
                const struct arch_timer_erratum_workaround *wa;         \
-               preempt_disable();                                      \
+               preempt_disable_notrace();                              \
                wa = __this_cpu_read(timer_unstable_counter_workaround); \
                if (wa && wa->read_##reg)                               \
                        _val = wa->read_##reg();                        \
                else                                                    \
                        _val = read_sysreg(reg);                        \
-               preempt_enable();                                       \
+               preempt_enable_notrace();                               \
        } else {                                                        \
                _val = read_sysreg(reg);                                \
        }                                                               \
index acae781f7359ece14f713e74e168deb6e47dd68b..3288c2b3673149b728ea52ee87bc65ba723c9811 100644 (file)
 
 /*
  * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
+ * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
-#define ELF_ET_DYN_BASE                0x100000000UL
+#define ELF_ET_DYN_BASE                (2 * TASK_SIZE_64 / 3)
 
 #ifndef __ASSEMBLY__
 
index 06da8ea16bbe5e150bb7330ab0049c7438b25f8d..c7b4995868e14d78216c4b06ce87476dfe8a4789 100644 (file)
@@ -161,9 +161,11 @@ void fpsimd_flush_thread(void)
 {
        if (!system_supports_fpsimd())
                return;
+       preempt_disable();
        memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
        fpsimd_flush_task_state(current);
        set_thread_flag(TIF_FOREIGN_FPSTATE);
+       preempt_enable();
 }
 
 /*
index 973df7de7bf8d3e4fcde6dc2ba1590fa051964a2..adb0910b88f5f26c1562a7fef6f00f29ee9ec391 100644 (file)
@@ -354,7 +354,6 @@ __primary_switched:
        tst     x23, ~(MIN_KIMG_ALIGN - 1)      // already running randomized?
        b.ne    0f
        mov     x0, x21                         // pass FDT address in x0
-       mov     x1, x23                         // pass modulo offset in x1
        bl      kaslr_early_init                // parse FDT for KASLR options
        cbz     x0, 0f                          // KASLR disabled? just proceed
        orr     x23, x23, x0                    // record KASLR offset
index a9710efb8c017a735f9aa6518463d11b8d6264c9..47080c49cc7e77a3df120f061f7b10f90a8c2ec5 100644 (file)
@@ -75,7 +75,7 @@ extern void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, int *size,
  * containing function pointers) to be reinitialized, and zero-initialized
  * .bss variables will be reset to 0.
  */
-u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset)
+u64 __init kaslr_early_init(u64 dt_phys)
 {
        void *fdt;
        u64 seed, offset, mask, module_range;
@@ -131,15 +131,17 @@ u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset)
        /*
         * The kernel Image should not extend across a 1GB/32MB/512MB alignment
         * boundary (for 4KB/16KB/64KB granule kernels, respectively). If this
-        * happens, increase the KASLR offset by the size of the kernel image
-        * rounded up by SWAPPER_BLOCK_SIZE.
+        * happens, round down the KASLR offset by (1 << SWAPPER_TABLE_SHIFT).
+        *
+        * NOTE: The references to _text and _end below will already take the
+        *       modulo offset (the physical displacement modulo 2 MB) into
+        *       account, given that the physical placement is controlled by
+        *       the loader, and will not change as a result of the virtual
+        *       mapping we choose.
         */
-       if ((((u64)_text + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT) !=
-           (((u64)_end + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT)) {
-               u64 kimg_sz = _end - _text;
-               offset = (offset + round_up(kimg_sz, SWAPPER_BLOCK_SIZE))
-                               & mask;
-       }
+       if ((((u64)_text + offset) >> SWAPPER_TABLE_SHIFT) !=
+           (((u64)_end + offset) >> SWAPPER_TABLE_SHIFT))
+               offset = round_down(offset, 1 << SWAPPER_TABLE_SHIFT);
 
        if (IS_ENABLED(CONFIG_KASAN))
                /*
index 2509e4fe699225675f74876032e22b24b338a3b1..1f22a41565a38ac08083b29fcad216ca4ea1a2c9 100644 (file)
@@ -435,8 +435,11 @@ retry:
                 * the mmap_sem because it would already be released
                 * in __lock_page_or_retry in mm/filemap.c.
                 */
-               if (fatal_signal_pending(current))
+               if (fatal_signal_pending(current)) {
+                       if (!user_mode(regs))
+                               goto no_context;
                        return 0;
+               }
 
                /*
                 * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of
index 36f858c37ca70b576e851a52ada48e2400de86a1..81b0031f909f6d65855ed3051505a4baa9469a64 100644 (file)
@@ -199,7 +199,7 @@ config PPC
        select HAVE_OPTPROBES                   if PPC64
        select HAVE_PERF_EVENTS
        select HAVE_PERF_EVENTS_NMI             if PPC64
-       select HAVE_HARDLOCKUP_DETECTOR_PERF    if HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
+       select HAVE_HARDLOCKUP_DETECTOR_PERF    if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
        select HAVE_PERF_REGS
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_RCU_TABLE_FREE              if SMP
index 0c76675394c5930d5cecf2ac01a2718c8e9b6c1f..35bec1c5bd5aa63567be4847c2073be53fa0390c 100644 (file)
@@ -90,6 +90,24 @@ static inline void switch_mm_irqs_off(struct mm_struct *prev,
        /* Mark this context has been used on the new CPU */
        if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) {
                cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
+
+               /*
+                * This full barrier orders the store to the cpumask above vs
+                * a subsequent operation which allows this CPU to begin loading
+                * translations for next.
+                *
+                * When using the radix MMU that operation is the load of the
+                * MMU context id, which is then moved to SPRN_PID.
+                *
+                * For the hash MMU it is either the first load from slb_cache
+                * in switch_slb(), and/or the store of paca->mm_ctx_id in
+                * copy_mm_to_paca().
+                *
+                * On the read side the barrier is in pte_xchg(), which orders
+                * the store to the PTE vs the load of mm_cpumask.
+                */
+               smp_mb();
+
                new_on_cpu = true;
        }
 
index 9c0f5db5cf461a92e72185701b4cbc1df168dfcc..67e7e3d990f44ef495ee02b6fcb3ba16053bd5c5 100644 (file)
@@ -87,6 +87,7 @@ static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
        unsigned long *p = (unsigned long *)ptep;
        __be64 prev;
 
+       /* See comment in switch_mm_irqs_off() */
        prev = (__force __be64)__cmpxchg_u64(p, (__force unsigned long)pte_raw(old),
                                             (__force unsigned long)pte_raw(new));
 
index 8bd3b13fe2fb2e8bd1c5762c4e080c9cd921edaa..369a164b545c09087e0740fd6c32ea282a7b5245 100644 (file)
@@ -62,6 +62,7 @@ static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
 {
        unsigned long *p = (unsigned long *)ptep;
 
+       /* See comment in switch_mm_irqs_off() */
        return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new));
 }
 #endif
index ec480966f9bf55f17184537f64e7d10c40c723c0..1f0fd361e09b9415f81242d67d9b939f36fd63ba 100644 (file)
@@ -362,7 +362,8 @@ void enable_kernel_vsx(void)
 
        cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX);
 
-       if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) {
+       if (current->thread.regs &&
+           (current->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP))) {
                check_if_tm_restore_required(current);
                /*
                 * If a thread has already been reclaimed then the
@@ -386,7 +387,7 @@ void flush_vsx_to_thread(struct task_struct *tsk)
 {
        if (tsk->thread.regs) {
                preempt_disable();
-               if (tsk->thread.regs->msr & MSR_VSX) {
+               if (tsk->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP)) {
                        BUG_ON(tsk != current);
                        giveup_vsx(tsk);
                }
index a160c14304eba22bd83ee98b8f052a2ed8bf7a3f..53766e2bc029e25efc87270f6983e3b7975be31d 100644 (file)
@@ -294,32 +294,26 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
                                   struct kvm_create_spapr_tce_64 *args)
 {
        struct kvmppc_spapr_tce_table *stt = NULL;
+       struct kvmppc_spapr_tce_table *siter;
        unsigned long npages, size;
        int ret = -ENOMEM;
        int i;
+       int fd = -1;
 
        if (!args->size)
                return -EINVAL;
 
-       /* Check this LIOBN hasn't been previously allocated */
-       list_for_each_entry(stt, &kvm->arch.spapr_tce_tables, list) {
-               if (stt->liobn == args->liobn)
-                       return -EBUSY;
-       }
-
        size = _ALIGN_UP(args->size, PAGE_SIZE >> 3);
        npages = kvmppc_tce_pages(size);
        ret = kvmppc_account_memlimit(kvmppc_stt_pages(npages), true);
-       if (ret) {
-               stt = NULL;
-               goto fail;
-       }
+       if (ret)
+               return ret;
 
        ret = -ENOMEM;
        stt = kzalloc(sizeof(*stt) + npages * sizeof(struct page *),
                      GFP_KERNEL);
        if (!stt)
-               goto fail;
+               goto fail_acct;
 
        stt->liobn = args->liobn;
        stt->page_shift = args->page_shift;
@@ -334,24 +328,42 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
                        goto fail;
        }
 
-       kvm_get_kvm(kvm);
+       ret = fd = anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops,
+                                   stt, O_RDWR | O_CLOEXEC);
+       if (ret < 0)
+               goto fail;
 
        mutex_lock(&kvm->lock);
-       list_add_rcu(&stt->list, &kvm->arch.spapr_tce_tables);
+
+       /* Check this LIOBN hasn't been previously allocated */
+       ret = 0;
+       list_for_each_entry(siter, &kvm->arch.spapr_tce_tables, list) {
+               if (siter->liobn == args->liobn) {
+                       ret = -EBUSY;
+                       break;
+               }
+       }
+
+       if (!ret) {
+               list_add_rcu(&stt->list, &kvm->arch.spapr_tce_tables);
+               kvm_get_kvm(kvm);
+       }
 
        mutex_unlock(&kvm->lock);
 
-       return anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops,
-                               stt, O_RDWR | O_CLOEXEC);
+       if (!ret)
+               return fd;
 
-fail:
-       if (stt) {
-               for (i = 0; i < npages; i++)
-                       if (stt->pages[i])
-                               __free_page(stt->pages[i]);
+       put_unused_fd(fd);
 
-               kfree(stt);
-       }
+ fail:
+       for (i = 0; i < npages; i++)
+               if (stt->pages[i])
+                       __free_page(stt->pages[i]);
+
+       kfree(stt);
+ fail_acct:
+       kvmppc_account_memlimit(kvmppc_stt_pages(npages), false);
        return ret;
 }
 
index c52184a8efdf025c1efffc6dd7310e9374dca630..9c9c983b864f8d64a81eac456adc405cc0252e5d 100644 (file)
@@ -1291,6 +1291,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
        /* Hypervisor doorbell - exit only if host IPI flag set */
        cmpwi   r12, BOOK3S_INTERRUPT_H_DOORBELL
        bne     3f
+BEGIN_FTR_SECTION
+       PPC_MSGSYNC
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
        lbz     r0, HSTATE_HOST_IPI(r13)
        cmpwi   r0, 0
        beq     4f
index 4636ca6e7d383b7d3ce26b18df01152b8087a8ec..d1ed2c41b5d246dde6d53c34530bc30dc63656b9 100644 (file)
@@ -16,7 +16,22 @@ static void GLUE(X_PFX,ack_pending)(struct kvmppc_xive_vcpu *xc)
        u8 cppr;
        u16 ack;
 
-       /* XXX DD1 bug workaround: Check PIPR vs. CPPR first ! */
+       /*
+        * Ensure any previous store to CPPR is ordered vs.
+        * the subsequent loads from PIPR or ACK.
+        */
+       eieio();
+
+       /*
+        * DD1 bug workaround: If PIPR is less favored than CPPR
+        * ignore the interrupt or we might incorrectly lose an IPB
+        * bit.
+        */
+       if (cpu_has_feature(CPU_FTR_POWER9_DD1)) {
+               u8 pipr = __x_readb(__x_tima + TM_QW1_OS + TM_PIPR);
+               if (pipr >= xc->hw_cppr)
+                       return;
+       }
 
        /* Perform the acknowledge OS to register cycle. */
        ack = be16_to_cpu(__x_readw(__x_tima + TM_SPC_ACK_OS_REG));
@@ -235,6 +250,11 @@ skip_ipi:
        /*
         * If we found an interrupt, adjust what the guest CPPR should
         * be as if we had just fetched that interrupt from HW.
+        *
+        * Note: This can only make xc->cppr smaller as the previous
+        * loop will only exit with hirq != 0 if prio is lower than
+        * the current xc->cppr. Thus we don't need to re-check xc->mfrr
+        * for pending IPIs.
         */
        if (hirq)
                xc->cppr = prio;
@@ -380,6 +400,12 @@ X_STATIC int GLUE(X_PFX,h_cppr)(struct kvm_vcpu *vcpu, unsigned long cppr)
        old_cppr = xc->cppr;
        xc->cppr = cppr;
 
+       /*
+        * Order the above update of xc->cppr with the subsequent
+        * read of xc->mfrr inside push_pending_to_hw()
+        */
+       smp_mb();
+
        /*
         * We are masking less, we need to look for pending things
         * to deliver and set VP pending bits accordingly to trigger
@@ -420,21 +446,37 @@ X_STATIC int GLUE(X_PFX,h_eoi)(struct kvm_vcpu *vcpu, unsigned long xirr)
         * used to signal MFRR changes is EOId when fetched from
         * the queue.
         */
-       if (irq == XICS_IPI || irq == 0)
+       if (irq == XICS_IPI || irq == 0) {
+               /*
+                * This barrier orders the setting of xc->cppr vs.
+                * subsquent test of xc->mfrr done inside
+                * scan_interrupts and push_pending_to_hw
+                */
+               smp_mb();
                goto bail;
+       }
 
        /* Find interrupt source */
        sb = kvmppc_xive_find_source(xive, irq, &src);
        if (!sb) {
                pr_devel(" source not found !\n");
                rc = H_PARAMETER;
+               /* Same as above */
+               smp_mb();
                goto bail;
        }
        state = &sb->irq_state[src];
        kvmppc_xive_select_irq(state, &hw_num, &xd);
 
        state->in_eoi = true;
-       mb();
+
+       /*
+        * This barrier orders both setting of in_eoi above vs,
+        * subsequent test of guest_priority, and the setting
+        * of xc->cppr vs. subsquent test of xc->mfrr done inside
+        * scan_interrupts and push_pending_to_hw
+        */
+       smp_mb();
 
 again:
        if (state->guest_priority == MASKED) {
@@ -461,6 +503,14 @@ again:
 
        }
 
+       /*
+        * This barrier orders the above guest_priority check
+        * and spin_lock/unlock with clearing in_eoi below.
+        *
+        * It also has to be a full mb() as it must ensure
+        * the MMIOs done in source_eoi() are completed before
+        * state->in_eoi is visible.
+        */
        mb();
        state->in_eoi = false;
 bail:
@@ -495,6 +545,18 @@ X_STATIC int GLUE(X_PFX,h_ipi)(struct kvm_vcpu *vcpu, unsigned long server,
        /* Locklessly write over MFRR */
        xc->mfrr = mfrr;
 
+       /*
+        * The load of xc->cppr below and the subsequent MMIO store
+        * to the IPI must happen after the above mfrr update is
+        * globally visible so that:
+        *
+        * - Synchronize with another CPU doing an H_EOI or a H_CPPR
+        *   updating xc->cppr then reading xc->mfrr.
+        *
+        * - The target of the IPI sees the xc->mfrr update
+        */
+       mb();
+
        /* Shoot the IPI if most favored than target cppr */
        if (mfrr < xc->cppr)
                __x_writeq(0, __x_trig_page(&xc->vp_ipi_data));
index f36b4b7260577d574e2f8f70a0ca52609eee1ee0..386df9adef0a409ada718390eb3705fba78fc5c3 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/pci.h>
 #include <linux/mutex.h>
+#include <linux/iommu.h>
 #include <asm-generic/pci.h>
 #include <asm/pci_clp.h>
 #include <asm/pci_debug.h>
@@ -122,6 +123,8 @@ struct zpci_dev {
        unsigned long   iommu_pages;
        unsigned int    next_bit;
 
+       struct iommu_device iommu_dev;  /* IOMMU core handle */
+
        char res_name[16];
        struct zpci_bar_struct bars[PCI_BAR_COUNT];
 
@@ -174,6 +177,10 @@ int clp_enable_fh(struct zpci_dev *, u8);
 int clp_disable_fh(struct zpci_dev *);
 int clp_get_state(u32 fid, enum zpci_state *state);
 
+/* IOMMU Interface */
+int zpci_init_iommu(struct zpci_dev *zdev);
+void zpci_destroy_iommu(struct zpci_dev *zdev);
+
 #ifdef CONFIG_PCI
 /* Error handling and recovery */
 void zpci_event_error(void *);
index 926b5244263efd3dd1fadf637ce4790251367e60..a2e5c24f47a7471a1e7730f654b8ce4599434ef0 100644 (file)
@@ -394,7 +394,7 @@ static int sthyi(u64 vaddr)
                "srl     %[cc],28\n"
                : [cc] "=d" (cc)
                : [code] "d" (code), [addr] "a" (addr)
-               : "memory", "cc");
+               : "3", "memory", "cc");
        return cc;
 }
 
@@ -425,7 +425,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
        VCPU_EVENT(vcpu, 3, "STHYI: fc: %llu addr: 0x%016llx", code, addr);
        trace_kvm_s390_handle_sthyi(vcpu, code, addr);
 
-       if (reg1 == reg2 || reg1 & 1 || reg2 & 1 || addr & ~PAGE_MASK)
+       if (reg1 == reg2 || reg1 & 1 || reg2 & 1)
                return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
        if (code & 0xffff) {
@@ -433,6 +433,9 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
                goto out;
        }
 
+       if (addr & ~PAGE_MASK)
+               return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
+
        /*
         * If the page has not yet been faulted in, we want to do that
         * now and not after all the expensive calculations.
index 7b30af5da222a947cceb1cf226945884e0682847..001ca80fa2fe01e176564edf4107e615b665bdef 100644 (file)
@@ -776,6 +776,7 @@ void pcibios_remove_bus(struct pci_bus *bus)
 
        zpci_exit_slot(zdev);
        zpci_cleanup_bus_resources(zdev);
+       zpci_destroy_iommu(zdev);
        zpci_free_domain(zdev);
 
        spin_lock(&zpci_list_lock);
@@ -848,11 +849,15 @@ int zpci_create_device(struct zpci_dev *zdev)
        if (rc)
                goto out;
 
+       rc = zpci_init_iommu(zdev);
+       if (rc)
+               goto out_free;
+
        mutex_init(&zdev->lock);
        if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
                rc = zpci_enable_device(zdev);
                if (rc)
-                       goto out_free;
+                       goto out_destroy_iommu;
        }
        rc = zpci_scan_bus(zdev);
        if (rc)
@@ -869,6 +874,8 @@ int zpci_create_device(struct zpci_dev *zdev)
 out_disable:
        if (zdev->state == ZPCI_FN_STATE_ONLINE)
                zpci_disable_device(zdev);
+out_destroy_iommu:
+       zpci_destroy_iommu(zdev);
 out_free:
        zpci_free_domain(zdev);
 out:
index 0efd0583a8c9da1afc2acc508f2e2e1a5388441d..6249214148c24bb44f2203117200768a410cee2d 100644 (file)
@@ -68,6 +68,7 @@ typedef struct { unsigned long iopgprot; } iopgprot_t;
 #define iopgprot_val(x)        ((x).iopgprot)
 
 #define __pte(x)       ((pte_t) { (x) } )
+#define __pmd(x)       ((pmd_t) { { (x) }, })
 #define __iopte(x)     ((iopte_t) { (x) } )
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __ctxd(x)      ((ctxd_t) { (x) } )
@@ -95,6 +96,7 @@ typedef unsigned long iopgprot_t;
 #define iopgprot_val(x)        (x)
 
 #define __pte(x)       (x)
+#define __pmd(x)       ((pmd_t) { { (x) }, })
 #define __iopte(x)     (x)
 #define __pgd(x)       (x)
 #define __ctxd(x)      (x)
index f10e2f7123949dedc8904ea37895d402ed097d2b..9ebebf1fd93d2f5db8c09804c336b006041b28af 100644 (file)
@@ -1266,8 +1266,6 @@ static int pci_sun4v_probe(struct platform_device *op)
                         * ATU group, but ATU hcalls won't be available.
                         */
                        hv_atu = false;
-                       pr_err(PFX "Could not register hvapi ATU err=%d\n",
-                              err);
                } else {
                        pr_info(PFX "Registered hvapi ATU major[%lu] minor[%lu]\n",
                                vatu_major, vatu_minor);
index a38787b843220807d0f5527f864981fc75e8486f..732af9a9f6ddef510e39da7d6eca5547e210296e 100644 (file)
@@ -602,7 +602,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 {
        struct pci_dev *dev;
        int i, has_io, has_mem;
-       unsigned int cmd;
+       unsigned int cmd = 0;
        struct linux_pcic *pcic;
        /* struct linux_pbm_info* pbm = &pcic->pbm; */
        int node;
index d6b6c97fe3c73061f911737a5da23ab41a3eab77..703127aaf4a5015ee4a1099e6129735f7162222b 100644 (file)
@@ -5,26 +5,26 @@
        .align  4
 ENTRY(__multi3) /* %o0 = u, %o1 = v */
        mov     %o1, %g1
-       srl     %o3, 0, %g4
-       mulx    %g4, %g1, %o1
+       srl     %o3, 0, %o4
+       mulx    %o4, %g1, %o1
        srlx    %g1, 0x20, %g3
-       mulx    %g3, %g4, %g5
-       sllx    %g5, 0x20, %o5
-       srl     %g1, 0, %g4
+       mulx    %g3, %o4, %g7
+       sllx    %g7, 0x20, %o5
+       srl     %g1, 0, %o4
        sub     %o1, %o5, %o5
        srlx    %o5, 0x20, %o5
-       addcc   %g5, %o5, %g5
+       addcc   %g7, %o5, %g7
        srlx    %o3, 0x20, %o5
-       mulx    %g4, %o5, %g4
+       mulx    %o4, %o5, %o4
        mulx    %g3, %o5, %o5
        sethi   %hi(0x80000000), %g3
-       addcc   %g5, %g4, %g5
-       srlx    %g5, 0x20, %g5
+       addcc   %g7, %o4, %g7
+       srlx    %g7, 0x20, %g7
        add     %g3, %g3, %g3
        movcc   %xcc, %g0, %g3
-       addcc   %o5, %g5, %o5
-       sllx    %g4, 0x20, %g4
-       add     %o1, %g4, %o1
+       addcc   %o5, %g7, %o5
+       sllx    %o4, 0x20, %o4
+       add     %o1, %o4, %o1
        add     %o5, %g3, %g2
        mulx    %g1, %o2, %g1
        add     %g1, %g2, %g1
index 781521b7cf9ef6b6766dac9249a3568f257c4fa8..323cb065be5eda120b44dac79618a13301ece231 100644 (file)
@@ -100,6 +100,7 @@ config X86
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
        select GENERIC_TIME_VSYSCALL
+       select HARDLOCKUP_CHECK_TIMESTAMP       if X86_64
        select HAVE_ACPI_APEI                   if ACPI
        select HAVE_ACPI_APEI_NMI               if ACPI
        select HAVE_ALIGNED_STRUCT_PAGE         if SLUB
@@ -163,7 +164,7 @@ config X86
        select HAVE_PCSPKR_PLATFORM
        select HAVE_PERF_EVENTS
        select HAVE_PERF_EVENTS_NMI
-       select HAVE_HARDLOCKUP_DETECTOR_PERF    if HAVE_PERF_EVENTS_NMI
+       select HAVE_HARDLOCKUP_DETECTOR_PERF    if PERF_EVENTS && HAVE_PERF_EVENTS_NMI
        select HAVE_PERF_REGS
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_REGS_AND_STACK_ACCESS_API
index 1cd792db15efe760e3a6fc8b17b9a4c4e6f35233..1eab79c9ac484172a63d9cc0c4a409b7fffe7e8b 100644 (file)
        .set T1, REG_T1
 .endm
 
-#define K_BASE         %r8
 #define HASH_PTR       %r9
+#define BLOCKS_CTR     %r8
 #define BUFFER_PTR     %r10
 #define BUFFER_PTR2    %r13
-#define BUFFER_END     %r11
 
 #define PRECALC_BUF    %r14
 #define WK_BUF         %r15
                 * blended AVX2 and ALU instruction scheduling
                 * 1 vector iteration per 8 rounds
                 */
-               vmovdqu ((i * 2) + PRECALC_OFFSET)(BUFFER_PTR), W_TMP
+               vmovdqu (i * 2)(BUFFER_PTR), W_TMP
        .elseif ((i & 7) == 1)
-               vinsertf128 $1, (((i-1) * 2)+PRECALC_OFFSET)(BUFFER_PTR2),\
+               vinsertf128 $1, ((i-1) * 2)(BUFFER_PTR2),\
                         WY_TMP, WY_TMP
        .elseif ((i & 7) == 2)
                vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY
        .elseif ((i & 7) == 4)
-               vpaddd  K_XMM(K_BASE), WY, WY_TMP
+               vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
        .elseif ((i & 7) == 7)
                vmovdqu  WY_TMP, PRECALC_WK(i&~7)
 
                vpxor   WY, WY_TMP, WY_TMP
        .elseif ((i & 7) == 7)
                vpxor   WY_TMP2, WY_TMP, WY
-               vpaddd  K_XMM(K_BASE), WY, WY_TMP
+               vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
                vmovdqu WY_TMP, PRECALC_WK(i&~7)
 
                PRECALC_ROTATE_WY
                vpsrld  $30, WY, WY
                vpor    WY, WY_TMP, WY
        .elseif ((i & 7) == 7)
-               vpaddd  K_XMM(K_BASE), WY, WY_TMP
+               vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
                vmovdqu WY_TMP, PRECALC_WK(i&~7)
 
                PRECALC_ROTATE_WY
 
 .endm
 
+/* Add constant only if (%2 > %3) condition met (uses RTA as temp)
+ * %1 + %2 >= %3 ? %4 : 0
+ */
+.macro ADD_IF_GE a, b, c, d
+       mov     \a, RTA
+       add     $\d, RTA
+       cmp     $\c, \b
+       cmovge  RTA, \a
+.endm
+
 /*
  * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining
  */
        lea     (2*4*80+32)(%rsp), WK_BUF
 
        # Precalc WK for first 2 blocks
-       PRECALC_OFFSET = 0
+       ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 2, 64
        .set i, 0
        .rept    160
                PRECALC i
                .set i, i + 1
        .endr
-       PRECALC_OFFSET = 128
+
+       /* Go to next block if needed */
+       ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 3, 128
+       ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
        xchg    WK_BUF, PRECALC_BUF
 
        .align 32
@@ -479,8 +491,8 @@ _loop:
         * we use K_BASE value as a signal of a last block,
         * it is set below by: cmovae BUFFER_PTR, K_BASE
         */
-       cmp     K_BASE, BUFFER_PTR
-       jne     _begin
+       test BLOCKS_CTR, BLOCKS_CTR
+       jnz _begin
        .align 32
        jmp     _end
        .align 32
@@ -512,10 +524,10 @@ _loop0:
                .set j, j+2
        .endr
 
-       add     $(2*64), BUFFER_PTR       /* move to next odd-64-byte block */
-       cmp     BUFFER_END, BUFFER_PTR    /* is current block the last one? */
-       cmovae  K_BASE, BUFFER_PTR      /* signal the last iteration smartly */
-
+       /* Update Counter */
+       sub $1, BLOCKS_CTR
+       /* Move to the next block only if needed*/
+       ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 4, 128
        /*
         * rounds
         * 60,62,64,66,68
@@ -532,8 +544,8 @@ _loop0:
        UPDATE_HASH     12(HASH_PTR), D
        UPDATE_HASH     16(HASH_PTR), E
 
-       cmp     K_BASE, BUFFER_PTR      /* is current block the last one? */
-       je      _loop
+       test    BLOCKS_CTR, BLOCKS_CTR
+       jz      _loop
 
        mov     TB, B
 
@@ -575,10 +587,10 @@ _loop2:
                .set j, j+2
        .endr
 
-       add     $(2*64), BUFFER_PTR2      /* move to next even-64-byte block */
-
-       cmp     BUFFER_END, BUFFER_PTR2   /* is current block the last one */
-       cmovae  K_BASE, BUFFER_PTR       /* signal the last iteration smartly */
+       /* update counter */
+       sub     $1, BLOCKS_CTR
+       /* Move to the next block only if needed*/
+       ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
 
        jmp     _loop3
 _loop3:
@@ -641,19 +653,12 @@ _loop3:
 
        avx2_zeroupper
 
-       lea     K_XMM_AR(%rip), K_BASE
-
+       /* Setup initial values */
        mov     CTX, HASH_PTR
        mov     BUF, BUFFER_PTR
-       lea     64(BUF), BUFFER_PTR2
-
-       shl     $6, CNT                 /* mul by 64 */
-       add     BUF, CNT
-       add     $64, CNT
-       mov     CNT, BUFFER_END
 
-       cmp     BUFFER_END, BUFFER_PTR2
-       cmovae  K_BASE, BUFFER_PTR2
+       mov     BUF, BUFFER_PTR2
+       mov     CNT, BLOCKS_CTR
 
        xmm_mov BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP
 
index f960a043cdeba4a36f4ba20fddf81369f8ced38f..fc61739150e7c2c5a484c020b14441551fe5403a 100644 (file)
@@ -201,7 +201,7 @@ asmlinkage void sha1_transform_avx2(u32 *digest, const char *data,
 
 static bool avx2_usable(void)
 {
-       if (false && avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
+       if (avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
                && boot_cpu_has(X86_FEATURE_BMI1)
                && boot_cpu_has(X86_FEATURE_BMI2))
                return true;
index d271fb79248f3569c6a0a934f707d91f398562b8..6d078b89a5e887de4d9cbe1c42f3ed34d9682642 100644 (file)
@@ -1211,6 +1211,8 @@ ENTRY(nmi)
         * other IST entries.
         */
 
+       ASM_CLAC
+
        /* Use %rdx as our temp variable throughout */
        pushq   %rdx
 
index 8e3db8f642a7a02dd8f99db3a25dedbfd1deb01a..af12e294caeda5f518cf8b80ce5765996f1d8c56 100644 (file)
@@ -2114,7 +2114,7 @@ static void refresh_pce(void *ignored)
        load_mm_cr4(this_cpu_read(cpu_tlbstate.loaded_mm));
 }
 
-static void x86_pmu_event_mapped(struct perf_event *event)
+static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)
 {
        if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
                return;
@@ -2129,22 +2129,20 @@ static void x86_pmu_event_mapped(struct perf_event *event)
         * For now, this can't happen because all callers hold mmap_sem
         * for write.  If this changes, we'll need a different solution.
         */
-       lockdep_assert_held_exclusive(&current->mm->mmap_sem);
+       lockdep_assert_held_exclusive(&mm->mmap_sem);
 
-       if (atomic_inc_return(&current->mm->context.perf_rdpmc_allowed) == 1)
-               on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1);
+       if (atomic_inc_return(&mm->context.perf_rdpmc_allowed) == 1)
+               on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1);
 }
 
-static void x86_pmu_event_unmapped(struct perf_event *event)
+static void x86_pmu_event_unmapped(struct perf_event *event, struct mm_struct *mm)
 {
-       if (!current->mm)
-               return;
 
        if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
                return;
 
-       if (atomic_dec_and_test(&current->mm->context.perf_rdpmc_allowed))
-               on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1);
+       if (atomic_dec_and_test(&mm->context.perf_rdpmc_allowed))
+               on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1);
 }
 
 static int x86_pmu_event_idx(struct perf_event *event)
index 8ae8c5ce3a1f94debb2fe81f5652cbd7b35f2c4a..ddd8d3516bfcfa58fc3baf7b3f4f70b7231190ab 100644 (file)
@@ -69,7 +69,7 @@ struct bts_buffer {
        struct bts_phys buf[0];
 };
 
-struct pmu bts_pmu;
+static struct pmu bts_pmu;
 
 static size_t buf_size(struct page *page)
 {
index eb0533558c2b705957a30704218b983eda65e61e..d32c0eed38ca92665d378fa2d0792eed12aad818 100644 (file)
@@ -587,7 +587,7 @@ static __initconst const u64 p4_hw_cache_event_ids
  * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are
  * either up to date automatically or not applicable at all.
  */
-struct p4_event_alias {
+static struct p4_event_alias {
        u64 original;
        u64 alternative;
 } p4_event_aliases[] = {
index a45e2114a8460925b44bd6e0983f3ee37e83d861..8e2457cb6b4a416e1c84d9baa990ea512ec74ba0 100644 (file)
@@ -559,7 +559,7 @@ static struct attribute_group rapl_pmu_format_group = {
        .attrs = rapl_formats_attr,
 };
 
-const struct attribute_group *rapl_attr_groups[] = {
+static const struct attribute_group *rapl_attr_groups[] = {
        &rapl_pmu_attr_group,
        &rapl_pmu_format_group,
        &rapl_pmu_events_group,
index 44ec523287f670dff8eee3e3c9eb1bb1606489b6..1c5390f1cf0992787afa8d34bb361f622b00dcb2 100644 (file)
@@ -721,7 +721,7 @@ static struct attribute *uncore_pmu_attrs[] = {
        NULL,
 };
 
-static struct attribute_group uncore_pmu_attr_group = {
+static const struct attribute_group uncore_pmu_attr_group = {
        .attrs = uncore_pmu_attrs,
 };
 
index cda56933200503662d133050fc47bdae050e8d61..6a5cbe90f8593eb23a7a403132240fc9afc87c9d 100644 (file)
@@ -272,7 +272,7 @@ static struct attribute *nhmex_uncore_ubox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_ubox_format_group = {
+static const struct attribute_group nhmex_uncore_ubox_format_group = {
        .name           = "format",
        .attrs          = nhmex_uncore_ubox_formats_attr,
 };
@@ -299,7 +299,7 @@ static struct attribute *nhmex_uncore_cbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_cbox_format_group = {
+static const struct attribute_group nhmex_uncore_cbox_format_group = {
        .name = "format",
        .attrs = nhmex_uncore_cbox_formats_attr,
 };
@@ -407,7 +407,7 @@ static struct attribute *nhmex_uncore_bbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_bbox_format_group = {
+static const struct attribute_group nhmex_uncore_bbox_format_group = {
        .name = "format",
        .attrs = nhmex_uncore_bbox_formats_attr,
 };
@@ -484,7 +484,7 @@ static struct attribute *nhmex_uncore_sbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_sbox_format_group = {
+static const struct attribute_group nhmex_uncore_sbox_format_group = {
        .name                   = "format",
        .attrs                  = nhmex_uncore_sbox_formats_attr,
 };
@@ -898,7 +898,7 @@ static struct attribute *nhmex_uncore_mbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_mbox_format_group = {
+static const struct attribute_group nhmex_uncore_mbox_format_group = {
        .name           = "format",
        .attrs          = nhmex_uncore_mbox_formats_attr,
 };
@@ -1163,7 +1163,7 @@ static struct attribute *nhmex_uncore_rbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_rbox_format_group = {
+static const struct attribute_group nhmex_uncore_rbox_format_group = {
        .name = "format",
        .attrs = nhmex_uncore_rbox_formats_attr,
 };
index a3dcc12bef4ab3a67aab29c6acf3480920e06952..db1127ce685eb8ea687bb4e0279f13ad5706a59f 100644 (file)
@@ -130,7 +130,7 @@ static struct attribute *snb_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group snb_uncore_format_group = {
+static const struct attribute_group snb_uncore_format_group = {
        .name           = "format",
        .attrs          = snb_uncore_formats_attr,
 };
@@ -289,7 +289,7 @@ static struct attribute *snb_uncore_imc_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group snb_uncore_imc_format_group = {
+static const struct attribute_group snb_uncore_imc_format_group = {
        .name = "format",
        .attrs = snb_uncore_imc_formats_attr,
 };
@@ -769,7 +769,7 @@ static struct attribute *nhm_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhm_uncore_format_group = {
+static const struct attribute_group nhm_uncore_format_group = {
        .name = "format",
        .attrs = nhm_uncore_formats_attr,
 };
index 4f9127644b80abd87d4c49204dde197a9ade7ac2..db1fe377e6dd9ddfcfbc006a7346879f263d408a 100644 (file)
@@ -602,27 +602,27 @@ static struct uncore_event_desc snbep_uncore_qpi_events[] = {
        { /* end: all zeroes */ },
 };
 
-static struct attribute_group snbep_uncore_format_group = {
+static const struct attribute_group snbep_uncore_format_group = {
        .name = "format",
        .attrs = snbep_uncore_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_ubox_format_group = {
+static const struct attribute_group snbep_uncore_ubox_format_group = {
        .name = "format",
        .attrs = snbep_uncore_ubox_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_cbox_format_group = {
+static const struct attribute_group snbep_uncore_cbox_format_group = {
        .name = "format",
        .attrs = snbep_uncore_cbox_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_pcu_format_group = {
+static const struct attribute_group snbep_uncore_pcu_format_group = {
        .name = "format",
        .attrs = snbep_uncore_pcu_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_qpi_format_group = {
+static const struct attribute_group snbep_uncore_qpi_format_group = {
        .name = "format",
        .attrs = snbep_uncore_qpi_formats_attr,
 };
@@ -1431,27 +1431,27 @@ static struct attribute *ivbep_uncore_qpi_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group ivbep_uncore_format_group = {
+static const struct attribute_group ivbep_uncore_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_ubox_format_group = {
+static const struct attribute_group ivbep_uncore_ubox_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_ubox_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_cbox_format_group = {
+static const struct attribute_group ivbep_uncore_cbox_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_cbox_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_pcu_format_group = {
+static const struct attribute_group ivbep_uncore_pcu_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_pcu_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_qpi_format_group = {
+static const struct attribute_group ivbep_uncore_qpi_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_qpi_formats_attr,
 };
@@ -1887,7 +1887,7 @@ static struct attribute *knl_uncore_ubox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_ubox_format_group = {
+static const struct attribute_group knl_uncore_ubox_format_group = {
        .name = "format",
        .attrs = knl_uncore_ubox_formats_attr,
 };
@@ -1927,7 +1927,7 @@ static struct attribute *knl_uncore_cha_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_cha_format_group = {
+static const struct attribute_group knl_uncore_cha_format_group = {
        .name = "format",
        .attrs = knl_uncore_cha_formats_attr,
 };
@@ -2037,7 +2037,7 @@ static struct attribute *knl_uncore_pcu_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_pcu_format_group = {
+static const struct attribute_group knl_uncore_pcu_format_group = {
        .name = "format",
        .attrs = knl_uncore_pcu_formats_attr,
 };
@@ -2187,7 +2187,7 @@ static struct attribute *knl_uncore_irp_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_irp_format_group = {
+static const struct attribute_group knl_uncore_irp_format_group = {
        .name = "format",
        .attrs = knl_uncore_irp_formats_attr,
 };
@@ -2385,7 +2385,7 @@ static struct attribute *hswep_uncore_ubox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group hswep_uncore_ubox_format_group = {
+static const struct attribute_group hswep_uncore_ubox_format_group = {
        .name = "format",
        .attrs = hswep_uncore_ubox_formats_attr,
 };
@@ -2439,7 +2439,7 @@ static struct attribute *hswep_uncore_cbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group hswep_uncore_cbox_format_group = {
+static const struct attribute_group hswep_uncore_cbox_format_group = {
        .name = "format",
        .attrs = hswep_uncore_cbox_formats_attr,
 };
@@ -2621,7 +2621,7 @@ static struct attribute *hswep_uncore_sbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group hswep_uncore_sbox_format_group = {
+static const struct attribute_group hswep_uncore_sbox_format_group = {
        .name = "format",
        .attrs = hswep_uncore_sbox_formats_attr,
 };
@@ -3314,7 +3314,7 @@ static struct attribute *skx_uncore_cha_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_uncore_chabox_format_group = {
+static const struct attribute_group skx_uncore_chabox_format_group = {
        .name = "format",
        .attrs = skx_uncore_cha_formats_attr,
 };
@@ -3427,7 +3427,7 @@ static struct attribute *skx_uncore_iio_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_uncore_iio_format_group = {
+static const struct attribute_group skx_uncore_iio_format_group = {
        .name = "format",
        .attrs = skx_uncore_iio_formats_attr,
 };
@@ -3484,7 +3484,7 @@ static struct attribute *skx_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_uncore_format_group = {
+static const struct attribute_group skx_uncore_format_group = {
        .name = "format",
        .attrs = skx_uncore_formats_attr,
 };
@@ -3605,7 +3605,7 @@ static struct attribute *skx_upi_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_upi_uncore_format_group = {
+static const struct attribute_group skx_upi_uncore_format_group = {
        .name = "format",
        .attrs = skx_upi_uncore_formats_attr,
 };
index ca3c48c0872f4beba6b03ac92c50eb6a352b3006..5a28e8e55e36fd2164c0cda175288a7fcc534c4b 100644 (file)
 #define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */
 #define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */
 #define X86_FEATURE_AVIC       (15*32+13) /* Virtual Interrupt Controller */
-#define X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE (15*32+15) /* Virtual VMLOAD VMSAVE */
+#define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */
 #define X86_FEATURE_AVX512VBMI  (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
index 1c18d83d3f094d1f5abfa09a08b67e9cb6b7376d..9aeb91935ce02387d8dae5e2f51bf1750f420a43 100644 (file)
@@ -247,11 +247,11 @@ extern int force_personality32;
 
 /*
  * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
+ * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
 #define ELF_ET_DYN_BASE                (mmap_is_ia32() ? 0x000400000UL : \
-                                                 0x100000000UL)
+                                                 (TASK_SIZE / 3 * 2))
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports.  This could be done in user space,
index 255645f60ca2b4be333de67a10c6780f364e6fb2..554cdb205d17586887e6b599c991b2fc090ba38a 100644 (file)
@@ -450,10 +450,10 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
        return 0;
 }
 
-static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate)
+static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate, u64 mask)
 {
        if (use_xsave()) {
-               copy_kernel_to_xregs(&fpstate->xsave, -1);
+               copy_kernel_to_xregs(&fpstate->xsave, mask);
        } else {
                if (use_fxsr())
                        copy_kernel_to_fxregs(&fpstate->fxsave);
@@ -477,7 +477,7 @@ static inline void copy_kernel_to_fpregs(union fpregs_state *fpstate)
                        : : [addr] "m" (fpstate));
        }
 
-       __copy_kernel_to_fpregs(fpstate);
+       __copy_kernel_to_fpregs(fpstate, -1);
 }
 
 extern int copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int size);
index 87ac4fba6d8e12f07e8a9f191bdb028a1c3e6234..f4d120a3e22e8aee8326bebeedeaa506c2291b47 100644 (file)
@@ -492,6 +492,7 @@ struct kvm_vcpu_arch {
        unsigned long cr4;
        unsigned long cr4_guest_owned_bits;
        unsigned long cr8;
+       u32 pkru;
        u32 hflags;
        u64 efer;
        u64 apic_base;
index 265c907d7d4c9b8c69e24792a20c5a3dfb6c95ee..7a234be7e29846618cbdafb0153705cb8a8566b3 100644 (file)
@@ -140,9 +140,7 @@ static inline int init_new_context(struct task_struct *tsk,
                mm->context.execute_only_pkey = -1;
        }
        #endif
-       init_new_context_ldt(tsk, mm);
-
-       return 0;
+       return init_new_context_ldt(tsk, mm);
 }
 static inline void destroy_context(struct mm_struct *mm)
 {
index 7cf7c70b6ef2a20483361fb8333a85ace25bf1d7..0ee83321a3136fcca7a00a3b7e6c375e7a51e13f 100644 (file)
@@ -40,13 +40,16 @@ static void aperfmperf_snapshot_khz(void *dummy)
        struct aperfmperf_sample *s = this_cpu_ptr(&samples);
        ktime_t now = ktime_get();
        s64 time_delta = ktime_ms_delta(now, s->time);
+       unsigned long flags;
 
        /* Don't bother re-computing within the cache threshold time. */
        if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS)
                return;
 
+       local_irq_save(flags);
        rdmsrl(MSR_IA32_APERF, aperf);
        rdmsrl(MSR_IA32_MPERF, mperf);
+       local_irq_restore(flags);
 
        aperf_delta = aperf - s->aperf;
        mperf_delta = mperf - s->mperf;
index d7cc190ae45719bf84d721e781dc7fde00c85e14..f7370abd33c67570ad713a03a20f9114e6ad6399 100644 (file)
@@ -122,7 +122,7 @@ static struct attribute *thermal_throttle_attrs[] = {
        NULL
 };
 
-static struct attribute_group thermal_attr_group = {
+static const struct attribute_group thermal_attr_group = {
        .attrs  = thermal_throttle_attrs,
        .name   = "thermal_throttle"
 };
index 9cb98ee103db1bf0cdc2349614fe0d4e59cfb21f..86e8f0b2537b3eaedd2da204d67c94947a1b16f1 100644 (file)
@@ -561,7 +561,7 @@ static struct attribute *mc_default_attrs[] = {
        NULL
 };
 
-static struct attribute_group mc_attr_group = {
+static const struct attribute_group mc_attr_group = {
        .attrs                  = mc_default_attrs,
        .name                   = "microcode",
 };
@@ -707,7 +707,7 @@ static struct attribute *cpu_root_microcode_attrs[] = {
        NULL
 };
 
-static struct attribute_group cpu_root_microcode_group = {
+static const struct attribute_group cpu_root_microcode_group = {
        .name  = "microcode",
        .attrs = cpu_root_microcode_attrs,
 };
index c5bb63be4ba1e6a2df1203fe73079faad9fc62e7..40d5a8a752125ed5d26a7605d5eabad572879bfc 100644 (file)
@@ -237,6 +237,18 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ
        stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask);
 }
 
+static void set_mtrr_cpuslocked(unsigned int reg, unsigned long base,
+                               unsigned long size, mtrr_type type)
+{
+       struct set_mtrr_data data = { .smp_reg = reg,
+                                     .smp_base = base,
+                                     .smp_size = size,
+                                     .smp_type = type
+                                   };
+
+       stop_machine_cpuslocked(mtrr_rendezvous_handler, &data, cpu_online_mask);
+}
+
 static void set_mtrr_from_inactive_cpu(unsigned int reg, unsigned long base,
                                      unsigned long size, mtrr_type type)
 {
@@ -370,7 +382,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
        /* Search for an empty MTRR */
        i = mtrr_if->get_free_region(base, size, replace);
        if (i >= 0) {
-               set_mtrr(i, base, size, type);
+               set_mtrr_cpuslocked(i, base, size, type);
                if (likely(replace < 0)) {
                        mtrr_usage_table[i] = 1;
                } else {
@@ -378,7 +390,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
                        if (increment)
                                mtrr_usage_table[i]++;
                        if (unlikely(replace != i)) {
-                               set_mtrr(replace, 0, 0, 0);
+                               set_mtrr_cpuslocked(replace, 0, 0, 0);
                                mtrr_usage_table[replace] = 0;
                        }
                }
@@ -506,7 +518,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
                goto out;
        }
        if (--mtrr_usage_table[reg] < 1)
-               set_mtrr(reg, 0, 0, 0);
+               set_mtrr_cpuslocked(reg, 0, 0, 0);
        error = reg;
  out:
        mutex_unlock(&mtrr_mutex);
index 46c3c73e7f43f5fbb56fe0028d8aafb64a3f8a9e..9ba79543d9ee9f1ee19bce38955467afa04b125f 100644 (file)
@@ -53,6 +53,7 @@ void __head __startup_64(unsigned long physaddr)
        pudval_t *pud;
        pmdval_t *pmd, pmd_entry;
        int i;
+       unsigned int *next_pgt_ptr;
 
        /* Is the address too large? */
        if (physaddr >> MAX_PHYSMEM_BITS)
@@ -91,9 +92,9 @@ void __head __startup_64(unsigned long physaddr)
         * creates a bunch of nonsense entries but that is fine --
         * it avoids problems around wraparound.
         */
-
-       pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
-       pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
+       next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr);
+       pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
+       pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
 
        if (IS_ENABLED(CONFIG_X86_5LEVEL)) {
                p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
index 4afc67f5facc497606e2fb898ba7b7d402f04caa..06e1ff5562c0b4a5a28f3c052ed74b545c7ccca0 100644 (file)
@@ -55,7 +55,7 @@ static struct bin_attribute *boot_params_data_attrs[] = {
        NULL,
 };
 
-static struct attribute_group boot_params_attr_group = {
+static const struct attribute_group boot_params_attr_group = {
        .attrs = boot_params_version_attrs,
        .bin_attrs = boot_params_data_attrs,
 };
@@ -202,7 +202,7 @@ static struct bin_attribute *setup_data_data_attrs[] = {
        NULL,
 };
 
-static struct attribute_group setup_data_attr_group = {
+static const struct attribute_group setup_data_attr_group = {
        .attrs = setup_data_type_attrs,
        .bin_attrs = setup_data_data_attrs,
 };
index b474c8de7fba09cfe27d1e0124f694d152654570..54b9e89d4d6be3844b8b3c310433467d0e5f1481 100644 (file)
@@ -971,7 +971,8 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
  * Returns zero if CPU booted OK, else error code from
  * ->wakeup_secondary_cpu.
  */
-static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
+static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
+                      int *cpu0_nmi_registered)
 {
        volatile u32 *trampoline_status =
                (volatile u32 *) __va(real_mode_header->trampoline_status);
@@ -979,7 +980,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
        unsigned long start_ip = real_mode_header->trampoline_start;
 
        unsigned long boot_error = 0;
-       int cpu0_nmi_registered = 0;
        unsigned long timeout;
 
        idle->thread.sp = (unsigned long)task_pt_regs(idle);
@@ -1035,7 +1035,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
                boot_error = apic->wakeup_secondary_cpu(apicid, start_ip);
        else
                boot_error = wakeup_cpu_via_init_nmi(cpu, start_ip, apicid,
-                                                    &cpu0_nmi_registered);
+                                                    cpu0_nmi_registered);
 
        if (!boot_error) {
                /*
@@ -1080,12 +1080,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
                 */
                smpboot_restore_warm_reset_vector();
        }
-       /*
-        * Clean up the nmi handler. Do this after the callin and callout sync
-        * to avoid impact of possible long unregister time.
-        */
-       if (cpu0_nmi_registered)
-               unregister_nmi_handler(NMI_LOCAL, "wake_cpu0");
 
        return boot_error;
 }
@@ -1093,8 +1087,9 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
 int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        int apicid = apic->cpu_present_to_apicid(cpu);
+       int cpu0_nmi_registered = 0;
        unsigned long flags;
-       int err;
+       int err, ret = 0;
 
        WARN_ON(irqs_disabled());
 
@@ -1131,10 +1126,11 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
 
        common_cpu_up(cpu, tidle);
 
-       err = do_boot_cpu(apicid, cpu, tidle);
+       err = do_boot_cpu(apicid, cpu, tidle, &cpu0_nmi_registered);
        if (err) {
                pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu);
-               return -EIO;
+               ret = -EIO;
+               goto unreg_nmi;
        }
 
        /*
@@ -1150,7 +1146,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
                touch_nmi_watchdog();
        }
 
-       return 0;
+unreg_nmi:
+       /*
+        * Clean up the nmi handler. Do this after the callin and callout sync
+        * to avoid impact of possible long unregister time.
+        */
+       if (cpu0_nmi_registered)
+               unregister_nmi_handler(NMI_LOCAL, "wake_cpu0");
+
+       return ret;
 }
 
 /**
index 59ca2eea522c466937287c3e660b8f38e49c12aa..19adbb4184439dd6c40c39cd6dec2afe5a9ae83a 100644 (file)
@@ -469,7 +469,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
                        entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
                        cpuid_mask(&entry->ecx, CPUID_7_ECX);
                        /* PKU is not yet implemented for shadow paging. */
-                       if (!tdp_enabled)
+                       if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
                                entry->ecx &= ~F(PKU);
                        entry->edx &= kvm_cpuid_7_0_edx_x86_features;
                        entry->edx &= get_scattered_cpuid_leaf(7, 0, CPUID_EDX);
index 762cdf2595f992fd4ac8bb1e4c2c8914b344db04..e1e89ee4af750dc51f78cfbf8aa71e22d77b4cd1 100644 (file)
@@ -84,11 +84,6 @@ static inline u64 kvm_read_edx_eax(struct kvm_vcpu *vcpu)
                | ((u64)(kvm_register_read(vcpu, VCPU_REGS_RDX) & -1u) << 32);
 }
 
-static inline u32 kvm_read_pkru(struct kvm_vcpu *vcpu)
-{
-       return kvm_x86_ops->get_pkru(vcpu);
-}
-
 static inline void enter_guest_mode(struct kvm_vcpu *vcpu)
 {
        vcpu->arch.hflags |= HF_GUEST_MASK;
index d7d248a000dd6772681f3f5541e344f9677a2d1d..4b9a3ae6b725d37bdeeb5aeb24c0a9c2716228f4 100644 (file)
@@ -185,7 +185,7 @@ static inline u8 permission_fault(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
                * index of the protection domain, so pte_pkey * 2 is
                * is the index of the first bit for the domain.
                */
-               pkru_bits = (kvm_read_pkru(vcpu) >> (pte_pkey * 2)) & 3;
+               pkru_bits = (vcpu->arch.pkru >> (pte_pkey * 2)) & 3;
 
                /* clear present bit, replace PFEC.RSVD with ACC_USER_MASK. */
                offset = (pfec & ~1) +
index 1107626938ccff4f26da130f8b570928ca7c8efb..af256b786a70cccd14906fe926e2b790156967a4 100644 (file)
@@ -1100,7 +1100,7 @@ static __init int svm_hardware_setup(void)
 
        if (vls) {
                if (!npt_enabled ||
-                   !boot_cpu_has(X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE) ||
+                   !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
                    !IS_ENABLED(CONFIG_X86_64)) {
                        vls = false;
                } else {
@@ -1777,11 +1777,6 @@ static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
        to_svm(vcpu)->vmcb->save.rflags = rflags;
 }
 
-static u32 svm_get_pkru(struct kvm_vcpu *vcpu)
-{
-       return 0;
-}
-
 static void svm_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
 {
        switch (reg) {
@@ -5413,8 +5408,6 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .get_rflags = svm_get_rflags,
        .set_rflags = svm_set_rflags,
 
-       .get_pkru = svm_get_pkru,
-
        .tlb_flush = svm_flush_tlb,
 
        .run = svm_vcpu_run,
index 9b21b12230354e334900e6536b7612285f75b7e3..c6ef2940119bfdfb00f0547c321697280ebae0fa 100644 (file)
@@ -636,8 +636,6 @@ struct vcpu_vmx {
 
        u64 current_tsc_ratio;
 
-       bool guest_pkru_valid;
-       u32 guest_pkru;
        u32 host_pkru;
 
        /*
@@ -2383,11 +2381,6 @@ static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
                to_vmx(vcpu)->emulation_required = emulation_required(vcpu);
 }
 
-static u32 vmx_get_pkru(struct kvm_vcpu *vcpu)
-{
-       return to_vmx(vcpu)->guest_pkru;
-}
-
 static u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu)
 {
        u32 interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
@@ -9020,8 +9013,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
        if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
                vmx_set_interrupt_shadow(vcpu, 0);
 
-       if (vmx->guest_pkru_valid)
-               __write_pkru(vmx->guest_pkru);
+       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);
 
        atomic_switch_perf_msrs(vmx);
        debugctlmsr = get_debugctlmsr();
@@ -9169,13 +9164,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
         * back on host, so it is safe to read guest PKRU from current
         * XSAVE.
         */
-       if (boot_cpu_has(X86_FEATURE_OSPKE)) {
-               vmx->guest_pkru = __read_pkru();
-               if (vmx->guest_pkru != vmx->host_pkru) {
-                       vmx->guest_pkru_valid = true;
+       if (static_cpu_has(X86_FEATURE_PKU) &&
+           kvm_read_cr4_bits(vcpu, X86_CR4_PKE)) {
+               vcpu->arch.pkru = __read_pkru();
+               if (vcpu->arch.pkru != vmx->host_pkru)
                        __write_pkru(vmx->host_pkru);
-               } else
-                       vmx->guest_pkru_valid = false;
        }
 
        /*
@@ -11682,8 +11675,6 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
        .get_rflags = vmx_get_rflags,
        .set_rflags = vmx_set_rflags,
 
-       .get_pkru = vmx_get_pkru,
-
        .tlb_flush = vmx_flush_tlb,
 
        .run = vmx_vcpu_run,
index d734aa8c5b4f7290e365badd00ea962fd0af9acd..05a5e57c6f39770e81e2af3f760f9ce44783f9b3 100644 (file)
@@ -3245,7 +3245,12 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
                        u32 size, offset, ecx, edx;
                        cpuid_count(XSTATE_CPUID, index,
                                    &size, &offset, &ecx, &edx);
-                       memcpy(dest + offset, src, size);
+                       if (feature == XFEATURE_MASK_PKRU)
+                               memcpy(dest + offset, &vcpu->arch.pkru,
+                                      sizeof(vcpu->arch.pkru));
+                       else
+                               memcpy(dest + offset, src, size);
+
                }
 
                valid -= feature;
@@ -3283,7 +3288,11 @@ static void load_xsave(struct kvm_vcpu *vcpu, u8 *src)
                        u32 size, offset, ecx, edx;
                        cpuid_count(XSTATE_CPUID, index,
                                    &size, &offset, &ecx, &edx);
-                       memcpy(dest, src + offset, size);
+                       if (feature == XFEATURE_MASK_PKRU)
+                               memcpy(&vcpu->arch.pkru, src + offset,
+                                      sizeof(vcpu->arch.pkru));
+                       else
+                               memcpy(dest, src + offset, size);
                }
 
                valid -= feature;
@@ -7633,7 +7642,9 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
         */
        vcpu->guest_fpu_loaded = 1;
        __kernel_fpu_begin();
-       __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
+       /* PKRU is separately restored in kvm_x86_ops->run.  */
+       __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state,
+                               ~XFEATURE_MASK_PKRU);
        trace_kvm_fpu(1);
 }
 
index 229d04a83f8561ec08e394f57d8cb5d671bd56ff..a88cfbfbd0781a4d20c398d7ca1b30f50f05be43 100644 (file)
@@ -50,8 +50,7 @@ unsigned long tasksize_64bit(void)
 static unsigned long stack_maxrandom_size(unsigned long task_size)
 {
        unsigned long max = 0;
-       if ((current->flags & PF_RANDOMIZE) &&
-               !(current->personality & ADDR_NO_RANDOMIZE)) {
+       if (current->flags & PF_RANDOMIZE) {
                max = (-1UL) & __STACK_RND_MASK(task_size == tasksize_32bit());
                max <<= PAGE_SHIFT;
        }
@@ -79,13 +78,13 @@ static int mmap_is_legacy(void)
 
 static unsigned long arch_rnd(unsigned int rndbits)
 {
+       if (!(current->flags & PF_RANDOMIZE))
+               return 0;
        return (get_random_long() & ((1UL << rndbits) - 1)) << PAGE_SHIFT;
 }
 
 unsigned long arch_mmap_rnd(void)
 {
-       if (!(current->flags & PF_RANDOMIZE))
-               return 0;
        return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits);
 }
 
index 3e4bdb442fbcfc783059be96efe4d4e2d6b58b47..f44c0bc95aa2f45ad42462a5f23f4db4672d1257 100644 (file)
@@ -26,7 +26,7 @@
 static struct bau_operations ops __ro_after_init;
 
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
-static int timeout_base_ns[] = {
+static const int timeout_base_ns[] = {
                20,
                160,
                1280,
@@ -1216,7 +1216,7 @@ static struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg,
  * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register.
  * Such a message must be ignored.
  */
-void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
+static void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
 {
        unsigned long mmr_image;
        unsigned char swack_vec;
index 9ebc2945f991e9ff5d50c5191de45ca1025f1201..4f927a58dff86183a95baf9c7f4eb474c218f0f2 100644 (file)
@@ -75,6 +75,8 @@ static const char *const blk_queue_flag_name[] = {
        QUEUE_FLAG_NAME(STATS),
        QUEUE_FLAG_NAME(POLL_STATS),
        QUEUE_FLAG_NAME(REGISTERED),
+       QUEUE_FLAG_NAME(SCSI_PASSTHROUGH),
+       QUEUE_FLAG_NAME(QUIESCED),
 };
 #undef QUEUE_FLAG_NAME
 
@@ -265,6 +267,7 @@ static const char *const cmd_flag_name[] = {
        CMD_FLAG_NAME(RAHEAD),
        CMD_FLAG_NAME(BACKGROUND),
        CMD_FLAG_NAME(NOUNMAP),
+       CMD_FLAG_NAME(NOWAIT),
 };
 #undef CMD_FLAG_NAME
 
index 0c3354cf3552877d7542cdb32f0ce4102a79fcce..76944e3271bf34a730e62fa0b27266abce86942e 100644 (file)
@@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev)
        for (queue = 0; queue < set->nr_hw_queues; queue++) {
                mask = pci_irq_get_affinity(pdev, queue);
                if (!mask)
-                       return -EINVAL;
+                       goto fallback;
 
                for_each_cpu(cpu, mask)
                        set->mq_map[cpu] = queue;
        }
 
        return 0;
+
+fallback:
+       WARN_ON_ONCE(set->nr_hw_queues > 1);
+       for_each_possible_cpu(cpu)
+               set->mq_map[cpu] = 0;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);
index 535cbdf32aabb28de64e7613e748bfa7a73ade6a..4603b115e234887860cbb28520c36ba9e5e7efd8 100644 (file)
@@ -360,12 +360,12 @@ struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,
                return ERR_PTR(ret);
 
        rq = blk_mq_get_request(q, NULL, op, &alloc_data);
+       blk_queue_exit(q);
 
        if (!rq)
                return ERR_PTR(-EWOULDBLOCK);
 
        blk_mq_put_ctx(alloc_data.ctx);
-       blk_queue_exit(q);
 
        rq->__data_len = 0;
        rq->__sector = (sector_t) -1;
@@ -411,12 +411,11 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
        alloc_data.ctx = __blk_mq_get_ctx(q, cpu);
 
        rq = blk_mq_get_request(q, NULL, op, &alloc_data);
+       blk_queue_exit(q);
 
        if (!rq)
                return ERR_PTR(-EWOULDBLOCK);
 
-       blk_queue_exit(q);
-
        return rq;
 }
 EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx);
index a7285bf2831c7bdbb89b753fccb198f8640e8780..80f5481fe9f6c1603e477349732dac62c3baf204 100644 (file)
@@ -382,6 +382,14 @@ static unsigned int tg_iops_limit(struct throtl_grp *tg, int rw)
        }                                                               \
 } while (0)
 
+static inline unsigned int throtl_bio_data_size(struct bio *bio)
+{
+       /* assume it's one sector */
+       if (unlikely(bio_op(bio) == REQ_OP_DISCARD))
+               return 512;
+       return bio->bi_iter.bi_size;
+}
+
 static void throtl_qnode_init(struct throtl_qnode *qn, struct throtl_grp *tg)
 {
        INIT_LIST_HEAD(&qn->node);
@@ -934,6 +942,7 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio,
        bool rw = bio_data_dir(bio);
        u64 bytes_allowed, extra_bytes, tmp;
        unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
+       unsigned int bio_size = throtl_bio_data_size(bio);
 
        jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
 
@@ -947,14 +956,14 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio,
        do_div(tmp, HZ);
        bytes_allowed = tmp;
 
-       if (tg->bytes_disp[rw] + bio->bi_iter.bi_size <= bytes_allowed) {
+       if (tg->bytes_disp[rw] + bio_size <= bytes_allowed) {
                if (wait)
                        *wait = 0;
                return true;
        }
 
        /* Calc approx time to dispatch */
-       extra_bytes = tg->bytes_disp[rw] + bio->bi_iter.bi_size - bytes_allowed;
+       extra_bytes = tg->bytes_disp[rw] + bio_size - bytes_allowed;
        jiffy_wait = div64_u64(extra_bytes * HZ, tg_bps_limit(tg, rw));
 
        if (!jiffy_wait)
@@ -1034,11 +1043,12 @@ static bool tg_may_dispatch(struct throtl_grp *tg, struct bio *bio,
 static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio)
 {
        bool rw = bio_data_dir(bio);
+       unsigned int bio_size = throtl_bio_data_size(bio);
 
        /* Charge the bio to the group */
-       tg->bytes_disp[rw] += bio->bi_iter.bi_size;
+       tg->bytes_disp[rw] += bio_size;
        tg->io_disp[rw]++;
-       tg->last_bytes_disp[rw] += bio->bi_iter.bi_size;
+       tg->last_bytes_disp[rw] += bio_size;
        tg->last_io_disp[rw]++;
 
        /*
index c4513b23f57a6438af6ae38367c072931edf138c..dd56d7460cb91d504aa22ae9215d00f97c844359 100644 (file)
 #include <scsi/scsi_cmnd.h>
 
 /**
- * bsg_destroy_job - routine to teardown/delete a bsg job
+ * bsg_teardown_job - routine to teardown a bsg job
  * @job: bsg_job that is to be torn down
  */
-static void bsg_destroy_job(struct kref *kref)
+static void bsg_teardown_job(struct kref *kref)
 {
        struct bsg_job *job = container_of(kref, struct bsg_job, kref);
        struct request *rq = job->req;
 
-       blk_end_request_all(rq, BLK_STS_OK);
-
        put_device(job->dev);   /* release reference for the request */
 
        kfree(job->request_payload.sg_list);
        kfree(job->reply_payload.sg_list);
-       kfree(job);
+
+       blk_end_request_all(rq, BLK_STS_OK);
 }
 
 void bsg_job_put(struct bsg_job *job)
 {
-       kref_put(&job->kref, bsg_destroy_job);
+       kref_put(&job->kref, bsg_teardown_job);
 }
 EXPORT_SYMBOL_GPL(bsg_job_put);
 
@@ -100,7 +99,7 @@ EXPORT_SYMBOL_GPL(bsg_job_done);
  */
 static void bsg_softirq_done(struct request *rq)
 {
-       struct bsg_job *job = rq->special;
+       struct bsg_job *job = blk_mq_rq_to_pdu(rq);
 
        bsg_job_put(job);
 }
@@ -122,33 +121,20 @@ static int bsg_map_buffer(struct bsg_buffer *buf, struct request *req)
 }
 
 /**
- * bsg_create_job - create the bsg_job structure for the bsg request
+ * bsg_prepare_job - create the bsg_job structure for the bsg request
  * @dev: device that is being sent the bsg request
  * @req: BSG request that needs a job structure
  */
-static int bsg_create_job(struct device *dev, struct request *req)
+static int bsg_prepare_job(struct device *dev, struct request *req)
 {
        struct request *rsp = req->next_rq;
-       struct request_queue *q = req->q;
        struct scsi_request *rq = scsi_req(req);
-       struct bsg_job *job;
+       struct bsg_job *job = blk_mq_rq_to_pdu(req);
        int ret;
 
-       BUG_ON(req->special);
-
-       job = kzalloc(sizeof(struct bsg_job) + q->bsg_job_size, GFP_KERNEL);
-       if (!job)
-               return -ENOMEM;
-
-       req->special = job;
-       job->req = req;
-       if (q->bsg_job_size)
-               job->dd_data = (void *)&job[1];
        job->request = rq->cmd;
        job->request_len = rq->cmd_len;
-       job->reply = rq->sense;
-       job->reply_len = SCSI_SENSE_BUFFERSIZE; /* Size of sense buffer
-                                                * allocated */
+
        if (req->bio) {
                ret = bsg_map_buffer(&job->request_payload, req);
                if (ret)
@@ -187,7 +173,6 @@ static void bsg_request_fn(struct request_queue *q)
 {
        struct device *dev = q->queuedata;
        struct request *req;
-       struct bsg_job *job;
        int ret;
 
        if (!get_device(dev))
@@ -199,7 +184,7 @@ static void bsg_request_fn(struct request_queue *q)
                        break;
                spin_unlock_irq(q->queue_lock);
 
-               ret = bsg_create_job(dev, req);
+               ret = bsg_prepare_job(dev, req);
                if (ret) {
                        scsi_req(req)->result = ret;
                        blk_end_request_all(req, BLK_STS_OK);
@@ -207,8 +192,7 @@ static void bsg_request_fn(struct request_queue *q)
                        continue;
                }
 
-               job = req->special;
-               ret = q->bsg_job_fn(job);
+               ret = q->bsg_job_fn(blk_mq_rq_to_pdu(req));
                spin_lock_irq(q->queue_lock);
                if (ret)
                        break;
@@ -219,6 +203,35 @@ static void bsg_request_fn(struct request_queue *q)
        spin_lock_irq(q->queue_lock);
 }
 
+static int bsg_init_rq(struct request_queue *q, struct request *req, gfp_t gfp)
+{
+       struct bsg_job *job = blk_mq_rq_to_pdu(req);
+       struct scsi_request *sreq = &job->sreq;
+
+       memset(job, 0, sizeof(*job));
+
+       scsi_req_init(sreq);
+       sreq->sense_len = SCSI_SENSE_BUFFERSIZE;
+       sreq->sense = kzalloc(sreq->sense_len, gfp);
+       if (!sreq->sense)
+               return -ENOMEM;
+
+       job->req = req;
+       job->reply = sreq->sense;
+       job->reply_len = sreq->sense_len;
+       job->dd_data = job + 1;
+
+       return 0;
+}
+
+static void bsg_exit_rq(struct request_queue *q, struct request *req)
+{
+       struct bsg_job *job = blk_mq_rq_to_pdu(req);
+       struct scsi_request *sreq = &job->sreq;
+
+       kfree(sreq->sense);
+}
+
 /**
  * bsg_setup_queue - Create and add the bsg hooks so we can receive requests
  * @dev: device to attach bsg device to
@@ -235,7 +248,9 @@ struct request_queue *bsg_setup_queue(struct device *dev, char *name,
        q = blk_alloc_queue(GFP_KERNEL);
        if (!q)
                return ERR_PTR(-ENOMEM);
-       q->cmd_size = sizeof(struct scsi_request);
+       q->cmd_size = sizeof(struct bsg_job) + dd_job_size;
+       q->init_rq_fn = bsg_init_rq;
+       q->exit_rq_fn = bsg_exit_rq;
        q->request_fn = bsg_request_fn;
 
        ret = blk_init_allocated_queue(q);
@@ -243,7 +258,6 @@ struct request_queue *bsg_setup_queue(struct device *dev, char *name,
                goto out_cleanup_queue;
 
        q->queuedata = dev;
-       q->bsg_job_size = dd_job_size;
        q->bsg_job_fn = job_fn;
        queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q);
        queue_flag_set_unlocked(QUEUE_FLAG_SCSI_PASSTHROUGH, q);
index 538c61677c100e9361bc556154719b7b2368740e..783f4c838aee4c1daabdea8ac8d6f21e75060492 100644 (file)
@@ -100,9 +100,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
                free_buffer_on_error = TRUE;
        }
 
-       status = acpi_get_handle(handle, pathname, &target_handle);
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
+       if (pathname) {
+               status = acpi_get_handle(handle, pathname, &target_handle);
+               if (ACPI_FAILURE(status)) {
+                       return_ACPI_STATUS(status);
+               }
+       } else {
+               target_handle = handle;
        }
 
        full_pathname = acpi_ns_get_external_pathname(target_handle);
index 62068a5e814f026a44e212bd2b93941590a3fe53..ae3d6d15263307c2c159fd459d09bc93ef66fa03 100644 (file)
@@ -1741,7 +1741,7 @@ error:
  * functioning ECDT EC first in order to handle the events.
  * https://bugzilla.kernel.org/show_bug.cgi?id=115021
  */
-int __init acpi_ec_ecdt_start(void)
+static int __init acpi_ec_ecdt_start(void)
 {
        acpi_handle handle;
 
@@ -2003,20 +2003,17 @@ static inline void acpi_ec_query_exit(void)
 int __init acpi_ec_init(void)
 {
        int result;
+       int ecdt_fail, dsdt_fail;
 
        /* register workqueue for _Qxx evaluations */
        result = acpi_ec_query_init();
        if (result)
-               goto err_exit;
-       /* Now register the driver for the EC */
-       result = acpi_bus_register_driver(&acpi_ec_driver);
-       if (result)
-               goto err_exit;
+               return result;
 
-err_exit:
-       if (result)
-               acpi_ec_query_exit();
-       return result;
+       /* Drivers must be started after acpi_ec_query_init() */
+       ecdt_fail = acpi_ec_ecdt_start();
+       dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
+       return ecdt_fail && dsdt_fail ? -ENODEV : 0;
 }
 
 /* EC driver currently not unloadable */
index 58dd7ab3c6538bd490b45e2e420c3d822ecf8c3e..3f5af4d7a73989f86cdcc80c1e8e7b949a975702 100644 (file)
@@ -185,7 +185,6 @@ typedef int (*acpi_ec_query_func) (void *data);
 int acpi_ec_init(void);
 int acpi_ec_ecdt_probe(void);
 int acpi_ec_dsdt_probe(void);
-int acpi_ec_ecdt_start(void);
 void acpi_ec_block_transactions(void);
 void acpi_ec_unblock_transactions(void);
 int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
index 917c789f953dfb280f6f00895ce1fcf7ae2484ec..476a52c60cf3de98b18abe2c35a681c2be3ae058 100644 (file)
@@ -1047,7 +1047,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(
        fwnode_for_each_child_node(fwnode, child) {
                u32 nr;
 
-               if (!fwnode_property_read_u32(fwnode, prop_name, &nr))
+               if (fwnode_property_read_u32(child, prop_name, &nr))
                        continue;
 
                if (val == nr)
index 33897298f03e3ed680272ba6f4109077d434a0d8..70fd5502c2843a7cb0338245767a3c7dc2aeb308 100644 (file)
@@ -2084,7 +2084,6 @@ int __init acpi_scan_init(void)
 
        acpi_gpe_apply_masked_gpes();
        acpi_update_all_gpes();
-       acpi_ec_ecdt_start();
 
        acpi_scan_initialized = true;
 
index f7665c31fecaf3f46b64e17a821f9b8528def937..831cdd7d197dbed87d8a55c530af8df50da15419 100644 (file)
@@ -3362,7 +3362,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
        const char *failure_string;
        struct binder_buffer *buffer;
 
-       if (proc->tsk != current)
+       if (proc->tsk != current->group_leader)
                return -EINVAL;
 
        if ((vma->vm_end - vma->vm_start) > SZ_4M)
index ef8334949b4217d9d0f1f964432c16a56ed244c4..f321b96405f55746490b50132f583c0124b192bb 100644 (file)
@@ -221,8 +221,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
 }
 
 static int
-figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit,
-                loff_t logical_blocksize)
+figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit)
 {
        loff_t size = get_size(offset, sizelimit, lo->lo_backing_file);
        sector_t x = (sector_t)size;
@@ -234,12 +233,6 @@ figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit,
                lo->lo_offset = offset;
        if (lo->lo_sizelimit != sizelimit)
                lo->lo_sizelimit = sizelimit;
-       if (lo->lo_flags & LO_FLAGS_BLOCKSIZE) {
-               lo->lo_logical_blocksize = logical_blocksize;
-               blk_queue_physical_block_size(lo->lo_queue, lo->lo_blocksize);
-               blk_queue_logical_block_size(lo->lo_queue,
-                                            lo->lo_logical_blocksize);
-       }
        set_capacity(lo->lo_disk, x);
        bd_set_size(bdev, (loff_t)get_capacity(bdev->bd_disk) << 9);
        /* let user-space know about the new size */
@@ -820,7 +813,6 @@ static void loop_config_discard(struct loop_device *lo)
        struct file *file = lo->lo_backing_file;
        struct inode *inode = file->f_mapping->host;
        struct request_queue *q = lo->lo_queue;
-       int lo_bits = 9;
 
        /*
         * We use punch hole to reclaim the free space used by the
@@ -840,11 +832,9 @@ static void loop_config_discard(struct loop_device *lo)
 
        q->limits.discard_granularity = inode->i_sb->s_blocksize;
        q->limits.discard_alignment = 0;
-       if (lo->lo_flags & LO_FLAGS_BLOCKSIZE)
-               lo_bits = blksize_bits(lo->lo_logical_blocksize);
 
-       blk_queue_max_discard_sectors(q, UINT_MAX >> lo_bits);
-       blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> lo_bits);
+       blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
+       blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> 9);
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
 }
 
@@ -938,7 +928,6 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
 
        lo->use_dio = false;
        lo->lo_blocksize = lo_blocksize;
-       lo->lo_logical_blocksize = 512;
        lo->lo_device = bdev;
        lo->lo_flags = lo_flags;
        lo->lo_backing_file = file;
@@ -1104,7 +1093,6 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
        int err;
        struct loop_func_table *xfer;
        kuid_t uid = current_uid();
-       int lo_flags = lo->lo_flags;
 
        if (lo->lo_encrypt_key_size &&
            !uid_eq(lo->lo_key_owner, uid) &&
@@ -1137,26 +1125,9 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
        if (err)
                goto exit;
 
-       if (info->lo_flags & LO_FLAGS_BLOCKSIZE) {
-               if (!(lo->lo_flags & LO_FLAGS_BLOCKSIZE))
-                       lo->lo_logical_blocksize = 512;
-               lo->lo_flags |= LO_FLAGS_BLOCKSIZE;
-               if (LO_INFO_BLOCKSIZE(info) != 512 &&
-                   LO_INFO_BLOCKSIZE(info) != 1024 &&
-                   LO_INFO_BLOCKSIZE(info) != 2048 &&
-                   LO_INFO_BLOCKSIZE(info) != 4096)
-                       return -EINVAL;
-               if (LO_INFO_BLOCKSIZE(info) > lo->lo_blocksize)
-                       return -EINVAL;
-       }
-
        if (lo->lo_offset != info->lo_offset ||
-           lo->lo_sizelimit != info->lo_sizelimit ||
-           lo->lo_flags != lo_flags ||
-           ((lo->lo_flags & LO_FLAGS_BLOCKSIZE) &&
-            lo->lo_logical_blocksize != LO_INFO_BLOCKSIZE(info))) {
-               if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit,
-                                    LO_INFO_BLOCKSIZE(info))) {
+           lo->lo_sizelimit != info->lo_sizelimit) {
+               if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit)) {
                        err = -EFBIG;
                        goto exit;
                }
@@ -1348,8 +1319,7 @@ static int loop_set_capacity(struct loop_device *lo)
        if (unlikely(lo->lo_state != Lo_bound))
                return -ENXIO;
 
-       return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit,
-                               lo->lo_logical_blocksize);
+       return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
 }
 
 static int loop_set_dio(struct loop_device *lo, unsigned long arg)
index 2c096b9a17b8ccd756065d5102b293796a5833ad..fecd3f97ef8c7cd9f825e6c58777a1a2bc6f3461 100644 (file)
@@ -49,7 +49,6 @@ struct loop_device {
        struct file *   lo_backing_file;
        struct block_device *lo_device;
        unsigned        lo_blocksize;
-       unsigned        lo_logical_blocksize;
        void            *key_data; 
 
        gfp_t           old_gfp_mask;
index 1498b899a593e31951c835f4f537d1bb03d0e596..d3d5523862c227d86166a56fba230467b9b545fc 100644 (file)
@@ -381,6 +381,7 @@ static void virtblk_config_changed_work(struct work_struct *work)
        struct request_queue *q = vblk->disk->queue;
        char cap_str_2[10], cap_str_10[10];
        char *envp[] = { "RESIZE=1", NULL };
+       unsigned long long nblocks;
        u64 capacity;
 
        /* Host must always specify the capacity. */
@@ -393,16 +394,19 @@ static void virtblk_config_changed_work(struct work_struct *work)
                capacity = (sector_t)-1;
        }
 
-       string_get_size(capacity, queue_logical_block_size(q),
+       nblocks = DIV_ROUND_UP_ULL(capacity, queue_logical_block_size(q) >> 9);
+
+       string_get_size(nblocks, queue_logical_block_size(q),
                        STRING_UNITS_2, cap_str_2, sizeof(cap_str_2));
-       string_get_size(capacity, queue_logical_block_size(q),
+       string_get_size(nblocks, queue_logical_block_size(q),
                        STRING_UNITS_10, cap_str_10, sizeof(cap_str_10));
 
        dev_notice(&vdev->dev,
-                 "new size: %llu %d-byte logical blocks (%s/%s)\n",
-                 (unsigned long long)capacity,
-                 queue_logical_block_size(q),
-                 cap_str_10, cap_str_2);
+                  "new size: %llu %d-byte logical blocks (%s/%s)\n",
+                  nblocks,
+                  queue_logical_block_size(q),
+                  cap_str_10,
+                  cap_str_2);
 
        set_capacity(vblk->disk, capacity);
        revalidate_disk(vblk->disk);
index 98e34e4c62b8b228a6ee6d37256e860ee7d3c2b7..2468c28d477110e6bcb2cbf5225dd481c6ec5b95 100644 (file)
@@ -2075,9 +2075,9 @@ static int blkfront_resume(struct xenbus_device *dev)
                        /*
                         * Get the bios in the request so we can re-queue them.
                         */
-                       if (req_op(shadow[i].request) == REQ_OP_FLUSH ||
-                           req_op(shadow[i].request) == REQ_OP_DISCARD ||
-                           req_op(shadow[i].request) == REQ_OP_SECURE_ERASE ||
+                       if (req_op(shadow[j].request) == REQ_OP_FLUSH ||
+                           req_op(shadow[j].request) == REQ_OP_DISCARD ||
+                           req_op(shadow[j].request) == REQ_OP_SECURE_ERASE ||
                            shadow[j].request->cmd_flags & REQ_FUA) {
                                /*
                                 * Flush operations don't contain bios, so
index fcae5ca6ac9234debecf5a4f84521405aa64a74c..54a67f8a28ebfb929610ea07697d7c7e4eb33de1 100644 (file)
@@ -262,7 +262,7 @@ config CLKSRC_LPC32XX
 
 config CLKSRC_PISTACHIO
        bool "Clocksource for Pistachio SoC" if COMPILE_TEST
-       depends on HAS_IOMEM
+       depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
        select TIMER_OF
        help
          Enables the clocksource for the Pistachio SoC.
index aae87c4c546ee06203195654087cd9ef8b43d57a..72bbfccef1132c3a962d9e93d4bd6c459f1b368d 100644 (file)
@@ -1440,7 +1440,7 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
         * While unlikely, it's theoretically possible that none of the frames
         * in a timer expose the combination of feature we want.
         */
-       for (i = i; i < timer_count; i++) {
+       for (i = 0; i < timer_count; i++) {
                timer = &timers[i];
 
                frame = arch_timer_mem_find_best_frame(timer);
index bc48cbf6a7957198d4ecd6bf91840df350843d48..269db74a065815e2211194fbda9774dcf1e80041 100644 (file)
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "failed to get irq\n");
-               return -EINVAL;
+               return irq;
        }
 
        /* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
        if (IS_ERR(p->base))
                return PTR_ERR(p->base);
 
-       if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
-                            IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-                            dev_name(&pdev->dev), p)) {
+       ret = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+                              IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+                              dev_name(&pdev->dev), p);
+       if (ret) {
                dev_err(&pdev->dev, "failed to request low IRQ\n");
-               return -ENOENT;
+               return ret;
        }
 
        /* get hold of clock */
index d509b500a7b5f8565514352a0313cb4704976042..4d7aef9d9c15422df0e9973e72379b2e21256f47 100644 (file)
@@ -128,9 +128,9 @@ static __init int timer_base_init(struct device_node *np,
        const char *name = of_base->name ? of_base->name : np->full_name;
 
        of_base->base = of_io_request_and_map(np, of_base->index, name);
-       if (!of_base->base) {
+       if (IS_ERR(of_base->base)) {
                pr_err("Failed to iomap (%s)\n", name);
-               return -ENXIO;
+               return PTR_ERR(of_base->base);
        }
 
        return 0;
index 0566455f233ed3cd663506321f08f7ae546862be..65ee4fcace1f260632cf53c150c3260cc27240ad 100644 (file)
@@ -1613,8 +1613,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time)
 
 static inline int32_t get_avg_frequency(struct cpudata *cpu)
 {
-       return mul_ext_fp(cpu->sample.core_avg_perf,
-                         cpu->pstate.max_pstate_physical * cpu->pstate.scaling);
+       return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz);
 }
 
 static inline int32_t get_avg_pstate(struct cpudata *cpu)
index 427cbe01272926acd38eba211dceb28fec61db64..dadc4a808df5a37764adf45df9f90dc1fce5b03a 100644 (file)
@@ -1073,7 +1073,7 @@ static int aead_perform(struct aead_request *req, int encrypt,
                req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags,
                                &crypt->icv_rev_aes);
                if (unlikely(!req_ctx->hmac_virt))
-                       goto free_buf_src;
+                       goto free_buf_dst;
                if (!encrypt) {
                        scatterwalk_map_and_copy(req_ctx->hmac_virt,
                                req->src, cryptlen, authsize, 0);
@@ -1088,10 +1088,10 @@ static int aead_perform(struct aead_request *req, int encrypt,
        BUG_ON(qmgr_stat_overflow(SEND_QID));
        return -EINPROGRESS;
 
-free_buf_src:
-       free_buf_chain(dev, req_ctx->src, crypt->src_buf);
 free_buf_dst:
        free_buf_chain(dev, req_ctx->dst, crypt->dst_buf);
+free_buf_src:
+       free_buf_chain(dev, req_ctx->src, crypt->src_buf);
        crypt->ctl_flags = CTL_FLAG_UNUSED;
        return -ENOMEM;
 }
index b10cbaa82ff537b1cfb68d93d80aecdfebcd6c22..b26256f23d67fbdf58206adf2a253fcf40c50091 100644 (file)
@@ -717,8 +717,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
                tdc->chan_addr = tdma->base_addr + ADMA_CH_REG_OFFSET(i);
 
                tdc->irq = of_irq_get(pdev->dev.of_node, i);
-               if (tdc->irq < 0) {
-                       ret = tdc->irq;
+               if (tdc->irq <= 0) {
+                       ret = tdc->irq ?: -ENXIO;
                        goto irq_dispose;
                }
 
index e338c374356294f97c1b331c4c04a4977d495290..45c65f805fd6ba5a3899b5c29a9651fa2d6dcc43 100644 (file)
@@ -557,7 +557,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc)
        edge_cause = mvebu_gpio_read_edge_cause(mvchip);
        edge_mask  = mvebu_gpio_read_edge_mask(mvchip);
 
-       cause = (data_in ^ level_mask) | (edge_cause & edge_mask);
+       cause = (data_in & level_mask) | (edge_cause & edge_mask);
 
        for (i = 0; i < mvchip->chip.ngpio; i++) {
                int irq;
index 16fe9742597b540ff4d82e869dc13d66326bbd2a..fc80add5fedb57dc07b6f567eef138494452316e 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/sysfs.h>
+#include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/interrupt.h>
@@ -432,6 +433,11 @@ static struct attribute *gpiochip_attrs[] = {
 };
 ATTRIBUTE_GROUPS(gpiochip);
 
+static struct gpio_desc *gpio_to_valid_desc(int gpio)
+{
+       return gpio_is_valid(gpio) ? gpio_to_desc(gpio) : NULL;
+}
+
 /*
  * /sys/class/gpio/export ... write-only
  *     integer N ... number of GPIO to export (full access)
@@ -450,7 +456,7 @@ static ssize_t export_store(struct class *class,
        if (status < 0)
                goto done;
 
-       desc = gpio_to_desc(gpio);
+       desc = gpio_to_valid_desc(gpio);
        /* reject invalid GPIOs */
        if (!desc) {
                pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
@@ -493,7 +499,7 @@ static ssize_t unexport_store(struct class *class,
        if (status < 0)
                goto done;
 
-       desc = gpio_to_desc(gpio);
+       desc = gpio_to_valid_desc(gpio);
        /* reject bogus commands (gpio_unexport ignores them) */
        if (!desc) {
                pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
index a6899180b265721831837282e6c66d12a8bccf48..c586f44312f9772fb93f8b1442827c842d610594 100644 (file)
@@ -244,6 +244,12 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
                struct dma_fence *f = e->fence;
                struct amd_sched_fence *s_fence = to_amd_sched_fence(f);
 
+               if (dma_fence_is_signaled(f)) {
+                       hash_del(&e->node);
+                       dma_fence_put(f);
+                       kmem_cache_free(amdgpu_sync_slab, e);
+                       continue;
+               }
                if (ring && s_fence) {
                        /* For fences from the same ring it is sufficient
                         * when they are scheduled.
@@ -256,13 +262,6 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
                        }
                }
 
-               if (dma_fence_is_signaled(f)) {
-                       hash_del(&e->node);
-                       dma_fence_put(f);
-                       kmem_cache_free(amdgpu_sync_slab, e);
-                       continue;
-               }
-
                return f;
        }
 
index c0f336d23f9ccab1d375eda63f8381d62ccf0f00..aed25c4183bb0e5df17a751e25a33c907b91d9b1 100644 (file)
@@ -1655,6 +1655,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
        if (config->funcs->atomic_check)
                ret = config->funcs->atomic_check(state->dev, state);
 
+       if (ret)
+               return ret;
+
        if (!state->allow_modeset) {
                for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
                        if (drm_atomic_crtc_needs_modeset(crtc_state)) {
@@ -1665,7 +1668,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
                }
        }
 
-       return ret;
+       return 0;
 }
 EXPORT_SYMBOL(drm_atomic_check_only);
 
@@ -2167,10 +2170,10 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
        struct drm_atomic_state *state;
        struct drm_modeset_acquire_ctx ctx;
        struct drm_plane *plane;
-       struct drm_out_fence_state *fence_state = NULL;
+       struct drm_out_fence_state *fence_state;
        unsigned plane_mask;
        int ret = 0;
-       unsigned int i, j, num_fences = 0;
+       unsigned int i, j, num_fences;
 
        /* disallow for drivers not supporting atomic: */
        if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
@@ -2211,6 +2214,8 @@ retry:
        plane_mask = 0;
        copied_objs = 0;
        copied_props = 0;
+       fence_state = NULL;
+       num_fences = 0;
 
        for (i = 0; i < arg->count_objs; i++) {
                uint32_t obj_id, count_props;
index 8dc11064253d9e5ed58f8c817a471b36c25c5951..cdaac37907b1e4577565625f6485a7cf3de25088 100644 (file)
@@ -255,13 +255,13 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
        struct drm_gem_object *obj = ptr;
        struct drm_device *dev = obj->dev;
 
+       if (dev->driver->gem_close_object)
+               dev->driver->gem_close_object(obj, file_priv);
+
        if (drm_core_check_feature(dev, DRIVER_PRIME))
                drm_gem_remove_prime_handles(obj, file_priv);
        drm_vma_node_revoke(&obj->vma_node, file_priv);
 
-       if (dev->driver->gem_close_object)
-               dev->driver->gem_close_object(obj, file_priv);
-
        drm_gem_object_handle_put_unlocked(obj);
 
        return 0;
index 5dc8c4350602a561fe4cfd77fce77e26770696fb..e40c12fabbdeaf9a325811d25e17c30990637e12 100644 (file)
@@ -601,6 +601,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 
                crtc = drm_crtc_find(dev, plane_req->crtc_id);
                if (!crtc) {
+                       drm_framebuffer_put(fb);
                        DRM_DEBUG_KMS("Unknown crtc ID %d\n",
                                      plane_req->crtc_id);
                        return -ENOENT;
index 713848c3634946bea6c9805a3a705c22c1b8c08c..e556a46cd4c292773b5e5dfca629c21625b05c43 100644 (file)
@@ -2714,7 +2714,7 @@ static int shadow_indirect_ctx(struct intel_shadow_wa_ctx *wa_ctx)
 unmap_src:
        i915_gem_object_unpin_map(obj);
 put_obj:
-       i915_gem_object_put(wa_ctx->indirect_ctx.obj);
+       i915_gem_object_put(obj);
        return ret;
 }
 
index 00d8967c8512048f5fb46f629c9c76ace1161bbf..d1bd53b73738446f5d01cc7aae2b585f675de6b7 100644 (file)
@@ -4580,7 +4580,7 @@ static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
 
                sseu->slice_mask |= BIT(s);
 
-               if (IS_GEN9_BC(dev_priv))
+               if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv))
                        sseu->subslice_mask =
                                INTEL_INFO(dev_priv)->sseu.subslice_mask;
 
index 39ed58a21fc1f517f56d179d48b3b9bef00e9410..e1e971ee2ed57aae59dd505a49e8a6ee546e58ff 100644 (file)
@@ -688,19 +688,19 @@ static inline bool skip_rcs_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static bool
-needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt,
-                 struct intel_engine_cs *engine,
-                 struct i915_gem_context *to)
+needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt, struct intel_engine_cs *engine)
 {
+       struct i915_gem_context *from = engine->legacy_active_context;
+
        if (!ppgtt)
                return false;
 
        /* Always load the ppgtt on first use */
-       if (!engine->legacy_active_context)
+       if (!from)
                return true;
 
        /* Same context without new entries, skip */
-       if (engine->legacy_active_context == to &&
+       if ((!from->ppgtt || from->ppgtt == ppgtt) &&
            !(intel_engine_flag(engine) & ppgtt->pd_dirty_rings))
                return false;
 
@@ -744,7 +744,7 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
        if (skip_rcs_switch(ppgtt, engine, to))
                return 0;
 
-       if (needs_pd_load_pre(ppgtt, engine, to)) {
+       if (needs_pd_load_pre(ppgtt, engine)) {
                /* Older GENs and non render rings still want the load first,
                 * "PP_DCLV followed by PP_DIR_BASE register through Load
                 * Register Immediate commands in Ring Buffer before submitting
@@ -841,7 +841,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
                struct i915_hw_ppgtt *ppgtt =
                        to->ppgtt ?: req->i915->mm.aliasing_ppgtt;
 
-               if (needs_pd_load_pre(ppgtt, engine, to)) {
+               if (needs_pd_load_pre(ppgtt, engine)) {
                        int ret;
 
                        trace_switch_mm(engine, to);
@@ -852,6 +852,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
                        ppgtt->pd_dirty_rings &= ~intel_engine_flag(engine);
                }
 
+               engine->legacy_active_context = to;
                return 0;
        }
 
index 7032c542a9b1d007c4bc69e328db040b88efc15d..4dd4c2159a92e26d91fd98e560c587a91b964e48 100644 (file)
@@ -242,6 +242,10 @@ int i915_gem_render_state_emit(struct drm_i915_gem_request *req)
                        goto err_unpin;
        }
 
+       ret = req->engine->emit_flush(req, EMIT_INVALIDATE);
+       if (ret)
+               goto err_unpin;
+
        ret = req->engine->emit_bb_start(req,
                                         so->batch_offset, so->batch_size,
                                         I915_DISPATCH_SECURE);
index 639d45c1dd2e6ac24013431aa6da84abb9f0b089..7ea7fd1e8856dc7bf98f3a6a6fdce0366db1f089 100644 (file)
@@ -1120,8 +1120,8 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
        bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
        uint8_t aux_channel, ddc_pin;
        /* Each DDI port can have more than one value on the "DVO Port" field,
-        * so look for all the possible values for each port and abort if more
-        * than one is found. */
+        * so look for all the possible values for each port.
+        */
        int dvo_ports[][3] = {
                {DVO_PORT_HDMIA, DVO_PORT_DPA, -1},
                {DVO_PORT_HDMIB, DVO_PORT_DPB, -1},
@@ -1130,7 +1130,10 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
                {DVO_PORT_CRT, DVO_PORT_HDMIE, DVO_PORT_DPE},
        };
 
-       /* Find the child device to use, abort if more than one found. */
+       /*
+        * Find the first child device to reference the port, report if more
+        * than one found.
+        */
        for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
                it = dev_priv->vbt.child_dev + i;
 
@@ -1140,11 +1143,11 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 
                        if (it->common.dvo_port == dvo_ports[port][j]) {
                                if (child) {
-                                       DRM_DEBUG_KMS("More than one child device for port %c in VBT.\n",
+                                       DRM_DEBUG_KMS("More than one child device for port %c in VBT, using the first.\n",
                                                      port_name(port));
-                                       return;
+                               } else {
+                                       child = it;
                                }
-                               child = it;
                        }
                }
        }
index 9edeaaef77adf6c38e23733769e271147698f02a..d3b3252a874252641af555d8797a72e20056a34b 100644 (file)
@@ -1762,7 +1762,7 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv,
        if (dev_priv->vbt.edp.low_vswing) {
                if (voltage == VOLTAGE_INFO_0_85V) {
                        *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_85V);
-                       return cnl_ddi_translations_dp_0_85V;
+                       return cnl_ddi_translations_edp_0_85V;
                } else if (voltage == VOLTAGE_INFO_0_95V) {
                        *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_95V);
                        return cnl_ddi_translations_edp_0_95V;
index 9471c88d449eaf84adf3411d61135bf090be9b96..cc484b56eeaa33213a0832f43770132a1b165df1 100644 (file)
@@ -3485,6 +3485,13 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)
            !gpu_reset_clobbers_display(dev_priv))
                return;
 
+       /* We have a modeset vs reset deadlock, defensively unbreak it.
+        *
+        * FIXME: We can do a _lot_ better, this is just a first iteration.
+        */
+       i915_gem_set_wedged(dev_priv);
+       DRM_DEBUG_DRIVER("Wedging GPU to avoid deadlocks with pending modeset updates\n");
+
        /*
         * Need mode_config.mutex so that we don't
         * trample ongoing ->detect() and whatnot.
index 6e09ceb71500ceeedce5836c3772861f47aeda21..150a156f3b1e9a2bff7f32bbf1ed1905eb71ca8b 100644 (file)
@@ -46,7 +46,7 @@ static u32 dcs_get_backlight(struct intel_connector *connector)
        struct intel_encoder *encoder = connector->encoder;
        struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
        struct mipi_dsi_device *dsi_device;
-       u8 data;
+       u8 data = 0;
        enum port port;
 
        /* FIXME: Need to take care of 16 bit brightness level */
index 7158c7ce9c0941a05654261e2443bac8b2315b08..91c07b0c8db912dbb24a08fc045dee7a899b237b 100644 (file)
@@ -306,7 +306,7 @@ static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
 
        if (!gpio_desc) {
                gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
-                                                "panel", gpio_index,
+                                                NULL, gpio_index,
                                                 value ? GPIOD_OUT_LOW :
                                                 GPIOD_OUT_HIGH);
 
index 7404cf2aac28690e2e5367de5a93164062a909b4..2afa4daa88e8cc695085c99d7a6d8b33c87a869a 100644 (file)
@@ -1221,6 +1221,14 @@ static int intel_init_workaround_bb(struct intel_engine_cs *engine)
        return ret;
 }
 
+static u8 gtiir[] = {
+       [RCS] = 0,
+       [BCS] = 0,
+       [VCS] = 1,
+       [VCS2] = 1,
+       [VECS] = 3,
+};
+
 static int gen8_init_common_ring(struct intel_engine_cs *engine)
 {
        struct drm_i915_private *dev_priv = engine->i915;
@@ -1245,9 +1253,22 @@ static int gen8_init_common_ring(struct intel_engine_cs *engine)
 
        DRM_DEBUG_DRIVER("Execlists enabled for %s\n", engine->name);
 
-       /* After a GPU reset, we may have requests to replay */
+       GEM_BUG_ON(engine->id >= ARRAY_SIZE(gtiir));
+
+       /*
+        * Clear any pending interrupt state.
+        *
+        * We do it twice out of paranoia that some of the IIR are double
+        * buffered, and if we only reset it once there may still be
+        * an interrupt pending.
+        */
+       I915_WRITE(GEN8_GT_IIR(gtiir[engine->id]),
+                  GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift);
+       I915_WRITE(GEN8_GT_IIR(gtiir[engine->id]),
+                  GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift);
        clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
 
+       /* After a GPU reset, we may have requests to replay */
        submit = false;
        for (n = 0; n < ARRAY_SIZE(engine->execlist_port); n++) {
                if (!port_isset(&port[n]))
index 52b3a1fd4059bab91a898f7f498a79af2c117a4b..57ef5833c4274958f3eed9f39b66a598dcfd1cd7 100644 (file)
@@ -63,7 +63,6 @@ enum {
 };
 
 /* Logical Rings */
-void intel_logical_ring_stop(struct intel_engine_cs *engine);
 void intel_logical_ring_cleanup(struct intel_engine_cs *engine);
 int logical_render_ring_init(struct intel_engine_cs *engine);
 int logical_xcs_ring_init(struct intel_engine_cs *engine);
index 5abef482eacf1b24780edea4c40ab7e593a42dc6..beb9baaf2f2e4e573956f1ea842c2963dce95bd7 100644 (file)
@@ -210,8 +210,8 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
        struct drm_device *dev = intel_dig_port->base.base.dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
 
-       if (!IS_GEN9(dev_priv)) {
-               DRM_ERROR("LSPCON is supported on GEN9 only\n");
+       if (!HAS_LSPCON(dev_priv)) {
+               DRM_ERROR("LSPCON is not supported on this platform\n");
                return false;
        }
 
index 6276bb834b4fe15529652e73c07e901617abc194..d3845989a29dfcba4bf4b03f5740f9945d1bdcdf 100644 (file)
@@ -545,15 +545,13 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
                return;
        }
 
+       ics = ipu_drm_fourcc_to_colorspace(fb->format->format);
        switch (ipu_plane->dp_flow) {
        case IPU_DP_FLOW_SYNC_BG:
-               ipu_dp_setup_channel(ipu_plane->dp,
-                                       IPUV3_COLORSPACE_RGB,
-                                       IPUV3_COLORSPACE_RGB);
+               ipu_dp_setup_channel(ipu_plane->dp, ics, IPUV3_COLORSPACE_RGB);
                ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
                break;
        case IPU_DP_FLOW_SYNC_FG:
-               ics = ipu_drm_fourcc_to_colorspace(state->fb->format->format);
                ipu_dp_setup_channel(ipu_plane->dp, ics,
                                        IPUV3_COLORSPACE_UNKNOWN);
                /* Enable local alpha on partial plane */
index c6b1b7f3a2a397740d5545671113def5bb2e5519..c16bc0a7115b1b41db4ccca2b74061e3e7ccceb2 100644 (file)
@@ -275,11 +275,15 @@ static void rockchip_drm_fb_resume(struct drm_device *drm)
 static int rockchip_drm_sys_suspend(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
-       struct rockchip_drm_private *priv = drm->dev_private;
+       struct rockchip_drm_private *priv;
+
+       if (!drm)
+               return 0;
 
        drm_kms_helper_poll_disable(drm);
        rockchip_drm_fb_suspend(drm);
 
+       priv = drm->dev_private;
        priv->state = drm_atomic_helper_suspend(drm);
        if (IS_ERR(priv->state)) {
                rockchip_drm_fb_resume(drm);
@@ -293,8 +297,12 @@ static int rockchip_drm_sys_suspend(struct device *dev)
 static int rockchip_drm_sys_resume(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
-       struct rockchip_drm_private *priv = drm->dev_private;
+       struct rockchip_drm_private *priv;
+
+       if (!drm)
+               return 0;
 
+       priv = drm->dev_private;
        drm_atomic_helper_resume(drm, priv->state);
        rockchip_drm_fb_resume(drm);
        drm_kms_helper_poll_enable(drm);
index abc7d8fe06b450084bcd20ec560b62405415ff40..a45a627283a149c79693ec90dbd9da5fd8f42056 100644 (file)
 #include "sun4i_framebuffer.h"
 #include "sun4i_tcon.h"
 
+static void sun4i_drv_lastclose(struct drm_device *dev)
+{
+       struct sun4i_drv *drv = dev->dev_private;
+
+       drm_fbdev_cma_restore_mode(drv->fbdev);
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
 
 static struct drm_driver sun4i_drv_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
 
        /* Generic Operations */
+       .lastclose              = sun4i_drv_lastclose,
        .fops                   = &sun4i_drv_fops,
        .name                   = "sun4i-drm",
        .desc                   = "Allwinner sun4i Display Engine",
index 08766c6e7856b31f6183dba84f47c27980fb49c2..87a20b3dcf7a53a64fc464a3c8834d5c0a167781 100644 (file)
@@ -1,6 +1,7 @@
 config IMX_IPUV3_CORE
        tristate "IPUv3 core support"
        depends on SOC_IMX5 || SOC_IMX6Q || ARCH_MULTIPLATFORM
+       depends on DRM || !DRM # if DRM=m, this can't be 'y'
        select GENERIC_IRQ_CHIP
        help
          Choose this if you have a i.MX5/6 system and want to use the Image
index f19348328a715580aa37043abed6d1ee6b061cf4..6fdf9231c23cb0a4f4c736d95662495c2237e24f 100644 (file)
@@ -410,10 +410,11 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
        }
 
        /* We are in an invalid state; reset bus to a known state. */
-       if (!bus->msgs && bus->master_state != ASPEED_I2C_MASTER_STOP) {
+       if (!bus->msgs) {
                dev_err(bus->dev, "bus in unknown state");
                bus->cmd_err = -EIO;
-               aspeed_i2c_do_stop(bus);
+               if (bus->master_state != ASPEED_I2C_MASTER_STOP)
+                       aspeed_i2c_do_stop(bus);
                goto out_no_complete;
        }
        msg = &bus->msgs[bus->msgs_index];
index 143a8fd582b4aeb905ea25b416261a5c1f44a6e9..57248bccadbcb73df29b224594b66bf8088cfb30 100644 (file)
@@ -198,8 +198,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
        dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY;
 
        dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
-                        DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED |
-                        DW_IC_CON_SPEED_FAST;
+                        DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED;
 
        dev->mode = DW_IC_SLAVE;
 
@@ -430,7 +429,7 @@ static void dw_i2c_plat_complete(struct device *dev)
 #endif
 
 #ifdef CONFIG_PM
-static int dw_i2c_plat_suspend(struct device *dev)
+static int dw_i2c_plat_runtime_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
@@ -452,11 +451,21 @@ static int dw_i2c_plat_resume(struct device *dev)
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int dw_i2c_plat_suspend(struct device *dev)
+{
+       pm_runtime_resume(dev);
+       return dw_i2c_plat_runtime_suspend(dev);
+}
+#endif
+
 static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
        .prepare = dw_i2c_plat_prepare,
        .complete = dw_i2c_plat_complete,
        SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
-       SET_RUNTIME_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume, NULL)
+       SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend,
+                          dw_i2c_plat_resume,
+                          NULL)
 };
 
 #define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops)
index 0548c7ea578c9752f7c4cc1efebef37b41bca68a..78d8fb73927d853ebec3061685696db646236e36 100644 (file)
@@ -177,6 +177,8 @@ static int i2c_dw_reg_slave(struct i2c_client *slave)
                return -EBUSY;
        if (slave->flags & I2C_CLIENT_TEN)
                return -EAFNOSUPPORT;
+       pm_runtime_get_sync(dev->dev);
+
        /*
         * Set slave address in the IC_SAR register,
         * the address to which the DW_apb_i2c responds.
@@ -205,6 +207,7 @@ static int i2c_dw_unreg_slave(struct i2c_client *slave)
        dev->disable_int(dev);
        dev->disable(dev);
        dev->slave = NULL;
+       pm_runtime_put(dev->dev);
 
        return 0;
 }
@@ -272,7 +275,7 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
        slave_activity = ((dw_readl(dev, DW_IC_STATUS) &
                DW_IC_STATUS_SLAVE_ACTIVITY) >> 6);
 
-       if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY))
+       if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)
                return 0;
 
        dev_dbg(dev->dev,
@@ -382,7 +385,6 @@ int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
        ret = i2c_add_numbered_adapter(adap);
        if (ret)
                dev_err(dev->dev, "failure adding adapter: %d\n", ret);
-       pm_runtime_put_noidle(dev->dev);
 
        return ret;
 }
index b4685bb9b5d7356f97067a80c1ff9bd0f2d92090..adca51a99487cfb4d2a6d8843047018265e3295a 100644 (file)
@@ -127,8 +127,7 @@ static int simtec_i2c_probe(struct platform_device *dev)
        iounmap(pd->reg);
 
  err_res:
-       release_resource(pd->ioarea);
-       kfree(pd->ioarea);
+       release_mem_region(pd->ioarea->start, size);
 
  err:
        kfree(pd);
@@ -142,8 +141,7 @@ static int simtec_i2c_remove(struct platform_device *dev)
        i2c_del_adapter(&pd->adap);
 
        iounmap(pd->reg);
-       release_resource(pd->ioarea);
-       kfree(pd->ioarea);
+       release_mem_region(pd->ioarea->start, resource_size(pd->ioarea));
        kfree(pd);
 
        return 0;
index 12822a4b8f8f09b5c080f7338a89e0ea00cbb4f2..56e46581b84bdb03eeb07ddaa8d83cec1aa76341 100644 (file)
@@ -353,8 +353,8 @@ static int i2c_device_probe(struct device *dev)
        }
 
        /*
-        * An I2C ID table is not mandatory, if and only if, a suitable Device
-        * Tree match table entry is supplied for the probing device.
+        * An I2C ID table is not mandatory, if and only if, a suitable OF
+        * or ACPI ID table is supplied for the probing device.
         */
        if (!driver->id_table &&
            !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
index 232c0b80d65893e497abe4e13c4b5273e3c9a7a0..c3f86138cb55eba108cb39ef5c10548ad13ff5a4 100644 (file)
@@ -644,7 +644,7 @@ static int ina2xx_capture_thread(void *data)
 {
        struct iio_dev *indio_dev = data;
        struct ina2xx_chip_info *chip = iio_priv(indio_dev);
-       unsigned int sampling_us = SAMPLING_PERIOD(chip);
+       int sampling_us = SAMPLING_PERIOD(chip);
        int buffer_us;
 
        /*
index e09233b03c055b01c1d3cab229b66e5d093c1c3d..609676384f5e779824e41100ba53906c3df92d13 100644 (file)
@@ -64,7 +64,7 @@
 #define STM32H7_CKMODE_MASK            GENMASK(17, 16)
 
 /* STM32 H7 maximum analog clock rate (from datasheet) */
-#define STM32H7_ADC_MAX_CLK_RATE       72000000
+#define STM32H7_ADC_MAX_CLK_RATE       36000000
 
 /**
  * stm32_adc_common_regs - stm32 common registers, compatible dependent data
@@ -148,14 +148,14 @@ static int stm32f4_adc_clk_sel(struct platform_device *pdev,
                return -EINVAL;
        }
 
-       priv->common.rate = rate;
+       priv->common.rate = rate / stm32f4_pclk_div[i];
        val = readl_relaxed(priv->common.base + STM32F4_ADC_CCR);
        val &= ~STM32F4_ADC_ADCPRE_MASK;
        val |= i << STM32F4_ADC_ADCPRE_SHIFT;
        writel_relaxed(val, priv->common.base + STM32F4_ADC_CCR);
 
        dev_dbg(&pdev->dev, "Using analog clock source at %ld kHz\n",
-               rate / (stm32f4_pclk_div[i] * 1000));
+               priv->common.rate / 1000);
 
        return 0;
 }
@@ -250,7 +250,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev,
 
 out:
        /* rate used later by each ADC instance to control BOOST mode */
-       priv->common.rate = rate;
+       priv->common.rate = rate / div;
 
        /* Set common clock mode and prescaler */
        val = readl_relaxed(priv->common.base + STM32H7_ADC_CCR);
@@ -260,7 +260,7 @@ out:
        writel_relaxed(val, priv->common.base + STM32H7_ADC_CCR);
 
        dev_dbg(&pdev->dev, "Using %s clock/%d source at %ld kHz\n",
-               ckmode ? "bus" : "adc", div, rate / (div * 1000));
+               ckmode ? "bus" : "adc", div, priv->common.rate / 1000);
 
        return 0;
 }
index 16ade0a0327bafbe478db6a3714549c455582a97..0e4b379ada4587e2fec367cb5a4beb8996cbe143 100644 (file)
@@ -111,8 +111,6 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
        s32 poll_value = 0;
 
        if (state) {
-               if (!atomic_read(&st->user_requested_state))
-                       return 0;
                if (sensor_hub_device_open(st->hsdev))
                        return -EIO;
 
@@ -161,6 +159,9 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
                                       &report_val);
        }
 
+       pr_debug("HID_SENSOR %s set power_state %d report_state %d\n",
+                st->pdev->name, state_val, report_val);
+
        sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
                               st->power_state.index,
                               sizeof(state_val), &state_val);
@@ -182,6 +183,7 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
                ret = pm_runtime_get_sync(&st->pdev->dev);
        else {
                pm_runtime_mark_last_busy(&st->pdev->dev);
+               pm_runtime_use_autosuspend(&st->pdev->dev);
                ret = pm_runtime_put_autosuspend(&st->pdev->dev);
        }
        if (ret < 0) {
@@ -285,8 +287,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
        /* Default to 3 seconds, but can be changed from sysfs */
        pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
                                         3000);
-       pm_runtime_use_autosuspend(&attrb->pdev->dev);
-
        return ret;
 error_unreg_trigger:
        iio_trigger_unregister(trig);
index 8cf84d3488b2650c0ca2f265e8dc58f1b10efc0b..12898424d8382f5953bcf2618e31f96c1874c56b 100644 (file)
@@ -696,7 +696,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
                .gyro_max_val = IIO_RAD_TO_DEGREE(22500),
                .gyro_max_scale = 450,
                .accel_max_val = IIO_M_S_2_TO_G(12500),
-               .accel_max_scale = 5,
+               .accel_max_scale = 10,
        },
        [ADIS16485] = {
                .channels = adis16485_channels,
index 8e1b0861fbe4a63b6b50466f320bd65e6e48f3c9..c3856369998498685aa1a516e11669fe8452aa2b 100644 (file)
@@ -356,9 +356,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
                .drdy_irq = {
                        .addr = 0x62,
                        .mask_int1 = 0x01,
-                       .addr_ihl = 0x63,
-                       .mask_ihl = 0x04,
-                       .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
+                       .addr_stat_drdy = 0x67,
                },
                .multi_read_bit = false,
                .bootime = 2,
index d82b788374b61ba617bc5a073e17d283e5e0cfc9..0d2ea3ee371b9fc8c0fff8c213f97ee3ab31b5a1 100644 (file)
@@ -282,6 +282,11 @@ static int bmp280_read_temp(struct bmp280_data *data,
        }
 
        adc_temp = be32_to_cpu(tmp) >> 12;
+       if (adc_temp == BMP280_TEMP_SKIPPED) {
+               /* reading was skipped */
+               dev_err(data->dev, "reading temperature skipped\n");
+               return -EIO;
+       }
        comp_temp = bmp280_compensate_temp(data, adc_temp);
 
        /*
@@ -317,6 +322,11 @@ static int bmp280_read_press(struct bmp280_data *data,
        }
 
        adc_press = be32_to_cpu(tmp) >> 12;
+       if (adc_press == BMP280_PRESS_SKIPPED) {
+               /* reading was skipped */
+               dev_err(data->dev, "reading pressure skipped\n");
+               return -EIO;
+       }
        comp_press = bmp280_compensate_press(data, adc_press);
 
        *val = comp_press;
@@ -345,6 +355,11 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
        }
 
        adc_humidity = be16_to_cpu(tmp);
+       if (adc_humidity == BMP280_HUMIDITY_SKIPPED) {
+               /* reading was skipped */
+               dev_err(data->dev, "reading humidity skipped\n");
+               return -EIO;
+       }
        comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
 
        *val = comp_humidity;
@@ -597,14 +612,20 @@ static const struct bmp280_chip_info bmp280_chip_info = {
 
 static int bme280_chip_config(struct bmp280_data *data)
 {
-       int ret = bmp280_chip_config(data);
+       int ret;
        u8 osrs = BMP280_OSRS_HUMIDITIY_X(data->oversampling_humid + 1);
 
+       /*
+        * Oversampling of humidity must be set before oversampling of
+        * temperature/pressure is set to become effective.
+        */
+       ret = regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY,
+                                 BMP280_OSRS_HUMIDITY_MASK, osrs);
+
        if (ret < 0)
                return ret;
 
-       return regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY,
-                                 BMP280_OSRS_HUMIDITY_MASK, osrs);
+       return bmp280_chip_config(data);
 }
 
 static const struct bmp280_chip_info bme280_chip_info = {
index 2c770e13be0e4ad0f4e884f5778d8b1e318b4a86..61347438b779e05f06f84b8c1a2ac8d50b9ddb1d 100644 (file)
 #define BME280_CHIP_ID                 0x60
 #define BMP280_SOFT_RESET_VAL          0xB6
 
+/* BMP280 register skipped special values */
+#define BMP280_TEMP_SKIPPED            0x80000
+#define BMP280_PRESS_SKIPPED           0x80000
+#define BMP280_HUMIDITY_SKIPPED                0x8000
+
 /* Regmap configurations */
 extern const struct regmap_config bmp180_regmap_config;
 extern const struct regmap_config bmp280_regmap_config;
index d22bc56dd9fc0ffffbd28eb30b3507e13fdfb50e..25ad6abfee22d0eeb77829ba623429ccbcbf343c 100644 (file)
@@ -366,34 +366,32 @@ static int stm32_counter_read_raw(struct iio_dev *indio_dev,
                                  int *val, int *val2, long mask)
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
+       u32 dat;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-       {
-               u32 cnt;
-
-               regmap_read(priv->regmap, TIM_CNT, &cnt);
-               *val = cnt;
+               regmap_read(priv->regmap, TIM_CNT, &dat);
+               *val = dat;
+               return IIO_VAL_INT;
 
+       case IIO_CHAN_INFO_ENABLE:
+               regmap_read(priv->regmap, TIM_CR1, &dat);
+               *val = (dat & TIM_CR1_CEN) ? 1 : 0;
                return IIO_VAL_INT;
-       }
-       case IIO_CHAN_INFO_SCALE:
-       {
-               u32 smcr;
 
-               regmap_read(priv->regmap, TIM_SMCR, &smcr);
-               smcr &= TIM_SMCR_SMS;
+       case IIO_CHAN_INFO_SCALE:
+               regmap_read(priv->regmap, TIM_SMCR, &dat);
+               dat &= TIM_SMCR_SMS;
 
                *val = 1;
                *val2 = 0;
 
                /* in quadrature case scale = 0.25 */
-               if (smcr == 3)
+               if (dat == 3)
                        *val2 = 2;
 
                return IIO_VAL_FRACTIONAL_LOG2;
        }
-       }
 
        return -EINVAL;
 }
@@ -403,15 +401,31 @@ static int stm32_counter_write_raw(struct iio_dev *indio_dev,
                                   int val, int val2, long mask)
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
+       u32 dat;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-               regmap_write(priv->regmap, TIM_CNT, val);
+               return regmap_write(priv->regmap, TIM_CNT, val);
 
-               return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
                /* fixed scale */
                return -EINVAL;
+
+       case IIO_CHAN_INFO_ENABLE:
+               if (val) {
+                       regmap_read(priv->regmap, TIM_CR1, &dat);
+                       if (!(dat & TIM_CR1_CEN))
+                               clk_enable(priv->clk);
+                       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
+                                          TIM_CR1_CEN);
+               } else {
+                       regmap_read(priv->regmap, TIM_CR1, &dat);
+                       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
+                                          0);
+                       if (dat & TIM_CR1_CEN)
+                               clk_disable(priv->clk);
+               }
+               return 0;
        }
 
        return -EINVAL;
@@ -471,7 +485,7 @@ static int stm32_get_trigger_mode(struct iio_dev *indio_dev,
 
        regmap_read(priv->regmap, TIM_SMCR, &smcr);
 
-       return smcr == TIM_SMCR_SMS ? 0 : -EINVAL;
+       return (smcr & TIM_SMCR_SMS) == TIM_SMCR_SMS ? 0 : -EINVAL;
 }
 
 static const struct iio_enum stm32_trigger_mode_enum = {
@@ -507,9 +521,19 @@ static int stm32_set_enable_mode(struct iio_dev *indio_dev,
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
        int sms = stm32_enable_mode2sms(mode);
+       u32 val;
 
        if (sms < 0)
                return sms;
+       /*
+        * Triggered mode sets CEN bit automatically by hardware. So, first
+        * enable counter clock, so it can use it. Keeps it in sync with CEN.
+        */
+       if (sms == 6) {
+               regmap_read(priv->regmap, TIM_CR1, &val);
+               if (!(val & TIM_CR1_CEN))
+                       clk_enable(priv->clk);
+       }
 
        regmap_update_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS, sms);
 
@@ -571,11 +595,14 @@ static int stm32_get_quadrature_mode(struct iio_dev *indio_dev,
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
        u32 smcr;
+       int mode;
 
        regmap_read(priv->regmap, TIM_SMCR, &smcr);
-       smcr &= TIM_SMCR_SMS;
+       mode = (smcr & TIM_SMCR_SMS) - 1;
+       if ((mode < 0) || (mode > ARRAY_SIZE(stm32_quadrature_modes)))
+               return -EINVAL;
 
-       return smcr - 1;
+       return mode;
 }
 
 static const struct iio_enum stm32_quadrature_mode_enum = {
@@ -592,13 +619,20 @@ static const char *const stm32_count_direction_states[] = {
 
 static int stm32_set_count_direction(struct iio_dev *indio_dev,
                                     const struct iio_chan_spec *chan,
-                                    unsigned int mode)
+                                    unsigned int dir)
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
+       u32 val;
+       int mode;
 
-       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_DIR, mode);
+       /* In encoder mode, direction is RO (given by TI1/TI2 signals) */
+       regmap_read(priv->regmap, TIM_SMCR, &val);
+       mode = (val & TIM_SMCR_SMS) - 1;
+       if ((mode >= 0) || (mode < ARRAY_SIZE(stm32_quadrature_modes)))
+               return -EBUSY;
 
-       return 0;
+       return regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_DIR,
+                                 dir ? TIM_CR1_DIR : 0);
 }
 
 static int stm32_get_count_direction(struct iio_dev *indio_dev,
@@ -609,7 +643,7 @@ static int stm32_get_count_direction(struct iio_dev *indio_dev,
 
        regmap_read(priv->regmap, TIM_CR1, &cr1);
 
-       return (cr1 & TIM_CR1_DIR);
+       return ((cr1 & TIM_CR1_DIR) ? 1 : 0);
 }
 
 static const struct iio_enum stm32_count_direction_enum = {
@@ -672,7 +706,9 @@ static const struct iio_chan_spec_ext_info stm32_trigger_count_info[] = {
 static const struct iio_chan_spec stm32_trigger_channel = {
        .type = IIO_COUNT,
        .channel = 0,
-       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+                             BIT(IIO_CHAN_INFO_ENABLE) |
+                             BIT(IIO_CHAN_INFO_SCALE),
        .ext_info = stm32_trigger_count_info,
        .indexed = 1
 };
index a5dfab6adf495b88e846ee03b815536a7917bf48..221468f77128440acb2f5956d2ecf25bac7cc80d 100644 (file)
@@ -537,10 +537,11 @@ void ib_unregister_device(struct ib_device *device)
        }
        up_read(&lists_rwsem);
 
-       mutex_unlock(&device_mutex);
-
        ib_device_unregister_rdmacg(device);
        ib_device_unregister_sysfs(device);
+
+       mutex_unlock(&device_mutex);
+
        ib_cache_cleanup_one(device);
 
        ib_security_destroy_port_pkey_list(device);
index c551d2b275fdf339310a087bef9c6e821d7c7e09..739bd69ef1d47fa163ea9f57cf86cbbf09f5fba7 100644 (file)
@@ -1015,7 +1015,7 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
        cq->uobject       = &obj->uobject;
        cq->comp_handler  = ib_uverbs_comp_handler;
        cq->event_handler = ib_uverbs_cq_event_handler;
-       cq->cq_context    = &ev_file->ev_queue;
+       cq->cq_context    = ev_file ? &ev_file->ev_queue : NULL;
        atomic_set(&cq->usecnt, 0);
 
        obj->uobject.object = cq;
@@ -1522,6 +1522,7 @@ static int create_qp(struct ib_uverbs_file *file,
                qp->qp_type       = attr.qp_type;
                atomic_set(&qp->usecnt, 0);
                atomic_inc(&pd->usecnt);
+               qp->port = 0;
                if (attr.send_cq)
                        atomic_inc(&attr.send_cq->usecnt);
                if (attr.recv_cq)
@@ -1962,8 +1963,9 @@ static int modify_qp(struct ib_uverbs_file *file,
        attr->alt_timeout         = cmd->base.alt_timeout;
        attr->rate_limit          = cmd->rate_limit;
 
-       attr->ah_attr.type = rdma_ah_find_type(qp->device,
-                                              cmd->base.dest.port_num);
+       if (cmd->base.attr_mask & IB_QP_AV)
+               attr->ah_attr.type = rdma_ah_find_type(qp->device,
+                                                      cmd->base.dest.port_num);
        if (cmd->base.dest.is_global) {
                rdma_ah_set_grh(&attr->ah_attr, NULL,
                                cmd->base.dest.flow_label,
@@ -1981,8 +1983,9 @@ static int modify_qp(struct ib_uverbs_file *file,
        rdma_ah_set_port_num(&attr->ah_attr,
                             cmd->base.dest.port_num);
 
-       attr->alt_ah_attr.type = rdma_ah_find_type(qp->device,
-                                                  cmd->base.dest.port_num);
+       if (cmd->base.attr_mask & IB_QP_ALT_PATH)
+               attr->alt_ah_attr.type =
+                       rdma_ah_find_type(qp->device, cmd->base.dest.port_num);
        if (cmd->base.alt_dest.is_global) {
                rdma_ah_set_grh(&attr->alt_ah_attr, NULL,
                                cmd->base.alt_dest.flow_label,
index c023e2c81b8f2b06443452f91edcc506b46b6d17..5e530d2bee4448ddcb68724199a5c93d36eec32a 100644 (file)
@@ -1153,7 +1153,6 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
                kref_get(&file->ref);
                mutex_unlock(&uverbs_dev->lists_mutex);
 
-               ib_uverbs_event_handler(&file->event_handler, &event);
 
                mutex_lock(&file->cleanup_mutex);
                ucontext = file->ucontext;
@@ -1170,6 +1169,7 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
                         * for example due to freeing the resources
                         * (e.g mmput).
                         */
+                       ib_uverbs_event_handler(&file->event_handler, &event);
                        ib_dev->disassociate_ucontext(ucontext);
                        mutex_lock(&file->cleanup_mutex);
                        ib_uverbs_cleanup_ucontext(file, ucontext, true);
index 7f8fe443df46f5b562ac3b2561e19226e3ab6b68..b456e3ca1876ae8db6bb5aeeb34dc8e7e48eab88 100644 (file)
@@ -838,6 +838,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
        spin_lock_init(&qp->mr_lock);
        INIT_LIST_HEAD(&qp->rdma_mrs);
        INIT_LIST_HEAD(&qp->sig_mrs);
+       qp->port = 0;
 
        if (qp_init_attr->qp_type == IB_QPT_XRC_TGT)
                return ib_create_xrc_qp(qp, qp_init_attr);
@@ -1297,7 +1298,11 @@ int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr,
                if (ret)
                        return ret;
        }
-       return ib_security_modify_qp(qp, attr, attr_mask, udata);
+       ret = ib_security_modify_qp(qp, attr, attr_mask, udata);
+       if (!ret && (attr_mask & IB_QP_PORT))
+               qp->port = attr->port_num;
+
+       return ret;
 }
 EXPORT_SYMBOL(ib_modify_qp_with_udata);
 
index 5332f06b99ba4cfa3ef404ec816d09fb68ec0ddf..c2fba76becd4e985a35b9ed3d1ec1314c955706b 100644 (file)
@@ -661,7 +661,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd,
        rhp = php->rhp;
 
        if (mr_type != IB_MR_TYPE_MEM_REG ||
-           max_num_sg > t4_max_fr_depth(&rhp->rdev.lldi.ulptx_memwrite_dsgl &&
+           max_num_sg > t4_max_fr_depth(rhp->rdev.lldi.ulptx_memwrite_dsgl &&
                                         use_dsgl))
                return ERR_PTR(-EINVAL);
 
index f78a733a63ec7e1f884930a72e53ba2100ee888e..d545302b8ef8c520d4eceb630a39db06b7a584a4 100644 (file)
@@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
        } else {
                u8 *dmac = rdma_ah_retrieve_dmac(ah_attr);
 
-               if (!dmac)
+               if (!dmac) {
+                       kfree(ah);
                        return ERR_PTR(-EINVAL);
+               }
                memcpy(ah->av.mac, dmac, ETH_ALEN);
        }
 
index 9ec1ae9a82c9843878ea10266b0d5338d8862308..a49ff2eb6fb3bca54f40bc460238eeb4a5b4ba52 100644 (file)
@@ -130,20 +130,32 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf(
        u64 base = 0;
        u32 i, j;
        u32 k = 0;
-       u32 low;
 
        /* copy base values in obj_info */
-       for (i = I40IW_HMC_IW_QP, j = 0;
-                       i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
+       for (i = I40IW_HMC_IW_QP, j = 0; i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
+               if ((i == I40IW_HMC_IW_SRQ) ||
+                       (i == I40IW_HMC_IW_FSIMC) ||
+                       (i == I40IW_HMC_IW_FSIAV)) {
+                       info[i].base = 0;
+                       info[i].cnt = 0;
+                       continue;
+               }
                get_64bit_val(buf, j, &temp);
                info[i].base = RS_64_1(temp, 32) * 512;
                if (info[i].base > base) {
                        base = info[i].base;
                        k = i;
                }
-               low = (u32)(temp);
-               if (low)
-                       info[i].cnt = low;
+               if (i == I40IW_HMC_IW_APBVT_ENTRY) {
+                       info[i].cnt = 1;
+                       continue;
+               }
+               if (i == I40IW_HMC_IW_QP)
+                       info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
+               else if (i == I40IW_HMC_IW_CQ)
+                       info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
+               else
+                       info[i].cnt = (u32)(temp);
        }
        size = info[k].cnt * info[k].size + info[k].base;
        if (size & 0x1FFFFF)
@@ -154,6 +166,31 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf(
        return 0;
 }
 
+/**
+ * i40iw_sc_decode_fpm_query() - Decode a 64 bit value into max count and size
+ * @buf: ptr to fpm query buffer
+ * @buf_idx: index into buf
+ * @info: ptr to i40iw_hmc_obj_info struct
+ * @rsrc_idx: resource index into info
+ *
+ * Decode a 64 bit value from fpm query buffer into max count and size
+ */
+static u64 i40iw_sc_decode_fpm_query(u64 *buf,
+                                           u32 buf_idx,
+                                           struct i40iw_hmc_obj_info *obj_info,
+                                           u32 rsrc_idx)
+{
+       u64 temp;
+       u32 size;
+
+       get_64bit_val(buf, buf_idx, &temp);
+       obj_info[rsrc_idx].max_cnt = (u32)temp;
+       size = (u32)RS_64_1(temp, 32);
+       obj_info[rsrc_idx].size = LS_64_1(1, size);
+
+       return temp;
+}
+
 /**
  * i40iw_sc_parse_fpm_query_buf() - parses fpm query buffer
  * @buf: ptr to fpm query buffer
@@ -168,9 +205,9 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf(
                                struct i40iw_hmc_info *hmc_info,
                                struct i40iw_hmc_fpm_misc *hmc_fpm_misc)
 {
-       u64 temp;
        struct i40iw_hmc_obj_info *obj_info;
-       u32 i, j, size;
+       u64 temp;
+       u32 size;
        u16 max_pe_sds;
 
        obj_info = hmc_info->hmc_obj;
@@ -185,41 +222,52 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf(
        hmc_fpm_misc->max_sds = max_pe_sds;
        hmc_info->sd_table.sd_cnt = max_pe_sds + hmc_info->first_sd_index;
 
-       for (i = I40IW_HMC_IW_QP, j = 8;
-            i <= I40IW_HMC_IW_ARP; i++, j += 8) {
-               get_64bit_val(buf, j, &temp);
-               if (i == I40IW_HMC_IW_QP)
-                       obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
-               else if (i == I40IW_HMC_IW_CQ)
-                       obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
-               else
-                       obj_info[i].max_cnt = (u32)temp;
+       get_64bit_val(buf, 8, &temp);
+       obj_info[I40IW_HMC_IW_QP].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
+       size = (u32)RS_64_1(temp, 32);
+       obj_info[I40IW_HMC_IW_QP].size = LS_64_1(1, size);
 
-               size = (u32)RS_64_1(temp, 32);
-               obj_info[i].size = ((u64)1 << size);
-       }
-       for (i = I40IW_HMC_IW_MR, j = 48;
-                       i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
-               get_64bit_val(buf, j, &temp);
-               obj_info[i].max_cnt = (u32)temp;
-               size = (u32)RS_64_1(temp, 32);
-               obj_info[i].size = LS_64_1(1, size);
-       }
+       get_64bit_val(buf, 16, &temp);
+       obj_info[I40IW_HMC_IW_CQ].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
+       size = (u32)RS_64_1(temp, 32);
+       obj_info[I40IW_HMC_IW_CQ].size = LS_64_1(1, size);
+
+       i40iw_sc_decode_fpm_query(buf, 32, obj_info, I40IW_HMC_IW_HTE);
+       i40iw_sc_decode_fpm_query(buf, 40, obj_info, I40IW_HMC_IW_ARP);
+
+       obj_info[I40IW_HMC_IW_APBVT_ENTRY].size = 8192;
+       obj_info[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1;
+
+       i40iw_sc_decode_fpm_query(buf, 48, obj_info, I40IW_HMC_IW_MR);
+       i40iw_sc_decode_fpm_query(buf, 56, obj_info, I40IW_HMC_IW_XF);
 
-       get_64bit_val(buf, 120, &temp);
-       hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS);
-       get_64bit_val(buf, 120, &temp);
-       hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER);
-       get_64bit_val(buf, 120, &temp);
-       hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET);
        get_64bit_val(buf, 64, &temp);
+       obj_info[I40IW_HMC_IW_XFFL].max_cnt = (u32)temp;
+       obj_info[I40IW_HMC_IW_XFFL].size = 4;
        hmc_fpm_misc->xf_block_size = RS_64(temp, I40IW_QUERY_FPM_XFBLOCKSIZE);
        if (!hmc_fpm_misc->xf_block_size)
                return I40IW_ERR_INVALID_SIZE;
+
+       i40iw_sc_decode_fpm_query(buf, 72, obj_info, I40IW_HMC_IW_Q1);
+
        get_64bit_val(buf, 80, &temp);
+       obj_info[I40IW_HMC_IW_Q1FL].max_cnt = (u32)temp;
+       obj_info[I40IW_HMC_IW_Q1FL].size = 4;
        hmc_fpm_misc->q1_block_size = RS_64(temp, I40IW_QUERY_FPM_Q1BLOCKSIZE);
        if (!hmc_fpm_misc->q1_block_size)
                return I40IW_ERR_INVALID_SIZE;
+
+       i40iw_sc_decode_fpm_query(buf, 88, obj_info, I40IW_HMC_IW_TIMER);
+
+       get_64bit_val(buf, 112, &temp);
+       obj_info[I40IW_HMC_IW_PBLE].max_cnt = (u32)temp;
+       obj_info[I40IW_HMC_IW_PBLE].size = 8;
+
+       get_64bit_val(buf, 120, &temp);
+       hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS);
+       hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER);
+       hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET);
+
        return 0;
 }
 
@@ -3392,13 +3440,6 @@ enum i40iw_status_code i40iw_sc_init_iw_hmc(struct i40iw_sc_dev *dev, u8 hmc_fn_
                hmc_info->sd_table.sd_entry = virt_mem.va;
        }
 
-       /* fill size of objects which are fixed */
-       hmc_info->hmc_obj[I40IW_HMC_IW_XFFL].size = 4;
-       hmc_info->hmc_obj[I40IW_HMC_IW_Q1FL].size = 4;
-       hmc_info->hmc_obj[I40IW_HMC_IW_PBLE].size = 8;
-       hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].size = 8192;
-       hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1;
-
        return ret_code;
 }
 
@@ -4840,7 +4881,7 @@ void i40iw_vsi_stats_free(struct i40iw_sc_vsi *vsi)
 {
        u8 fcn_id = vsi->fcn_id;
 
-       if ((vsi->stats_fcn_id_alloc) && (fcn_id != I40IW_INVALID_FCN_ID))
+       if (vsi->stats_fcn_id_alloc && fcn_id < I40IW_MAX_STATS_COUNT)
                vsi->dev->fcn_id_array[fcn_id] = false;
        i40iw_hw_stats_stop_timer(vsi);
 }
index a39ac12b6a7e8430b80e42d9a38d7abd3b48d3b8..2ebaadbed379406e9d6c10f01fe0577ab515ebc9 100644 (file)
@@ -1507,8 +1507,8 @@ enum {
        I40IW_CQ0_ALIGNMENT_MASK =              (256 - 1),
        I40IW_HOST_CTX_ALIGNMENT_MASK =         (4 - 1),
        I40IW_SHADOWAREA_MASK =                 (128 - 1),
-       I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK =    0,
-       I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK =   0
+       I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK =    (4 - 1),
+       I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK =   (4 - 1)
 };
 
 enum i40iw_alignment {
index 71050c5d29a05f3f6cb9433aafd7e09fbb5695aa..7f5583d83622a57821d1d4718c6bbc49d84410d0 100644 (file)
@@ -685,7 +685,7 @@ static enum i40iw_status_code i40iw_puda_cq_create(struct i40iw_puda_rsrc *rsrc)
        cqsize = rsrc->cq_size * (sizeof(struct i40iw_cqe));
        tsize = cqsize + sizeof(struct i40iw_cq_shadow_area);
        ret = i40iw_allocate_dma_mem(dev->hw, &rsrc->cqmem, tsize,
-                                    I40IW_CQ0_ALIGNMENT_MASK);
+                                    I40IW_CQ0_ALIGNMENT);
        if (ret)
                return ret;
 
index 91c421762f06797be844f0834d7ff09ff36bb5f9..f7013f11d8085966bf6d9dab310f0f8d0f35422a 100644 (file)
@@ -62,7 +62,7 @@ enum i40iw_status_code {
        I40IW_ERR_INVALID_ALIGNMENT = -23,
        I40IW_ERR_FLUSHED_QUEUE = -24,
        I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25,
-       I40IW_ERR_INVALID_IMM_DATA_SIZE = -26,
+       I40IW_ERR_INVALID_INLINE_DATA_SIZE = -26,
        I40IW_ERR_TIMEOUT = -27,
        I40IW_ERR_OPCODE_MISMATCH = -28,
        I40IW_ERR_CQP_COMPL_ERROR = -29,
index b0d3a0e8a9b522a3549d63593a0af38f682e71ba..1060725d18bce852a108d6ce9e0b55cb460bfb0d 100644 (file)
@@ -435,7 +435,7 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp,
 
        op_info = &info->op.inline_rdma_write;
        if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
-               return I40IW_ERR_INVALID_IMM_DATA_SIZE;
+               return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
 
        ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size);
        if (ret_code)
@@ -511,7 +511,7 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp,
 
        op_info = &info->op.inline_send;
        if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
-               return I40IW_ERR_INVALID_IMM_DATA_SIZE;
+               return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
 
        ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size);
        if (ret_code)
@@ -784,7 +784,7 @@ static enum i40iw_status_code i40iw_cq_poll_completion(struct i40iw_cq_uk *cq,
        get_64bit_val(cqe, 0, &qword0);
        get_64bit_val(cqe, 16, &qword2);
 
-       info->tcp_seq_num = (u8)RS_64(qword0, I40IWCQ_TCPSEQNUM);
+       info->tcp_seq_num = (u32)RS_64(qword0, I40IWCQ_TCPSEQNUM);
 
        info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID);
 
@@ -1187,7 +1187,7 @@ enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size,
                                                         u8 *wqe_size)
 {
        if (data_size > I40IW_MAX_INLINE_DATA_SIZE)
-               return I40IW_ERR_INVALID_IMM_DATA_SIZE;
+               return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
 
        if (data_size <= 16)
                *wqe_size = I40IW_QP_WQE_MIN_SIZE;
index a7f2e60085c46c2300e3695029fbe1373cc0d480..f7fcde1ff0aae66fef09d6eaccf8f9de6b008ba1 100644 (file)
@@ -1085,6 +1085,12 @@ static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
        bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) ==
                      IB_LINK_LAYER_INFINIBAND);
 
+       /* CM layer calls ib_modify_port() regardless of the link layer. For
+        * Ethernet ports, qkey violation and Port capabilities are meaningless.
+        */
+       if (!is_ib)
+               return 0;
+
        if (MLX5_CAP_GEN(dev->mdev, ib_virt) && is_ib) {
                change_mask = props->clr_port_cap_mask | props->set_port_cap_mask;
                value = ~props->clr_port_cap_mask | props->set_port_cap_mask;
index 0889ff367c8625f694346136c22bd510d2dea2a7..f58f8f5f3ebe10e8270606327b58440efd70aae3 100644 (file)
@@ -1238,6 +1238,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
                        goto err_destroy_tis;
 
                sq->base.container_mibqp = qp;
+               sq->base.mqp.event = mlx5_ib_qp_event;
        }
 
        if (qp->rq.wqe_cnt) {
index 69bda611d31385044766915410ac72eb70cffac5..90aa326fd7c0974e0c5a70eb5d2b46f50d03c490 100644 (file)
@@ -65,13 +65,28 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
        struct pvrdma_dev *dev = to_vdev(ibcq->device);
        struct pvrdma_cq *cq = to_vcq(ibcq);
        u32 val = cq->cq_handle;
+       unsigned long flags;
+       int has_data = 0;
 
        val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
                PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
 
+       spin_lock_irqsave(&cq->cq_lock, flags);
+
        pvrdma_write_uar_cq(dev, val);
 
-       return 0;
+       if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+               unsigned int head;
+
+               has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+                                                   cq->ibcq.cqe, &head);
+               if (unlikely(has_data == PVRDMA_INVALID_IDX))
+                       dev_err(&dev->pdev->dev, "CQ ring state invalid\n");
+       }
+
+       spin_unlock_irqrestore(&cq->cq_lock, flags);
+
+       return has_data;
 }
 
 /**
index f600f3a7a3c685488e1ede36058439c59f0703dc..23520df7650f5bc9261c3b58cac22a8dfc27423f 100644 (file)
@@ -331,7 +331,7 @@ static int soc_button_probe(struct platform_device *pdev)
        error = gpiod_count(dev, NULL);
        if (error < 0) {
                dev_dbg(dev, "no GPIO attached, ignoring...\n");
-               return error;
+               return -ENODEV;
        }
 
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
index 262d1057c1da21ba7290c37c0379087d1ff5fa49..850b00e3ad8ecde13046449befa4fad95e308a60 100644 (file)
@@ -1215,14 +1215,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
 
        case SS4_PACKET_ID_TWO:
                if (priv->flags & ALPS_BUTTONPAD) {
-                       f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
+                       }
                        f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
-                       f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
                        f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
                } else {
-                       f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+                       }
                        f->mt[0].y = SS4_STD_MF_Y_V2(p, 0);
-                       f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
                        f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
                }
                f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
@@ -1239,16 +1249,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
 
        case SS4_PACKET_ID_MULTI:
                if (priv->flags & ALPS_BUTTONPAD) {
-                       f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+                               f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
+                       }
+
                        f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
-                       f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
                        f->mt[3].y = SS4_BTL_MF_Y_V2(p, 1);
                        no_data_x = SS4_MFPACKET_NO_AX_BL;
                        no_data_y = SS4_MFPACKET_NO_AY_BL;
                } else {
-                       f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+                       }
                        f->mt[2].y = SS4_STD_MF_Y_V2(p, 0);
-                       f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
                        f->mt[3].y = SS4_STD_MF_Y_V2(p, 1);
                        no_data_x = SS4_MFPACKET_NO_AX;
                        no_data_y = SS4_MFPACKET_NO_AY;
@@ -2541,8 +2562,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
 
        memset(otp, 0, sizeof(otp));
 
-       if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
-           alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
+       if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
+           alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
                return -1;
 
        alps_update_device_area_ss4_v2(otp, priv);
index ed2d6879fa529aebc46d946e1b9c7341eee12b03..c80a7c76cb767187c13e18c5104042270886e736 100644 (file)
@@ -100,6 +100,10 @@ enum SS4_PACKET_ID {
                                 ((_b[1 + _i * 3]  << 5) & 0x1F00)      \
                                )
 
+#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
+                                ((_b[1 + (_i) * 3]  << 4) & 0x0F80)    \
+                               )
+
 #define SS4_STD_MF_Y_V2(_b, _i)        (((_b[1 + (_i) * 3] << 3) & 0x0010) |   \
                                 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |   \
                                 ((_b[2 + (_i) * 3] << 4) & 0x0E00)     \
@@ -109,6 +113,10 @@ enum SS4_PACKET_ID {
                                 ((_b[0 + (_i) * 3] >> 3) & 0x0010)     \
                                )
 
+#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |   \
+                                ((_b[0 + (_i) * 3] >> 4) & 0x0008)     \
+                               )
+
 #define SS4_BTL_MF_Y_V2(_b, _i)        (SS4_STD_MF_Y_V2(_b, _i) | \
                                 ((_b[0 + (_i) * 3] >> 3) & 0x0008)     \
                                )
index 3b616cb7c67f88512e82dbc8ba5f61e565cbd2a5..cfbc8ba4c96c7bedda89e1b79f8ee23b5cd36f47 100644 (file)
@@ -1247,7 +1247,12 @@ static const struct acpi_device_id elan_acpi_id[] = {
        { "ELAN0000", 0 },
        { "ELAN0100", 0 },
        { "ELAN0600", 0 },
+       { "ELAN0602", 0 },
        { "ELAN0605", 0 },
+       { "ELAN0608", 0 },
+       { "ELAN0605", 0 },
+       { "ELAN0609", 0 },
+       { "ELAN060B", 0 },
        { "ELAN1000", 0 },
        { }
 };
index 922ea02edcc3ef6c091b572275245e7d5fabd3f0..0871010f18d5f449e6440a5e41f71d24b8aecfd2 100644 (file)
@@ -265,7 +265,8 @@ static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *fir
        if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
                return -1;
 
-       if (param[0] != TP_MAGIC_IDENT)
+       /* add new TP ID. */
+       if (!(param[0] & TP_MAGIC_IDENT))
                return -1;
 
        if (firmware_id)
@@ -380,8 +381,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
                return 0;
 
        if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) {
-               psmouse_warn(psmouse, "failed to get extended button data\n");
-               button_info = 0;
+               psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n");
+               button_info = 0x33;
        }
 
        psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
index 5617ed3a7d7a15d0f9769086afb8c740b5739fcc..88055755f82e2304a5f7438bc59cb7f47f488823 100644 (file)
@@ -21,8 +21,9 @@
 #define TP_COMMAND             0xE2    /* Commands start with this */
 
 #define TP_READ_ID             0xE1    /* Sent for device identification */
-#define TP_MAGIC_IDENT         0x01    /* Sent after a TP_READ_ID followed */
+#define TP_MAGIC_IDENT         0x03    /* Sent after a TP_READ_ID followed */
                                        /* by the firmware ID */
+                                       /* Firmware ID includes 0x1, 0x2, 0x3 */
 
 
 /*
index f73ff28f77e2351f5f627033fd43a9bdc3c9f7b9..49bd2ab8c5075859bca8e2e90519e7da6cd6f48f 100644 (file)
@@ -76,6 +76,8 @@ config IOMMU_DMA
 
 config FSL_PAMU
        bool "Freescale IOMMU support"
+       depends on PCI
+       depends on PHYS_64BIT
        depends on PPC_E500MC || (COMPILE_TEST && PPC)
        select IOMMU_API
        select GENERIC_ALLOCATOR
@@ -253,6 +255,7 @@ config TEGRA_IOMMU_SMMU
 config EXYNOS_IOMMU
        bool "Exynos IOMMU Support"
        depends on ARCH_EXYNOS && MMU
+       depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes
        select IOMMU_API
        select ARM_DMA_USE_IOMMU
        help
@@ -367,4 +370,14 @@ config MTK_IOMMU_V1
 
          if unsure, say N here.
 
+config QCOM_IOMMU
+       # Note: iommu drivers cannot (yet?) be built as modules
+       bool "Qualcomm IOMMU Support"
+       depends on ARCH_QCOM || COMPILE_TEST
+       select IOMMU_API
+       select IOMMU_IO_PGTABLE_LPAE
+       select ARM_DMA_USE_IOMMU
+       help
+         Support for IOMMU on certain Qualcomm SoCs.
+
 endif # IOMMU_SUPPORT
index 195f7b997d8e9a4dc97e2713d0740267e0a21d80..b910aea813a15758690c79dbf229bbe2546c96b5 100644 (file)
@@ -27,3 +27,4 @@ obj-$(CONFIG_TEGRA_IOMMU_SMMU) += tegra-smmu.o
 obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o
 obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
 obj-$(CONFIG_S390_IOMMU) += s390-iommu.o
+obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o
index 354cbd6392cdf261ba657548ed2c208a09ddf50f..538c16f669f9bf7cb8fda0491c9c02b63f483a2b 100644 (file)
@@ -102,29 +102,6 @@ int amd_iommu_max_glx_val = -1;
 
 static const struct dma_map_ops amd_iommu_dma_ops;
 
-/*
- * This struct contains device specific data for the IOMMU
- */
-struct iommu_dev_data {
-       struct list_head list;            /* For domain->dev_list */
-       struct list_head dev_data_list;   /* For global dev_data_list */
-       struct protection_domain *domain; /* Domain the device is bound to */
-       u16 devid;                        /* PCI Device ID */
-       u16 alias;                        /* Alias Device ID */
-       bool iommu_v2;                    /* Device can make use of IOMMUv2 */
-       bool passthrough;                 /* Device is identity mapped */
-       struct {
-               bool enabled;
-               int qdep;
-       } ats;                            /* ATS state */
-       bool pri_tlp;                     /* PASID TLB required for
-                                            PPR completions */
-       u32 errata;                       /* Bitmap for errata to apply */
-       bool use_vapic;                   /* Enable device to use vapic mode */
-
-       struct ratelimit_state rs;        /* Ratelimit IOPF messages */
-};
-
 /*
  * general struct to manage commands send to an IOMMU
  */
@@ -137,20 +114,7 @@ struct kmem_cache *amd_iommu_irq_cache;
 static void update_domain(struct protection_domain *domain);
 static int protection_domain_init(struct protection_domain *domain);
 static void detach_device(struct device *dev);
-
-#define FLUSH_QUEUE_SIZE 256
-
-struct flush_queue_entry {
-       unsigned long iova_pfn;
-       unsigned long pages;
-       u64 counter; /* Flush counter when this entry was added to the queue */
-};
-
-struct flush_queue {
-       struct flush_queue_entry *entries;
-       unsigned head, tail;
-       spinlock_t lock;
-};
+static void iova_domain_flush_tlb(struct iova_domain *iovad);
 
 /*
  * Data container for a dma_ops specific protection domain
@@ -161,36 +125,6 @@ struct dma_ops_domain {
 
        /* IOVA RB-Tree */
        struct iova_domain iovad;
-
-       struct flush_queue __percpu *flush_queue;
-
-       /*
-        * We need two counter here to be race-free wrt. IOTLB flushing and
-        * adding entries to the flush queue.
-        *
-        * The flush_start_cnt is incremented _before_ the IOTLB flush starts.
-        * New entries added to the flush ring-buffer get their 'counter' value
-        * from here. This way we can make sure that entries added to the queue
-        * (or other per-cpu queues of the same domain) while the TLB is about
-        * to be flushed are not considered to be flushed already.
-        */
-       atomic64_t flush_start_cnt;
-
-       /*
-        * The flush_finish_cnt is incremented when an IOTLB flush is complete.
-        * This value is always smaller than flush_start_cnt. The queue_add
-        * function frees all IOVAs that have a counter value smaller than
-        * flush_finish_cnt. This makes sure that we only free IOVAs that are
-        * flushed out of the IOTLB of the domain.
-        */
-       atomic64_t flush_finish_cnt;
-
-       /*
-        * Timer to make sure we don't keep IOVAs around unflushed
-        * for too long
-        */
-       struct timer_list flush_timer;
-       atomic_t flush_timer_on;
 };
 
 static struct iova_domain reserved_iova_ranges;
@@ -371,19 +305,25 @@ static u16 get_alias(struct device *dev)
 static struct iommu_dev_data *find_dev_data(u16 devid)
 {
        struct iommu_dev_data *dev_data;
+       struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
 
        dev_data = search_dev_data(devid);
 
-       if (dev_data == NULL)
+       if (dev_data == NULL) {
                dev_data = alloc_dev_data(devid);
 
+               if (translation_pre_enabled(iommu))
+                       dev_data->defer_attach = true;
+       }
+
        return dev_data;
 }
 
-static struct iommu_dev_data *get_dev_data(struct device *dev)
+struct iommu_dev_data *get_dev_data(struct device *dev)
 {
        return dev->archdata.iommu;
 }
+EXPORT_SYMBOL(get_dev_data);
 
 /*
 * Find or create an IOMMU group for a acpihid device.
@@ -1165,7 +1105,7 @@ static int iommu_flush_dte(struct amd_iommu *iommu, u16 devid)
        return iommu_queue_command(iommu, &cmd);
 }
 
-static void iommu_flush_dte_all(struct amd_iommu *iommu)
+static void amd_iommu_flush_dte_all(struct amd_iommu *iommu)
 {
        u32 devid;
 
@@ -1179,7 +1119,7 @@ static void iommu_flush_dte_all(struct amd_iommu *iommu)
  * This function uses heavy locking and may disable irqs for some time. But
  * this is no issue because it is only called during resume.
  */
-static void iommu_flush_tlb_all(struct amd_iommu *iommu)
+static void amd_iommu_flush_tlb_all(struct amd_iommu *iommu)
 {
        u32 dom_id;
 
@@ -1193,7 +1133,7 @@ static void iommu_flush_tlb_all(struct amd_iommu *iommu)
        iommu_completion_wait(iommu);
 }
 
-static void iommu_flush_all(struct amd_iommu *iommu)
+static void amd_iommu_flush_all(struct amd_iommu *iommu)
 {
        struct iommu_cmd cmd;
 
@@ -1212,7 +1152,7 @@ static void iommu_flush_irt(struct amd_iommu *iommu, u16 devid)
        iommu_queue_command(iommu, &cmd);
 }
 
-static void iommu_flush_irt_all(struct amd_iommu *iommu)
+static void amd_iommu_flush_irt_all(struct amd_iommu *iommu)
 {
        u32 devid;
 
@@ -1225,11 +1165,11 @@ static void iommu_flush_irt_all(struct amd_iommu *iommu)
 void iommu_flush_all_caches(struct amd_iommu *iommu)
 {
        if (iommu_feature(iommu, FEATURE_IA)) {
-               iommu_flush_all(iommu);
+               amd_iommu_flush_all(iommu);
        } else {
-               iommu_flush_dte_all(iommu);
-               iommu_flush_irt_all(iommu);
-               iommu_flush_tlb_all(iommu);
+               amd_iommu_flush_dte_all(iommu);
+               amd_iommu_flush_irt_all(iommu);
+               amd_iommu_flush_tlb_all(iommu);
        }
 }
 
@@ -1537,9 +1477,9 @@ static int iommu_map_page(struct protection_domain *dom,
 
        if (count > 1) {
                __pte = PAGE_SIZE_PTE(phys_addr, page_size);
-               __pte |= PM_LEVEL_ENC(7) | IOMMU_PTE_P | IOMMU_PTE_FC;
+               __pte |= PM_LEVEL_ENC(7) | IOMMU_PTE_PR | IOMMU_PTE_FC;
        } else
-               __pte = phys_addr | IOMMU_PTE_P | IOMMU_PTE_FC;
+               __pte = phys_addr | IOMMU_PTE_PR | IOMMU_PTE_FC;
 
        if (prot & IOMMU_PROT_IR)
                __pte |= IOMMU_PTE_IR;
@@ -1788,178 +1728,19 @@ static void free_gcr3_table(struct protection_domain *domain)
        free_page((unsigned long)domain->gcr3_tbl);
 }
 
-static void dma_ops_domain_free_flush_queue(struct dma_ops_domain *dom)
-{
-       int cpu;
-
-       for_each_possible_cpu(cpu) {
-               struct flush_queue *queue;
-
-               queue = per_cpu_ptr(dom->flush_queue, cpu);
-               kfree(queue->entries);
-       }
-
-       free_percpu(dom->flush_queue);
-
-       dom->flush_queue = NULL;
-}
-
-static int dma_ops_domain_alloc_flush_queue(struct dma_ops_domain *dom)
-{
-       int cpu;
-
-       atomic64_set(&dom->flush_start_cnt,  0);
-       atomic64_set(&dom->flush_finish_cnt, 0);
-
-       dom->flush_queue = alloc_percpu(struct flush_queue);
-       if (!dom->flush_queue)
-               return -ENOMEM;
-
-       /* First make sure everything is cleared */
-       for_each_possible_cpu(cpu) {
-               struct flush_queue *queue;
-
-               queue = per_cpu_ptr(dom->flush_queue, cpu);
-               queue->head    = 0;
-               queue->tail    = 0;
-               queue->entries = NULL;
-       }
-
-       /* Now start doing the allocation */
-       for_each_possible_cpu(cpu) {
-               struct flush_queue *queue;
-
-               queue = per_cpu_ptr(dom->flush_queue, cpu);
-               queue->entries = kzalloc(FLUSH_QUEUE_SIZE * sizeof(*queue->entries),
-                                        GFP_KERNEL);
-               if (!queue->entries) {
-                       dma_ops_domain_free_flush_queue(dom);
-                       return -ENOMEM;
-               }
-
-               spin_lock_init(&queue->lock);
-       }
-
-       return 0;
-}
-
 static void dma_ops_domain_flush_tlb(struct dma_ops_domain *dom)
 {
-       atomic64_inc(&dom->flush_start_cnt);
        domain_flush_tlb(&dom->domain);
        domain_flush_complete(&dom->domain);
-       atomic64_inc(&dom->flush_finish_cnt);
-}
-
-static inline bool queue_ring_full(struct flush_queue *queue)
-{
-       assert_spin_locked(&queue->lock);
-
-       return (((queue->tail + 1) % FLUSH_QUEUE_SIZE) == queue->head);
-}
-
-#define queue_ring_for_each(i, q) \
-       for (i = (q)->head; i != (q)->tail; i = (i + 1) % FLUSH_QUEUE_SIZE)
-
-static inline unsigned queue_ring_add(struct flush_queue *queue)
-{
-       unsigned idx = queue->tail;
-
-       assert_spin_locked(&queue->lock);
-       queue->tail = (idx + 1) % FLUSH_QUEUE_SIZE;
-
-       return idx;
-}
-
-static inline void queue_ring_remove_head(struct flush_queue *queue)
-{
-       assert_spin_locked(&queue->lock);
-       queue->head = (queue->head + 1) % FLUSH_QUEUE_SIZE;
-}
-
-static void queue_ring_free_flushed(struct dma_ops_domain *dom,
-                                   struct flush_queue *queue)
-{
-       u64 counter = atomic64_read(&dom->flush_finish_cnt);
-       int idx;
-
-       queue_ring_for_each(idx, queue) {
-               /*
-                * This assumes that counter values in the ring-buffer are
-                * monotonously rising.
-                */
-               if (queue->entries[idx].counter >= counter)
-                       break;
-
-               free_iova_fast(&dom->iovad,
-                              queue->entries[idx].iova_pfn,
-                              queue->entries[idx].pages);
-
-               queue_ring_remove_head(queue);
-       }
-}
-
-static void queue_add(struct dma_ops_domain *dom,
-                     unsigned long address, unsigned long pages)
-{
-       struct flush_queue *queue;
-       unsigned long flags;
-       int idx;
-
-       pages     = __roundup_pow_of_two(pages);
-       address >>= PAGE_SHIFT;
-
-       queue = get_cpu_ptr(dom->flush_queue);
-       spin_lock_irqsave(&queue->lock, flags);
-
-       /*
-        * First remove the enries from the ring-buffer that are already
-        * flushed to make the below queue_ring_full() check less likely
-        */
-       queue_ring_free_flushed(dom, queue);
-
-       /*
-        * When ring-queue is full, flush the entries from the IOTLB so
-        * that we can free all entries with queue_ring_free_flushed()
-        * below.
-        */
-       if (queue_ring_full(queue)) {
-               dma_ops_domain_flush_tlb(dom);
-               queue_ring_free_flushed(dom, queue);
-       }
-
-       idx = queue_ring_add(queue);
-
-       queue->entries[idx].iova_pfn = address;
-       queue->entries[idx].pages    = pages;
-       queue->entries[idx].counter  = atomic64_read(&dom->flush_start_cnt);
-
-       spin_unlock_irqrestore(&queue->lock, flags);
-
-       if (atomic_cmpxchg(&dom->flush_timer_on, 0, 1) == 0)
-               mod_timer(&dom->flush_timer, jiffies + msecs_to_jiffies(10));
-
-       put_cpu_ptr(dom->flush_queue);
 }
 
-static void queue_flush_timeout(unsigned long data)
+static void iova_domain_flush_tlb(struct iova_domain *iovad)
 {
-       struct dma_ops_domain *dom = (struct dma_ops_domain *)data;
-       int cpu;
+       struct dma_ops_domain *dom;
 
-       atomic_set(&dom->flush_timer_on, 0);
+       dom = container_of(iovad, struct dma_ops_domain, iovad);
 
        dma_ops_domain_flush_tlb(dom);
-
-       for_each_possible_cpu(cpu) {
-               struct flush_queue *queue;
-               unsigned long flags;
-
-               queue = per_cpu_ptr(dom->flush_queue, cpu);
-               spin_lock_irqsave(&queue->lock, flags);
-               queue_ring_free_flushed(dom, queue);
-               spin_unlock_irqrestore(&queue->lock, flags);
-       }
 }
 
 /*
@@ -1973,11 +1754,6 @@ static void dma_ops_domain_free(struct dma_ops_domain *dom)
 
        del_domain_from_list(&dom->domain);
 
-       if (timer_pending(&dom->flush_timer))
-               del_timer(&dom->flush_timer);
-
-       dma_ops_domain_free_flush_queue(dom);
-
        put_iova_domain(&dom->iovad);
 
        free_pagetable(&dom->domain);
@@ -2013,16 +1789,11 @@ static struct dma_ops_domain *dma_ops_domain_alloc(void)
        init_iova_domain(&dma_dom->iovad, PAGE_SIZE,
                         IOVA_START_PFN, DMA_32BIT_PFN);
 
-       /* Initialize reserved ranges */
-       copy_reserved_iova(&reserved_iova_ranges, &dma_dom->iovad);
-
-       if (dma_ops_domain_alloc_flush_queue(dma_dom))
+       if (init_iova_flush_queue(&dma_dom->iovad, iova_domain_flush_tlb, NULL))
                goto free_dma_dom;
 
-       setup_timer(&dma_dom->flush_timer, queue_flush_timeout,
-                   (unsigned long)dma_dom);
-
-       atomic_set(&dma_dom->flush_timer_on, 0);
+       /* Initialize reserved ranges */
+       copy_reserved_iova(&reserved_iova_ranges, &dma_dom->iovad);
 
        add_domain_to_list(&dma_dom->domain);
 
@@ -2053,7 +1824,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats)
 
        pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK)
                    << DEV_ENTRY_MODE_SHIFT;
-       pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV;
+       pte_root |= DTE_FLAG_IR | DTE_FLAG_IW | DTE_FLAG_V | DTE_FLAG_TV;
 
        flags = amd_iommu_dev_table[devid].data[1];
 
@@ -2086,8 +1857,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats)
                flags    |= tmp;
        }
 
-
-       flags &= ~(DTE_FLAG_SA | 0xffffULL);
+       flags &= ~DEV_DOMID_MASK;
        flags |= domain->id;
 
        amd_iommu_dev_table[devid].data[1]  = flags;
@@ -2097,7 +1867,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats)
 static void clear_dte_entry(u16 devid)
 {
        /* remove entry from the device table seen by the hardware */
-       amd_iommu_dev_table[devid].data[0]  = IOMMU_PTE_P | IOMMU_PTE_TV;
+       amd_iommu_dev_table[devid].data[0]  = DTE_FLAG_V | DTE_FLAG_TV;
        amd_iommu_dev_table[devid].data[1] &= DTE_FLAG_MASK;
 
        amd_iommu_apply_erratum_63(devid);
@@ -2478,11 +2248,21 @@ static struct iommu_group *amd_iommu_device_group(struct device *dev)
 static struct protection_domain *get_domain(struct device *dev)
 {
        struct protection_domain *domain;
+       struct iommu_domain *io_domain;
 
        if (!check_device(dev))
                return ERR_PTR(-EINVAL);
 
        domain = get_dev_data(dev)->domain;
+       if (domain == NULL && get_dev_data(dev)->defer_attach) {
+               get_dev_data(dev)->defer_attach = false;
+               io_domain = iommu_get_domain_for_dev(dev);
+               domain = to_pdomain(io_domain);
+               attach_device(dev, domain);
+       }
+       if (domain == NULL)
+               return ERR_PTR(-EBUSY);
+
        if (!dma_ops_domain(domain))
                return ERR_PTR(-EBUSY);
 
@@ -2528,6 +2308,7 @@ static int dir2prot(enum dma_data_direction direction)
        else
                return 0;
 }
+
 /*
  * This function contains common code for mapping of a physically
  * contiguous memory region into DMA address space. It is used by all
@@ -2619,7 +2400,8 @@ static void __unmap_single(struct dma_ops_domain *dma_dom,
                domain_flush_tlb(&dma_dom->domain);
                domain_flush_complete(&dma_dom->domain);
        } else {
-               queue_add(dma_dom, dma_addr, pages);
+               pages = __roundup_pow_of_two(pages);
+               queue_iova(&dma_dom->iovad, dma_addr >> PAGE_SHIFT, pages, 0);
        }
 }
 
@@ -3373,6 +3155,13 @@ static void amd_iommu_apply_resv_region(struct device *dev,
        WARN_ON_ONCE(reserve_iova(&dma_dom->iovad, start, end) == NULL);
 }
 
+static bool amd_iommu_is_attach_deferred(struct iommu_domain *domain,
+                                        struct device *dev)
+{
+       struct iommu_dev_data *dev_data = dev->archdata.iommu;
+       return dev_data->defer_attach;
+}
+
 const struct iommu_ops amd_iommu_ops = {
        .capable = amd_iommu_capable,
        .domain_alloc = amd_iommu_domain_alloc,
@@ -3389,6 +3178,7 @@ const struct iommu_ops amd_iommu_ops = {
        .get_resv_regions = amd_iommu_get_resv_regions,
        .put_resv_regions = amd_iommu_put_resv_regions,
        .apply_resv_region = amd_iommu_apply_resv_region,
+       .is_attach_deferred = amd_iommu_is_attach_deferred,
        .pgsize_bitmap  = AMD_IOMMU_PGSIZES,
 };
 
@@ -3777,11 +3567,6 @@ EXPORT_SYMBOL(amd_iommu_device_info);
 
 static struct irq_chip amd_ir_chip;
 
-#define DTE_IRQ_PHYS_ADDR_MASK (((1ULL << 45)-1) << 6)
-#define DTE_IRQ_REMAP_INTCTL    (2ULL << 60)
-#define DTE_IRQ_TABLE_LEN       (8ULL << 1)
-#define DTE_IRQ_REMAP_ENABLE    1ULL
-
 static void set_dte_irq_entry(u16 devid, struct irq_remap_table *table)
 {
        u64 dte;
index 372303700566f4f984e6656bd937e2d99bf07cc6..ff8887ac5555210f3f69a2676b6f954c1a381e92 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/export.h>
 #include <linux/iommu.h>
 #include <linux/kmemleak.h>
-#include <linux/crash_dump.h>
 #include <asm/pci-direct.h>
 #include <asm/iommu.h>
 #include <asm/gart.h>
@@ -38,6 +37,7 @@
 #include <asm/io_apic.h>
 #include <asm/irq_remapping.h>
 
+#include <linux/crash_dump.h>
 #include "amd_iommu_proto.h"
 #include "amd_iommu_types.h"
 #include "irq_remapping.h"
@@ -196,6 +196,11 @@ spinlock_t amd_iommu_pd_lock;
  * page table root pointer.
  */
 struct dev_table_entry *amd_iommu_dev_table;
+/*
+ * Pointer to a device table which the content of old device table
+ * will be copied to. It's only be used in kdump kernel.
+ */
+static struct dev_table_entry *old_dev_tbl_cpy;
 
 /*
  * The alias table is a driver specific data structure which contains the
@@ -209,6 +214,7 @@ u16 *amd_iommu_alias_table;
  * for a specific device. It is also indexed by the PCI device id.
  */
 struct amd_iommu **amd_iommu_rlookup_table;
+EXPORT_SYMBOL(amd_iommu_rlookup_table);
 
 /*
  * This table is used to find the irq remapping table for a given device id
@@ -258,6 +264,28 @@ static int amd_iommu_enable_interrupts(void);
 static int __init iommu_go_to_state(enum iommu_init_state state);
 static void init_device_table_dma(void);
 
+static bool amd_iommu_pre_enabled = true;
+
+bool translation_pre_enabled(struct amd_iommu *iommu)
+{
+       return (iommu->flags & AMD_IOMMU_FLAG_TRANS_PRE_ENABLED);
+}
+EXPORT_SYMBOL(translation_pre_enabled);
+
+static void clear_translation_pre_enabled(struct amd_iommu *iommu)
+{
+       iommu->flags &= ~AMD_IOMMU_FLAG_TRANS_PRE_ENABLED;
+}
+
+static void init_translation_status(struct amd_iommu *iommu)
+{
+       u32 ctrl;
+
+       ctrl = readl(iommu->mmio_base + MMIO_CONTROL_OFFSET);
+       if (ctrl & (1<<CONTROL_IOMMU_EN))
+               iommu->flags |= AMD_IOMMU_FLAG_TRANS_PRE_ENABLED;
+}
+
 static inline void update_last_devid(u16 devid)
 {
        if (devid > amd_iommu_last_bdf)
@@ -615,6 +643,14 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu)
        amd_iommu_reset_cmd_buffer(iommu);
 }
 
+/*
+ * This function disables the command buffer
+ */
+static void iommu_disable_command_buffer(struct amd_iommu *iommu)
+{
+       iommu_feature_disable(iommu, CONTROL_CMDBUF_EN);
+}
+
 static void __init free_command_buffer(struct amd_iommu *iommu)
 {
        free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE));
@@ -647,6 +683,14 @@ static void iommu_enable_event_buffer(struct amd_iommu *iommu)
        iommu_feature_enable(iommu, CONTROL_EVT_LOG_EN);
 }
 
+/*
+ * This function disables the event log buffer
+ */
+static void iommu_disable_event_buffer(struct amd_iommu *iommu)
+{
+       iommu_feature_disable(iommu, CONTROL_EVT_LOG_EN);
+}
+
 static void __init free_event_buffer(struct amd_iommu *iommu)
 {
        free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE));
@@ -808,6 +852,96 @@ static int get_dev_entry_bit(u16 devid, u8 bit)
 }
 
 
+static bool copy_device_table(void)
+{
+       u64 int_ctl, int_tab_len, entry = 0, last_entry = 0;
+       struct dev_table_entry *old_devtb = NULL;
+       u32 lo, hi, devid, old_devtb_size;
+       phys_addr_t old_devtb_phys;
+       struct amd_iommu *iommu;
+       u16 dom_id, dte_v, irq_v;
+       gfp_t gfp_flag;
+       u64 tmp;
+
+       if (!amd_iommu_pre_enabled)
+               return false;
+
+       pr_warn("Translation is already enabled - trying to copy translation structures\n");
+       for_each_iommu(iommu) {
+               /* All IOMMUs should use the same device table with the same size */
+               lo = readl(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET);
+               hi = readl(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET + 4);
+               entry = (((u64) hi) << 32) + lo;
+               if (last_entry && last_entry != entry) {
+                       pr_err("IOMMU:%d should use the same dev table as others!/n",
+                               iommu->index);
+                       return false;
+               }
+               last_entry = entry;
+
+               old_devtb_size = ((entry & ~PAGE_MASK) + 1) << 12;
+               if (old_devtb_size != dev_table_size) {
+                       pr_err("The device table size of IOMMU:%d is not expected!/n",
+                               iommu->index);
+                       return false;
+               }
+       }
+
+       old_devtb_phys = entry & PAGE_MASK;
+       if (old_devtb_phys >= 0x100000000ULL) {
+               pr_err("The address of old device table is above 4G, not trustworthy!/n");
+               return false;
+       }
+       old_devtb = memremap(old_devtb_phys, dev_table_size, MEMREMAP_WB);
+       if (!old_devtb)
+               return false;
+
+       gfp_flag = GFP_KERNEL | __GFP_ZERO | GFP_DMA32;
+       old_dev_tbl_cpy = (void *)__get_free_pages(gfp_flag,
+                               get_order(dev_table_size));
+       if (old_dev_tbl_cpy == NULL) {
+               pr_err("Failed to allocate memory for copying old device table!/n");
+               return false;
+       }
+
+       for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
+               old_dev_tbl_cpy[devid] = old_devtb[devid];
+               dom_id = old_devtb[devid].data[1] & DEV_DOMID_MASK;
+               dte_v = old_devtb[devid].data[0] & DTE_FLAG_V;
+
+               if (dte_v && dom_id) {
+                       old_dev_tbl_cpy[devid].data[0] = old_devtb[devid].data[0];
+                       old_dev_tbl_cpy[devid].data[1] = old_devtb[devid].data[1];
+                       __set_bit(dom_id, amd_iommu_pd_alloc_bitmap);
+                       /* If gcr3 table existed, mask it out */
+                       if (old_devtb[devid].data[0] & DTE_FLAG_GV) {
+                               tmp = DTE_GCR3_VAL_B(~0ULL) << DTE_GCR3_SHIFT_B;
+                               tmp |= DTE_GCR3_VAL_C(~0ULL) << DTE_GCR3_SHIFT_C;
+                               old_dev_tbl_cpy[devid].data[1] &= ~tmp;
+                               tmp = DTE_GCR3_VAL_A(~0ULL) << DTE_GCR3_SHIFT_A;
+                               tmp |= DTE_FLAG_GV;
+                               old_dev_tbl_cpy[devid].data[0] &= ~tmp;
+                       }
+               }
+
+               irq_v = old_devtb[devid].data[2] & DTE_IRQ_REMAP_ENABLE;
+               int_ctl = old_devtb[devid].data[2] & DTE_IRQ_REMAP_INTCTL_MASK;
+               int_tab_len = old_devtb[devid].data[2] & DTE_IRQ_TABLE_LEN_MASK;
+               if (irq_v && (int_ctl || int_tab_len)) {
+                       if ((int_ctl != DTE_IRQ_REMAP_INTCTL) ||
+                           (int_tab_len != DTE_IRQ_TABLE_LEN)) {
+                               pr_err("Wrong old irq remapping flag: %#x\n", devid);
+                               return false;
+                       }
+
+                       old_dev_tbl_cpy[devid].data[2] = old_devtb[devid].data[2];
+               }
+       }
+       memunmap(old_devtb);
+
+       return true;
+}
+
 void amd_iommu_apply_erratum_63(u16 devid)
 {
        int sysmgt;
@@ -1399,6 +1533,16 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
 
        iommu->int_enabled = false;
 
+       init_translation_status(iommu);
+       if (translation_pre_enabled(iommu) && !is_kdump_kernel()) {
+               iommu_disable(iommu);
+               clear_translation_pre_enabled(iommu);
+               pr_warn("Translation was enabled for IOMMU:%d but we are not in kdump mode\n",
+                       iommu->index);
+       }
+       if (amd_iommu_pre_enabled)
+               amd_iommu_pre_enabled = translation_pre_enabled(iommu);
+
        ret = init_iommu_from_acpi(iommu, h);
        if (ret)
                return ret;
@@ -1892,8 +2036,7 @@ static int __init init_memory_definitions(struct acpi_table_header *table)
 }
 
 /*
- * Init the device table to not allow DMA access for devices and
- * suppress all page faults
+ * Init the device table to not allow DMA access for devices
  */
 static void init_device_table_dma(void)
 {
@@ -1902,14 +2045,6 @@ static void init_device_table_dma(void)
        for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
                set_dev_entry_bit(devid, DEV_ENTRY_VALID);
                set_dev_entry_bit(devid, DEV_ENTRY_TRANSLATION);
-               /*
-                * In kdump kernels in-flight DMA from the old kernel might
-                * cause IO_PAGE_FAULTs. There are no reports that a kdump
-                * actually failed because of that, so just disable fault
-                * reporting in the hardware to get rid of the messages
-                */
-               if (is_kdump_kernel())
-                       set_dev_entry_bit(devid, DEV_ENTRY_NO_PAGE_FAULT);
        }
 }
 
@@ -2022,24 +2157,62 @@ static void iommu_enable_ga(struct amd_iommu *iommu)
 #endif
 }
 
+static void early_enable_iommu(struct amd_iommu *iommu)
+{
+       iommu_disable(iommu);
+       iommu_init_flags(iommu);
+       iommu_set_device_table(iommu);
+       iommu_enable_command_buffer(iommu);
+       iommu_enable_event_buffer(iommu);
+       iommu_set_exclusion_range(iommu);
+       iommu_enable_ga(iommu);
+       iommu_enable(iommu);
+       iommu_flush_all_caches(iommu);
+}
+
 /*
  * This function finally enables all IOMMUs found in the system after
- * they have been initialized
+ * they have been initialized.
+ *
+ * Or if in kdump kernel and IOMMUs are all pre-enabled, try to copy
+ * the old content of device table entries. Not this case or copy failed,
+ * just continue as normal kernel does.
  */
 static void early_enable_iommus(void)
 {
        struct amd_iommu *iommu;
 
-       for_each_iommu(iommu) {
-               iommu_disable(iommu);
-               iommu_init_flags(iommu);
-               iommu_set_device_table(iommu);
-               iommu_enable_command_buffer(iommu);
-               iommu_enable_event_buffer(iommu);
-               iommu_set_exclusion_range(iommu);
-               iommu_enable_ga(iommu);
-               iommu_enable(iommu);
-               iommu_flush_all_caches(iommu);
+
+       if (!copy_device_table()) {
+               /*
+                * If come here because of failure in copying device table from old
+                * kernel with all IOMMUs enabled, print error message and try to
+                * free allocated old_dev_tbl_cpy.
+                */
+               if (amd_iommu_pre_enabled)
+                       pr_err("Failed to copy DEV table from previous kernel.\n");
+               if (old_dev_tbl_cpy != NULL)
+                       free_pages((unsigned long)old_dev_tbl_cpy,
+                                       get_order(dev_table_size));
+
+               for_each_iommu(iommu) {
+                       clear_translation_pre_enabled(iommu);
+                       early_enable_iommu(iommu);
+               }
+       } else {
+               pr_info("Copied DEV table from previous kernel.\n");
+               free_pages((unsigned long)amd_iommu_dev_table,
+                               get_order(dev_table_size));
+               amd_iommu_dev_table = old_dev_tbl_cpy;
+               for_each_iommu(iommu) {
+                       iommu_disable_command_buffer(iommu);
+                       iommu_disable_event_buffer(iommu);
+                       iommu_enable_command_buffer(iommu);
+                       iommu_enable_event_buffer(iommu);
+                       iommu_enable_ga(iommu);
+                       iommu_set_device_table(iommu);
+                       iommu_flush_all_caches(iommu);
+               }
        }
 
 #ifdef CONFIG_IRQ_REMAP
@@ -2275,7 +2448,8 @@ static int __init early_amd_iommu_init(void)
 
        /* Device table - directly used by all IOMMUs */
        ret = -ENOMEM;
-       amd_iommu_dev_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+       amd_iommu_dev_table = (void *)__get_free_pages(
+                                     GFP_KERNEL | __GFP_ZERO | GFP_DMA32,
                                      get_order(dev_table_size));
        if (amd_iommu_dev_table == NULL)
                goto out;
@@ -2325,7 +2499,8 @@ static int __init early_amd_iommu_init(void)
                goto out;
 
        /* Disable any previously enabled IOMMUs */
-       disable_iommus();
+       if (!is_kdump_kernel() || amd_iommu_disabled)
+               disable_iommus();
 
        if (amd_iommu_irq_remap)
                amd_iommu_irq_remap = check_ioapic_information();
index 466260f8a1df37bb79738d4c8f91b90568cdd7c6..90e62e9b01c5a48bccd79c6b4f544081e68b8524 100644 (file)
@@ -87,4 +87,6 @@ static inline bool iommu_feature(struct amd_iommu *iommu, u64 f)
        return !!(iommu->features & f);
 }
 
+extern bool translation_pre_enabled(struct amd_iommu *iommu);
+extern struct iommu_dev_data *get_dev_data(struct device *dev);
 #endif /* _ASM_X86_AMD_IOMMU_PROTO_H  */
index 294a409e283b7ae4b52c59350756983711bba9d1..5f775fef341c6bcf3974c43e87fe317e0b35ad52 100644 (file)
 
 #define GA_GUEST_NR            0x1
 
+/* Bit value definition for dte irq remapping fields*/
+#define DTE_IRQ_PHYS_ADDR_MASK (((1ULL << 45)-1) << 6)
+#define DTE_IRQ_REMAP_INTCTL_MASK      (0x3ULL << 60)
+#define DTE_IRQ_TABLE_LEN_MASK (0xfULL << 1)
+#define DTE_IRQ_REMAP_INTCTL    (2ULL << 60)
+#define DTE_IRQ_TABLE_LEN       (8ULL << 1)
+#define DTE_IRQ_REMAP_ENABLE    1ULL
+
 #define PAGE_MODE_NONE    0x00
 #define PAGE_MODE_1_LEVEL 0x01
 #define PAGE_MODE_2_LEVEL 0x02
 #define PM_LEVEL_INDEX(x, a)   (((a) >> PM_LEVEL_SHIFT((x))) & 0x1ffULL)
 #define PM_LEVEL_ENC(x)                (((x) << 9) & 0xe00ULL)
 #define PM_LEVEL_PDE(x, a)     ((a) | PM_LEVEL_ENC((x)) | \
-                                IOMMU_PTE_P | IOMMU_PTE_IR | IOMMU_PTE_IW)
+                                IOMMU_PTE_PR | IOMMU_PTE_IR | IOMMU_PTE_IW)
 #define PM_PTE_LEVEL(pte)      (((pte) >> 9) & 0x7ULL)
 
 #define PM_MAP_4k              0
 #define PTE_LEVEL_PAGE_SIZE(level)                     \
        (1ULL << (12 + (9 * (level))))
 
-#define IOMMU_PTE_P  (1ULL << 0)
-#define IOMMU_PTE_TV (1ULL << 1)
+/*
+ * Bit value definition for I/O PTE fields
+ */
+#define IOMMU_PTE_PR (1ULL << 0)
 #define IOMMU_PTE_U  (1ULL << 59)
 #define IOMMU_PTE_FC (1ULL << 60)
 #define IOMMU_PTE_IR (1ULL << 61)
 #define IOMMU_PTE_IW (1ULL << 62)
 
+/*
+ * Bit value definition for DTE fields
+ */
+#define DTE_FLAG_V  (1ULL << 0)
+#define DTE_FLAG_TV (1ULL << 1)
+#define DTE_FLAG_IR (1ULL << 61)
+#define DTE_FLAG_IW (1ULL << 62)
+
 #define DTE_FLAG_IOTLB (1ULL << 32)
-#define DTE_FLAG_SA    (1ULL << 34)
 #define DTE_FLAG_GV    (1ULL << 55)
 #define DTE_FLAG_MASK  (0x3ffULL << 32)
 #define DTE_GLX_SHIFT  (56)
 #define DTE_GLX_MASK   (3)
+#define DEV_DOMID_MASK 0xffffULL
 
 #define DTE_GCR3_VAL_A(x)      (((x) >> 12) & 0x00007ULL)
 #define DTE_GCR3_VAL_B(x)      (((x) >> 15) & 0x0ffffULL)
 #define GCR3_VALID             0x01ULL
 
 #define IOMMU_PAGE_MASK (((1ULL << 52) - 1) & ~0xfffULL)
-#define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_P)
+#define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_PR)
 #define IOMMU_PTE_PAGE(pte) (phys_to_virt((pte) & IOMMU_PAGE_MASK))
 #define IOMMU_PTE_MODE(pte) (((pte) >> 9) & 0x07)
 
@@ -435,6 +453,8 @@ struct iommu_domain;
 struct irq_domain;
 struct amd_irte_ops;
 
+#define AMD_IOMMU_FLAG_TRANS_PRE_ENABLED      (1 << 0)
+
 /*
  * This structure contains generic data for  IOMMU protection domains
  * independent of their use.
@@ -569,12 +589,15 @@ struct amd_iommu {
        struct amd_irte_ops *irte_ops;
 #endif
 
+       u32 flags;
        volatile u64 __aligned(8) cmd_sem;
 };
 
 static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)
 {
-       return container_of(dev, struct amd_iommu, iommu.dev);
+       struct iommu_device *iommu = dev_to_iommu_device(dev);
+
+       return container_of(iommu, struct amd_iommu, iommu);
 }
 
 #define ACPIHID_UID_LEN 256
@@ -597,6 +620,30 @@ struct devid_map {
        bool cmd_line;
 };
 
+/*
+ * This struct contains device specific data for the IOMMU
+ */
+struct iommu_dev_data {
+       struct list_head list;            /* For domain->dev_list */
+       struct list_head dev_data_list;   /* For global dev_data_list */
+       struct protection_domain *domain; /* Domain the device is bound to */
+       u16 devid;                        /* PCI Device ID */
+       u16 alias;                        /* Alias Device ID */
+       bool iommu_v2;                    /* Device can make use of IOMMUv2 */
+       bool passthrough;                 /* Device is identity mapped */
+       struct {
+               bool enabled;
+               int qdep;
+       } ats;                            /* ATS state */
+       bool pri_tlp;                     /* PASID TLB required for
+                                            PPR completions */
+       u32 errata;                       /* Bitmap for errata to apply */
+       bool use_vapic;                   /* Enable device to use vapic mode */
+       bool defer_attach;
+
+       struct ratelimit_state rs;        /* Ratelimit IOPF messages */
+};
+
 /* Map HPET and IOAPIC ids to the devid used by the IOMMU */
 extern struct list_head ioapic_map;
 extern struct list_head hpet_map;
index 6629c472eafd828bb45a9e7fe3a4260c2e199de2..e705fac89cb4448a56876ced9c0ac8e086f08723 100644 (file)
@@ -562,14 +562,30 @@ static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data)
        unsigned long flags;
        struct fault *fault;
        bool finish;
-       u16 tag;
+       u16 tag, devid;
        int ret;
+       struct iommu_dev_data *dev_data;
+       struct pci_dev *pdev = NULL;
 
        iommu_fault = data;
        tag         = iommu_fault->tag & 0x1ff;
        finish      = (iommu_fault->tag >> 9) & 1;
 
+       devid = iommu_fault->device_id;
+       pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff);
+       if (!pdev)
+               return -ENODEV;
+       dev_data = get_dev_data(&pdev->dev);
+
+       /* In kdump kernel pci dev is not initialized yet -> send INVALID */
        ret = NOTIFY_DONE;
+       if (translation_pre_enabled(amd_iommu_rlookup_table[devid])
+               && dev_data->defer_attach) {
+               amd_iommu_complete_ppr(pdev, iommu_fault->pasid,
+                                      PPR_INVALID, tag);
+               goto out;
+       }
+
        dev_state = get_device_state(iommu_fault->device_id);
        if (dev_state == NULL)
                goto out;
diff --git a/drivers/iommu/arm-smmu-regs.h b/drivers/iommu/arm-smmu-regs.h
new file mode 100644 (file)
index 0000000..a1226e4
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * IOMMU API for ARM architected SMMU implementations.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) 2013 ARM Limited
+ *
+ * Author: Will Deacon <will.deacon@arm.com>
+ */
+
+#ifndef _ARM_SMMU_REGS_H
+#define _ARM_SMMU_REGS_H
+
+/* Configuration registers */
+#define ARM_SMMU_GR0_sCR0              0x0
+#define sCR0_CLIENTPD                  (1 << 0)
+#define sCR0_GFRE                      (1 << 1)
+#define sCR0_GFIE                      (1 << 2)
+#define sCR0_EXIDENABLE                        (1 << 3)
+#define sCR0_GCFGFRE                   (1 << 4)
+#define sCR0_GCFGFIE                   (1 << 5)
+#define sCR0_USFCFG                    (1 << 10)
+#define sCR0_VMIDPNE                   (1 << 11)
+#define sCR0_PTM                       (1 << 12)
+#define sCR0_FB                                (1 << 13)
+#define sCR0_VMID16EN                  (1 << 31)
+#define sCR0_BSU_SHIFT                 14
+#define sCR0_BSU_MASK                  0x3
+
+/* Auxiliary Configuration register */
+#define ARM_SMMU_GR0_sACR              0x10
+
+/* Identification registers */
+#define ARM_SMMU_GR0_ID0               0x20
+#define ARM_SMMU_GR0_ID1               0x24
+#define ARM_SMMU_GR0_ID2               0x28
+#define ARM_SMMU_GR0_ID3               0x2c
+#define ARM_SMMU_GR0_ID4               0x30
+#define ARM_SMMU_GR0_ID5               0x34
+#define ARM_SMMU_GR0_ID6               0x38
+#define ARM_SMMU_GR0_ID7               0x3c
+#define ARM_SMMU_GR0_sGFSR             0x48
+#define ARM_SMMU_GR0_sGFSYNR0          0x50
+#define ARM_SMMU_GR0_sGFSYNR1          0x54
+#define ARM_SMMU_GR0_sGFSYNR2          0x58
+
+#define ID0_S1TS                       (1 << 30)
+#define ID0_S2TS                       (1 << 29)
+#define ID0_NTS                                (1 << 28)
+#define ID0_SMS                                (1 << 27)
+#define ID0_ATOSNS                     (1 << 26)
+#define ID0_PTFS_NO_AARCH32            (1 << 25)
+#define ID0_PTFS_NO_AARCH32S           (1 << 24)
+#define ID0_CTTW                       (1 << 14)
+#define ID0_NUMIRPT_SHIFT              16
+#define ID0_NUMIRPT_MASK               0xff
+#define ID0_NUMSIDB_SHIFT              9
+#define ID0_NUMSIDB_MASK               0xf
+#define ID0_EXIDS                      (1 << 8)
+#define ID0_NUMSMRG_SHIFT              0
+#define ID0_NUMSMRG_MASK               0xff
+
+#define ID1_PAGESIZE                   (1 << 31)
+#define ID1_NUMPAGENDXB_SHIFT          28
+#define ID1_NUMPAGENDXB_MASK           7
+#define ID1_NUMS2CB_SHIFT              16
+#define ID1_NUMS2CB_MASK               0xff
+#define ID1_NUMCB_SHIFT                        0
+#define ID1_NUMCB_MASK                 0xff
+
+#define ID2_OAS_SHIFT                  4
+#define ID2_OAS_MASK                   0xf
+#define ID2_IAS_SHIFT                  0
+#define ID2_IAS_MASK                   0xf
+#define ID2_UBS_SHIFT                  8
+#define ID2_UBS_MASK                   0xf
+#define ID2_PTFS_4K                    (1 << 12)
+#define ID2_PTFS_16K                   (1 << 13)
+#define ID2_PTFS_64K                   (1 << 14)
+#define ID2_VMID16                     (1 << 15)
+
+#define ID7_MAJOR_SHIFT                        4
+#define ID7_MAJOR_MASK                 0xf
+
+/* Global TLB invalidation */
+#define ARM_SMMU_GR0_TLBIVMID          0x64
+#define ARM_SMMU_GR0_TLBIALLNSNH       0x68
+#define ARM_SMMU_GR0_TLBIALLH          0x6c
+#define ARM_SMMU_GR0_sTLBGSYNC         0x70
+#define ARM_SMMU_GR0_sTLBGSTATUS       0x74
+#define sTLBGSTATUS_GSACTIVE           (1 << 0)
+
+/* Stream mapping registers */
+#define ARM_SMMU_GR0_SMR(n)            (0x800 + ((n) << 2))
+#define SMR_VALID                      (1 << 31)
+#define SMR_MASK_SHIFT                 16
+#define SMR_ID_SHIFT                   0
+
+#define ARM_SMMU_GR0_S2CR(n)           (0xc00 + ((n) << 2))
+#define S2CR_CBNDX_SHIFT               0
+#define S2CR_CBNDX_MASK                        0xff
+#define S2CR_EXIDVALID                 (1 << 10)
+#define S2CR_TYPE_SHIFT                        16
+#define S2CR_TYPE_MASK                 0x3
+enum arm_smmu_s2cr_type {
+       S2CR_TYPE_TRANS,
+       S2CR_TYPE_BYPASS,
+       S2CR_TYPE_FAULT,
+};
+
+#define S2CR_PRIVCFG_SHIFT             24
+#define S2CR_PRIVCFG_MASK              0x3
+enum arm_smmu_s2cr_privcfg {
+       S2CR_PRIVCFG_DEFAULT,
+       S2CR_PRIVCFG_DIPAN,
+       S2CR_PRIVCFG_UNPRIV,
+       S2CR_PRIVCFG_PRIV,
+};
+
+/* Context bank attribute registers */
+#define ARM_SMMU_GR1_CBAR(n)           (0x0 + ((n) << 2))
+#define CBAR_VMID_SHIFT                        0
+#define CBAR_VMID_MASK                 0xff
+#define CBAR_S1_BPSHCFG_SHIFT          8
+#define CBAR_S1_BPSHCFG_MASK           3
+#define CBAR_S1_BPSHCFG_NSH            3
+#define CBAR_S1_MEMATTR_SHIFT          12
+#define CBAR_S1_MEMATTR_MASK           0xf
+#define CBAR_S1_MEMATTR_WB             0xf
+#define CBAR_TYPE_SHIFT                        16
+#define CBAR_TYPE_MASK                 0x3
+#define CBAR_TYPE_S2_TRANS             (0 << CBAR_TYPE_SHIFT)
+#define CBAR_TYPE_S1_TRANS_S2_BYPASS   (1 << CBAR_TYPE_SHIFT)
+#define CBAR_TYPE_S1_TRANS_S2_FAULT    (2 << CBAR_TYPE_SHIFT)
+#define CBAR_TYPE_S1_TRANS_S2_TRANS    (3 << CBAR_TYPE_SHIFT)
+#define CBAR_IRPTNDX_SHIFT             24
+#define CBAR_IRPTNDX_MASK              0xff
+
+#define ARM_SMMU_GR1_CBA2R(n)          (0x800 + ((n) << 2))
+#define CBA2R_RW64_32BIT               (0 << 0)
+#define CBA2R_RW64_64BIT               (1 << 0)
+#define CBA2R_VMID_SHIFT               16
+#define CBA2R_VMID_MASK                        0xffff
+
+#define ARM_SMMU_CB_SCTLR              0x0
+#define ARM_SMMU_CB_ACTLR              0x4
+#define ARM_SMMU_CB_RESUME             0x8
+#define ARM_SMMU_CB_TTBCR2             0x10
+#define ARM_SMMU_CB_TTBR0              0x20
+#define ARM_SMMU_CB_TTBR1              0x28
+#define ARM_SMMU_CB_TTBCR              0x30
+#define ARM_SMMU_CB_CONTEXTIDR         0x34
+#define ARM_SMMU_CB_S1_MAIR0           0x38
+#define ARM_SMMU_CB_S1_MAIR1           0x3c
+#define ARM_SMMU_CB_PAR                        0x50
+#define ARM_SMMU_CB_FSR                        0x58
+#define ARM_SMMU_CB_FAR                        0x60
+#define ARM_SMMU_CB_FSYNR0             0x68
+#define ARM_SMMU_CB_S1_TLBIVA          0x600
+#define ARM_SMMU_CB_S1_TLBIASID                0x610
+#define ARM_SMMU_CB_S1_TLBIVAL         0x620
+#define ARM_SMMU_CB_S2_TLBIIPAS2       0x630
+#define ARM_SMMU_CB_S2_TLBIIPAS2L      0x638
+#define ARM_SMMU_CB_TLBSYNC            0x7f0
+#define ARM_SMMU_CB_TLBSTATUS          0x7f4
+#define ARM_SMMU_CB_ATS1PR             0x800
+#define ARM_SMMU_CB_ATSR               0x8f0
+
+#define SCTLR_S1_ASIDPNE               (1 << 12)
+#define SCTLR_CFCFG                    (1 << 7)
+#define SCTLR_CFIE                     (1 << 6)
+#define SCTLR_CFRE                     (1 << 5)
+#define SCTLR_E                                (1 << 4)
+#define SCTLR_AFE                      (1 << 2)
+#define SCTLR_TRE                      (1 << 1)
+#define SCTLR_M                                (1 << 0)
+
+#define CB_PAR_F                       (1 << 0)
+
+#define ATSR_ACTIVE                    (1 << 0)
+
+#define RESUME_RETRY                   (0 << 0)
+#define RESUME_TERMINATE               (1 << 0)
+
+#define TTBCR2_SEP_SHIFT               15
+#define TTBCR2_SEP_UPSTREAM            (0x7 << TTBCR2_SEP_SHIFT)
+#define TTBCR2_AS                      (1 << 4)
+
+#define TTBRn_ASID_SHIFT               48
+
+#define FSR_MULTI                      (1 << 31)
+#define FSR_SS                         (1 << 30)
+#define FSR_UUT                                (1 << 8)
+#define FSR_ASF                                (1 << 7)
+#define FSR_TLBLKF                     (1 << 6)
+#define FSR_TLBMCF                     (1 << 5)
+#define FSR_EF                         (1 << 4)
+#define FSR_PF                         (1 << 3)
+#define FSR_AFF                                (1 << 2)
+#define FSR_TF                         (1 << 1)
+
+#define FSR_IGN                                (FSR_AFF | FSR_ASF | \
+                                        FSR_TLBMCF | FSR_TLBLKF)
+#define FSR_FAULT                      (FSR_MULTI | FSR_SS | FSR_UUT | \
+                                        FSR_EF | FSR_PF | FSR_TF | FSR_IGN)
+
+#define FSYNR0_WNR                     (1 << 4)
+
+#endif /* _ARM_SMMU_REGS_H */
index beeb042c718c0d0ad9d8bc8bc4ab51988442700a..3bdb799d3b4b1f5ee1de1e2505d3d0024273c658 100644 (file)
 #include <linux/amba/bus.h>
 
 #include "io-pgtable.h"
+#include "arm-smmu-regs.h"
+
+#define ARM_MMU500_ACTLR_CPRE          (1 << 1)
+
+#define ARM_MMU500_ACR_CACHE_LOCK      (1 << 26)
+#define ARM_MMU500_ACR_SMTNMB_TLBEN    (1 << 8)
+
+#define TLB_LOOP_TIMEOUT               1000000 /* 1s! */
+#define TLB_SPIN_COUNT                 10
 
 /* Maximum number of context banks per SMMU */
 #define ARM_SMMU_MAX_CBS               128
 #define smmu_write_atomic_lq           writel_relaxed
 #endif
 
-/* Configuration registers */
-#define ARM_SMMU_GR0_sCR0              0x0
-#define sCR0_CLIENTPD                  (1 << 0)
-#define sCR0_GFRE                      (1 << 1)
-#define sCR0_GFIE                      (1 << 2)
-#define sCR0_EXIDENABLE                        (1 << 3)
-#define sCR0_GCFGFRE                   (1 << 4)
-#define sCR0_GCFGFIE                   (1 << 5)
-#define sCR0_USFCFG                    (1 << 10)
-#define sCR0_VMIDPNE                   (1 << 11)
-#define sCR0_PTM                       (1 << 12)
-#define sCR0_FB                                (1 << 13)
-#define sCR0_VMID16EN                  (1 << 31)
-#define sCR0_BSU_SHIFT                 14
-#define sCR0_BSU_MASK                  0x3
-
-/* Auxiliary Configuration register */
-#define ARM_SMMU_GR0_sACR              0x10
-
-/* Identification registers */
-#define ARM_SMMU_GR0_ID0               0x20
-#define ARM_SMMU_GR0_ID1               0x24
-#define ARM_SMMU_GR0_ID2               0x28
-#define ARM_SMMU_GR0_ID3               0x2c
-#define ARM_SMMU_GR0_ID4               0x30
-#define ARM_SMMU_GR0_ID5               0x34
-#define ARM_SMMU_GR0_ID6               0x38
-#define ARM_SMMU_GR0_ID7               0x3c
-#define ARM_SMMU_GR0_sGFSR             0x48
-#define ARM_SMMU_GR0_sGFSYNR0          0x50
-#define ARM_SMMU_GR0_sGFSYNR1          0x54
-#define ARM_SMMU_GR0_sGFSYNR2          0x58
-
-#define ID0_S1TS                       (1 << 30)
-#define ID0_S2TS                       (1 << 29)
-#define ID0_NTS                                (1 << 28)
-#define ID0_SMS                                (1 << 27)
-#define ID0_ATOSNS                     (1 << 26)
-#define ID0_PTFS_NO_AARCH32            (1 << 25)
-#define ID0_PTFS_NO_AARCH32S           (1 << 24)
-#define ID0_CTTW                       (1 << 14)
-#define ID0_NUMIRPT_SHIFT              16
-#define ID0_NUMIRPT_MASK               0xff
-#define ID0_NUMSIDB_SHIFT              9
-#define ID0_NUMSIDB_MASK               0xf
-#define ID0_EXIDS                      (1 << 8)
-#define ID0_NUMSMRG_SHIFT              0
-#define ID0_NUMSMRG_MASK               0xff
-
-#define ID1_PAGESIZE                   (1 << 31)
-#define ID1_NUMPAGENDXB_SHIFT          28
-#define ID1_NUMPAGENDXB_MASK           7
-#define ID1_NUMS2CB_SHIFT              16
-#define ID1_NUMS2CB_MASK               0xff
-#define ID1_NUMCB_SHIFT                        0
-#define ID1_NUMCB_MASK                 0xff
-
-#define ID2_OAS_SHIFT                  4
-#define ID2_OAS_MASK                   0xf
-#define ID2_IAS_SHIFT                  0
-#define ID2_IAS_MASK                   0xf
-#define ID2_UBS_SHIFT                  8
-#define ID2_UBS_MASK                   0xf
-#define ID2_PTFS_4K                    (1 << 12)
-#define ID2_PTFS_16K                   (1 << 13)
-#define ID2_PTFS_64K                   (1 << 14)
-#define ID2_VMID16                     (1 << 15)
-
-#define ID7_MAJOR_SHIFT                        4
-#define ID7_MAJOR_MASK                 0xf
-
-/* Global TLB invalidation */
-#define ARM_SMMU_GR0_TLBIVMID          0x64
-#define ARM_SMMU_GR0_TLBIALLNSNH       0x68
-#define ARM_SMMU_GR0_TLBIALLH          0x6c
-#define ARM_SMMU_GR0_sTLBGSYNC         0x70
-#define ARM_SMMU_GR0_sTLBGSTATUS       0x74
-#define sTLBGSTATUS_GSACTIVE           (1 << 0)
-#define TLB_LOOP_TIMEOUT               1000000 /* 1s! */
-#define TLB_SPIN_COUNT                 10
-
-/* Stream mapping registers */
-#define ARM_SMMU_GR0_SMR(n)            (0x800 + ((n) << 2))
-#define SMR_VALID                      (1 << 31)
-#define SMR_MASK_SHIFT                 16
-#define SMR_ID_SHIFT                   0
-
-#define ARM_SMMU_GR0_S2CR(n)           (0xc00 + ((n) << 2))
-#define S2CR_CBNDX_SHIFT               0
-#define S2CR_CBNDX_MASK                        0xff
-#define S2CR_EXIDVALID                 (1 << 10)
-#define S2CR_TYPE_SHIFT                        16
-#define S2CR_TYPE_MASK                 0x3
-enum arm_smmu_s2cr_type {
-       S2CR_TYPE_TRANS,
-       S2CR_TYPE_BYPASS,
-       S2CR_TYPE_FAULT,
-};
-
-#define S2CR_PRIVCFG_SHIFT             24
-#define S2CR_PRIVCFG_MASK              0x3
-enum arm_smmu_s2cr_privcfg {
-       S2CR_PRIVCFG_DEFAULT,
-       S2CR_PRIVCFG_DIPAN,
-       S2CR_PRIVCFG_UNPRIV,
-       S2CR_PRIVCFG_PRIV,
-};
-
-/* Context bank attribute registers */
-#define ARM_SMMU_GR1_CBAR(n)           (0x0 + ((n) << 2))
-#define CBAR_VMID_SHIFT                        0
-#define CBAR_VMID_MASK                 0xff
-#define CBAR_S1_BPSHCFG_SHIFT          8
-#define CBAR_S1_BPSHCFG_MASK           3
-#define CBAR_S1_BPSHCFG_NSH            3
-#define CBAR_S1_MEMATTR_SHIFT          12
-#define CBAR_S1_MEMATTR_MASK           0xf
-#define CBAR_S1_MEMATTR_WB             0xf
-#define CBAR_TYPE_SHIFT                        16
-#define CBAR_TYPE_MASK                 0x3
-#define CBAR_TYPE_S2_TRANS             (0 << CBAR_TYPE_SHIFT)
-#define CBAR_TYPE_S1_TRANS_S2_BYPASS   (1 << CBAR_TYPE_SHIFT)
-#define CBAR_TYPE_S1_TRANS_S2_FAULT    (2 << CBAR_TYPE_SHIFT)
-#define CBAR_TYPE_S1_TRANS_S2_TRANS    (3 << CBAR_TYPE_SHIFT)
-#define CBAR_IRPTNDX_SHIFT             24
-#define CBAR_IRPTNDX_MASK              0xff
-
-#define ARM_SMMU_GR1_CBA2R(n)          (0x800 + ((n) << 2))
-#define CBA2R_RW64_32BIT               (0 << 0)
-#define CBA2R_RW64_64BIT               (1 << 0)
-#define CBA2R_VMID_SHIFT               16
-#define CBA2R_VMID_MASK                        0xffff
-
 /* Translation context bank */
 #define ARM_SMMU_CB(smmu, n)   ((smmu)->cb_base + ((n) << (smmu)->pgshift))
 
-#define ARM_SMMU_CB_SCTLR              0x0
-#define ARM_SMMU_CB_ACTLR              0x4
-#define ARM_SMMU_CB_RESUME             0x8
-#define ARM_SMMU_CB_TTBCR2             0x10
-#define ARM_SMMU_CB_TTBR0              0x20
-#define ARM_SMMU_CB_TTBR1              0x28
-#define ARM_SMMU_CB_TTBCR              0x30
-#define ARM_SMMU_CB_CONTEXTIDR         0x34
-#define ARM_SMMU_CB_S1_MAIR0           0x38
-#define ARM_SMMU_CB_S1_MAIR1           0x3c
-#define ARM_SMMU_CB_PAR                        0x50
-#define ARM_SMMU_CB_FSR                        0x58
-#define ARM_SMMU_CB_FAR                        0x60
-#define ARM_SMMU_CB_FSYNR0             0x68
-#define ARM_SMMU_CB_S1_TLBIVA          0x600
-#define ARM_SMMU_CB_S1_TLBIASID                0x610
-#define ARM_SMMU_CB_S1_TLBIVAL         0x620
-#define ARM_SMMU_CB_S2_TLBIIPAS2       0x630
-#define ARM_SMMU_CB_S2_TLBIIPAS2L      0x638
-#define ARM_SMMU_CB_TLBSYNC            0x7f0
-#define ARM_SMMU_CB_TLBSTATUS          0x7f4
-#define ARM_SMMU_CB_ATS1PR             0x800
-#define ARM_SMMU_CB_ATSR               0x8f0
-
-#define SCTLR_S1_ASIDPNE               (1 << 12)
-#define SCTLR_CFCFG                    (1 << 7)
-#define SCTLR_CFIE                     (1 << 6)
-#define SCTLR_CFRE                     (1 << 5)
-#define SCTLR_E                                (1 << 4)
-#define SCTLR_AFE                      (1 << 2)
-#define SCTLR_TRE                      (1 << 1)
-#define SCTLR_M                                (1 << 0)
-
-#define ARM_MMU500_ACTLR_CPRE          (1 << 1)
-
-#define ARM_MMU500_ACR_CACHE_LOCK      (1 << 26)
-#define ARM_MMU500_ACR_SMTNMB_TLBEN    (1 << 8)
-
-#define CB_PAR_F                       (1 << 0)
-
-#define ATSR_ACTIVE                    (1 << 0)
-
-#define RESUME_RETRY                   (0 << 0)
-#define RESUME_TERMINATE               (1 << 0)
-
-#define TTBCR2_SEP_SHIFT               15
-#define TTBCR2_SEP_UPSTREAM            (0x7 << TTBCR2_SEP_SHIFT)
-#define TTBCR2_AS                      (1 << 4)
-
-#define TTBRn_ASID_SHIFT               48
-
-#define FSR_MULTI                      (1 << 31)
-#define FSR_SS                         (1 << 30)
-#define FSR_UUT                                (1 << 8)
-#define FSR_ASF                                (1 << 7)
-#define FSR_TLBLKF                     (1 << 6)
-#define FSR_TLBMCF                     (1 << 5)
-#define FSR_EF                         (1 << 4)
-#define FSR_PF                         (1 << 3)
-#define FSR_AFF                                (1 << 2)
-#define FSR_TF                         (1 << 1)
-
-#define FSR_IGN                                (FSR_AFF | FSR_ASF | \
-                                        FSR_TLBMCF | FSR_TLBLKF)
-#define FSR_FAULT                      (FSR_MULTI | FSR_SS | FSR_UUT | \
-                                        FSR_EF | FSR_PF | FSR_TF | FSR_IGN)
-
-#define FSYNR0_WNR                     (1 << 4)
-
 #define MSI_IOVA_BASE                  0x8000000
 #define MSI_IOVA_LENGTH                        0x100000
 
index c8b0329c85d2801e1cd99c74c9959f03ee1790d2..ca5ebaeafd6acee8d11033b34ba912eeebc04689 100644 (file)
@@ -1343,7 +1343,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
 
        if (mask) {
                BUG_ON(addr & ((1 << (VTD_PAGE_SHIFT + mask)) - 1));
-               addr |= (1 << (VTD_PAGE_SHIFT + mask - 1)) - 1;
+               addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1;
                desc.high = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE;
        } else
                desc.high = QI_DEV_IOTLB_ADDR(addr);
index 2395478dde7518cb7e74049765888fbef1c64510..f596fcc3289830f5a74ec93d438aa626bebf42fe 100644 (file)
@@ -54,10 +54,6 @@ typedef u32 sysmmu_pte_t;
 #define lv2ent_small(pent) ((*(pent) & 2) == 2)
 #define lv2ent_large(pent) ((*(pent) & 3) == 1)
 
-#ifdef CONFIG_BIG_ENDIAN
-#warning "revisit driver if we can enable big-endian ptes"
-#endif
-
 /*
  * v1.x - v3.x SYSMMU supports 32bit physical and 32bit virtual address spaces
  * v5.0 introduced support for 36bit physical address space by shifting
@@ -569,7 +565,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data,
        spin_unlock_irqrestore(&data->lock, flags);
 }
 
-static struct iommu_ops exynos_iommu_ops;
+static const struct iommu_ops exynos_iommu_ops;
 
 static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 {
@@ -659,6 +655,13 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev)
                }
        }
 
+       /*
+        * use the first registered sysmmu device for performing
+        * dma mapping operations on iommu page tables (cpu cache flush)
+        */
+       if (!dma_dev)
+               dma_dev = &pdev->dev;
+
        pm_runtime_enable(dev);
 
        return 0;
@@ -1323,7 +1326,7 @@ static int exynos_iommu_of_xlate(struct device *dev,
        return 0;
 }
 
-static struct iommu_ops exynos_iommu_ops = {
+static const struct iommu_ops exynos_iommu_ops = {
        .domain_alloc = exynos_iommu_domain_alloc,
        .domain_free = exynos_iommu_domain_free,
        .attach_dev = exynos_iommu_attach_device,
@@ -1339,8 +1342,6 @@ static struct iommu_ops exynos_iommu_ops = {
        .of_xlate = exynos_iommu_of_xlate,
 };
 
-static bool init_done;
-
 static int __init exynos_iommu_init(void)
 {
        int ret;
@@ -1373,8 +1374,6 @@ static int __init exynos_iommu_init(void)
                goto err_set_iommu;
        }
 
-       init_done = true;
-
        return 0;
 err_set_iommu:
        kmem_cache_free(lv2table_kmem_cache, zero_lv2_table);
@@ -1384,27 +1383,6 @@ err_reg_driver:
        kmem_cache_destroy(lv2table_kmem_cache);
        return ret;
 }
+core_initcall(exynos_iommu_init);
 
-static int __init exynos_iommu_of_setup(struct device_node *np)
-{
-       struct platform_device *pdev;
-
-       if (!init_done)
-               exynos_iommu_init();
-
-       pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-       if (!pdev)
-               return -ENODEV;
-
-       /*
-        * use the first registered sysmmu device for performing
-        * dma mapping operations on iommu page tables (cpu cache flush)
-        */
-       if (!dma_dev)
-               dma_dev = &pdev->dev;
-
-       return 0;
-}
-
-IOMMU_OF_DECLARE(exynos_iommu_of, "samsung,exynos-sysmmu",
-                exynos_iommu_of_setup);
+IOMMU_OF_DECLARE(exynos_iommu_of, "samsung,exynos-sysmmu", NULL);
index a34355fca37a555e5d5df308bd8df69f4a830b47..8540625796a16a482870e028afb72b96f4b93212 100644 (file)
@@ -42,6 +42,8 @@ struct pamu_isr_data {
 static struct paace *ppaact;
 static struct paace *spaact;
 
+static bool probed;                    /* Has PAMU been probed? */
+
 /*
  * Table for matching compatible strings, for device tree
  * guts node, for QorIQ SOCs.
@@ -530,8 +532,8 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu)
                if (node) {
                        prop = of_get_property(node, "cache-stash-id", NULL);
                        if (!prop) {
-                               pr_debug("missing cache-stash-id at %s\n",
-                                        node->full_name);
+                               pr_debug("missing cache-stash-id at %pOF\n",
+                                        node);
                                of_node_put(node);
                                return ~(u32)0;
                        }
@@ -557,8 +559,8 @@ found_cpu_node:
                if (stash_dest_hint == cache_level) {
                        prop = of_get_property(node, "cache-stash-id", NULL);
                        if (!prop) {
-                               pr_debug("missing cache-stash-id at %s\n",
-                                        node->full_name);
+                               pr_debug("missing cache-stash-id at %pOF\n",
+                                        node);
                                of_node_put(node);
                                return ~(u32)0;
                        }
@@ -568,8 +570,7 @@ found_cpu_node:
 
                prop = of_get_property(node, "next-level-cache", NULL);
                if (!prop) {
-                       pr_debug("can't find next-level-cache at %s\n",
-                                node->full_name);
+                       pr_debug("can't find next-level-cache at %pOF\n", node);
                        of_node_put(node);
                        return ~(u32)0;  /* can't traverse any further */
                }
@@ -1033,6 +1034,9 @@ static int fsl_pamu_probe(struct platform_device *pdev)
         * NOTE : All PAMUs share the same LIODN tables.
         */
 
+       if (WARN_ON(probed))
+               return -EBUSY;
+
        pamu_regs = of_iomap(dev->of_node, 0);
        if (!pamu_regs) {
                dev_err(dev, "ioremap of PAMU node failed\n");
@@ -1063,8 +1067,7 @@ static int fsl_pamu_probe(struct platform_device *pdev)
 
        guts_node = of_find_matching_node(NULL, guts_device_ids);
        if (!guts_node) {
-               dev_err(dev, "could not find GUTS node %s\n",
-                       dev->of_node->full_name);
+               dev_err(dev, "could not find GUTS node %pOF\n", dev->of_node);
                ret = -ENODEV;
                goto error;
        }
@@ -1172,6 +1175,8 @@ static int fsl_pamu_probe(struct platform_device *pdev)
 
        setup_liodns();
 
+       probed = true;
+
        return 0;
 
 error_genpool:
@@ -1246,8 +1251,7 @@ static __init int fsl_pamu_init(void)
 
        pdev = platform_device_alloc("fsl-of-pamu", 0);
        if (!pdev) {
-               pr_err("could not allocate device %s\n",
-                      np->full_name);
+               pr_err("could not allocate device %pOF\n", np);
                ret = -ENOMEM;
                goto error_device_alloc;
        }
@@ -1259,8 +1263,7 @@ static __init int fsl_pamu_init(void)
 
        ret = platform_device_add(pdev);
        if (ret) {
-               pr_err("could not add device %s (err=%i)\n",
-                      np->full_name, ret);
+               pr_err("could not add device %pOF (err=%i)\n", np, ret);
                goto error_device_add;
        }
 
index da0e1e30ef378841601eab22e9e5a50c0049efc1..f089136e9c3f1953ce4513193908e53b2cbf05c2 100644 (file)
@@ -33,6 +33,8 @@ static struct kmem_cache *fsl_pamu_domain_cache;
 static struct kmem_cache *iommu_devinfo_cache;
 static DEFINE_SPINLOCK(device_domain_lock);
 
+struct iommu_device pamu_iommu;        /* IOMMU core code handle */
+
 static struct fsl_dma_domain *to_fsl_dma_domain(struct iommu_domain *dom)
 {
        return container_of(dom, struct fsl_dma_domain, iommu_domain);
@@ -619,8 +621,8 @@ static int handle_attach_device(struct fsl_dma_domain *dma_domain,
        for (i = 0; i < num; i++) {
                /* Ensure that LIODN value is valid */
                if (liodn[i] >= PAACE_NUMBER_ENTRIES) {
-                       pr_debug("Invalid liodn %d, attach device failed for %s\n",
-                                liodn[i], dev->of_node->full_name);
+                       pr_debug("Invalid liodn %d, attach device failed for %pOF\n",
+                                liodn[i], dev->of_node);
                        ret = -EINVAL;
                        break;
                }
@@ -684,8 +686,7 @@ static int fsl_pamu_attach_device(struct iommu_domain *domain,
                liodn_cnt = len / sizeof(u32);
                ret = handle_attach_device(dma_domain, dev, liodn, liodn_cnt);
        } else {
-               pr_debug("missing fsl,liodn property at %s\n",
-                        dev->of_node->full_name);
+               pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
                ret = -EINVAL;
        }
 
@@ -720,8 +721,7 @@ static void fsl_pamu_detach_device(struct iommu_domain *domain,
        if (prop)
                detach_device(dev, dma_domain);
        else
-               pr_debug("missing fsl,liodn property at %s\n",
-                        dev->of_node->full_name);
+               pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
 }
 
 static  int configure_domain_geometry(struct iommu_domain *domain, void *data)
@@ -983,11 +983,14 @@ static int fsl_pamu_add_device(struct device *dev)
 
        iommu_group_put(group);
 
+       iommu_device_link(&pamu_iommu, dev);
+
        return 0;
 }
 
 static void fsl_pamu_remove_device(struct device *dev)
 {
+       iommu_device_unlink(&pamu_iommu, dev);
        iommu_group_remove_device(dev);
 }
 
@@ -1073,6 +1076,19 @@ int __init pamu_domain_init(void)
        if (ret)
                return ret;
 
+       ret = iommu_device_sysfs_add(&pamu_iommu, NULL, NULL, "iommu0");
+       if (ret)
+               return ret;
+
+       iommu_device_set_ops(&pamu_iommu, &fsl_pamu_ops);
+
+       ret = iommu_device_register(&pamu_iommu);
+       if (ret) {
+               iommu_device_sysfs_remove(&pamu_iommu);
+               pr_err("Can't register iommu device\n");
+               return ret;
+       }
+
        bus_set_iommu(&platform_bus_type, &fsl_pamu_ops);
        bus_set_iommu(&pci_bus_type, &fsl_pamu_ops);
 
index 687f18f65cea58d2a5f22725a2c36c78621dd3cd..2be8e23448eeb8615596fecb4b39363522919d8a 100644 (file)
@@ -458,31 +458,6 @@ static LIST_HEAD(dmar_rmrr_units);
 #define for_each_rmrr_units(rmrr) \
        list_for_each_entry(rmrr, &dmar_rmrr_units, list)
 
-static void flush_unmaps_timeout(unsigned long data);
-
-struct deferred_flush_entry {
-       unsigned long iova_pfn;
-       unsigned long nrpages;
-       struct dmar_domain *domain;
-       struct page *freelist;
-};
-
-#define HIGH_WATER_MARK 250
-struct deferred_flush_table {
-       int next;
-       struct deferred_flush_entry entries[HIGH_WATER_MARK];
-};
-
-struct deferred_flush_data {
-       spinlock_t lock;
-       int timer_on;
-       struct timer_list timer;
-       long size;
-       struct deferred_flush_table *tables;
-};
-
-static DEFINE_PER_CPU(struct deferred_flush_data, deferred_flush);
-
 /* bitmap for indexing intel_iommus */
 static int g_num_of_iommus;
 
@@ -974,20 +949,6 @@ static int device_context_mapped(struct intel_iommu *iommu, u8 bus, u8 devfn)
        return ret;
 }
 
-static void clear_context_table(struct intel_iommu *iommu, u8 bus, u8 devfn)
-{
-       struct context_entry *context;
-       unsigned long flags;
-
-       spin_lock_irqsave(&iommu->lock, flags);
-       context = iommu_context_addr(iommu, bus, devfn, 0);
-       if (context) {
-               context_clear_entry(context);
-               __iommu_flush_cache(iommu, context, sizeof(*context));
-       }
-       spin_unlock_irqrestore(&iommu->lock, flags);
-}
-
 static void free_context_table(struct intel_iommu *iommu)
 {
        int i;
@@ -1137,8 +1098,9 @@ static void dma_pte_clear_range(struct dmar_domain *domain,
 }
 
 static void dma_pte_free_level(struct dmar_domain *domain, int level,
-                              struct dma_pte *pte, unsigned long pfn,
-                              unsigned long start_pfn, unsigned long last_pfn)
+                              int retain_level, struct dma_pte *pte,
+                              unsigned long pfn, unsigned long start_pfn,
+                              unsigned long last_pfn)
 {
        pfn = max(start_pfn, pfn);
        pte = &pte[pfn_level_offset(pfn, level)];
@@ -1153,12 +1115,17 @@ static void dma_pte_free_level(struct dmar_domain *domain, int level,
                level_pfn = pfn & level_mask(level);
                level_pte = phys_to_virt(dma_pte_addr(pte));
 
-               if (level > 2)
-                       dma_pte_free_level(domain, level - 1, level_pte,
-                                          level_pfn, start_pfn, last_pfn);
+               if (level > 2) {
+                       dma_pte_free_level(domain, level - 1, retain_level,
+                                          level_pte, level_pfn, start_pfn,
+                                          last_pfn);
+               }
 
-               /* If range covers entire pagetable, free it */
-               if (!(start_pfn > level_pfn ||
+               /*
+                * Free the page table if we're below the level we want to
+                * retain and the range covers the entire table.
+                */
+               if (level < retain_level && !(start_pfn > level_pfn ||
                      last_pfn < level_pfn + level_size(level) - 1)) {
                        dma_clear_pte(pte);
                        domain_flush_cache(domain, pte, sizeof(*pte));
@@ -1169,10 +1136,14 @@ next:
        } while (!first_pte_in_page(++pte) && pfn <= last_pfn);
 }
 
-/* clear last level (leaf) ptes and free page table pages. */
+/*
+ * clear last level (leaf) ptes and free page table pages below the
+ * level we wish to keep intact.
+ */
 static void dma_pte_free_pagetable(struct dmar_domain *domain,
                                   unsigned long start_pfn,
-                                  unsigned long last_pfn)
+                                  unsigned long last_pfn,
+                                  int retain_level)
 {
        BUG_ON(!domain_pfn_supported(domain, start_pfn));
        BUG_ON(!domain_pfn_supported(domain, last_pfn));
@@ -1181,7 +1152,7 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
        dma_pte_clear_range(domain, start_pfn, last_pfn);
 
        /* We don't need lock here; nobody else touches the iova range */
-       dma_pte_free_level(domain, agaw_to_level(domain->agaw),
+       dma_pte_free_level(domain, agaw_to_level(domain->agaw), retain_level,
                           domain->pgd, 0, start_pfn, last_pfn);
 
        /* free pgd */
@@ -1309,6 +1280,13 @@ static void dma_free_pagelist(struct page *freelist)
        }
 }
 
+static void iova_entry_free(unsigned long data)
+{
+       struct page *freelist = (struct page *)data;
+
+       dma_free_pagelist(freelist);
+}
+
 /* iommu handling */
 static int iommu_alloc_root_entry(struct intel_iommu *iommu)
 {
@@ -1622,6 +1600,25 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu,
                                      addr, mask);
 }
 
+static void iommu_flush_iova(struct iova_domain *iovad)
+{
+       struct dmar_domain *domain;
+       int idx;
+
+       domain = container_of(iovad, struct dmar_domain, iovad);
+
+       for_each_domain_iommu(idx, domain) {
+               struct intel_iommu *iommu = g_iommus[idx];
+               u16 did = domain->iommu_did[iommu->seq_id];
+
+               iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH);
+
+               if (!cap_caching_mode(iommu->cap))
+                       iommu_flush_dev_iotlb(get_iommu_domain(iommu, did),
+                                             0, MAX_AGAW_PFN_WIDTH);
+       }
+}
+
 static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)
 {
        u32 pmen;
@@ -1932,9 +1929,16 @@ static int domain_init(struct dmar_domain *domain, struct intel_iommu *iommu,
 {
        int adjust_width, agaw;
        unsigned long sagaw;
+       int err;
 
        init_iova_domain(&domain->iovad, VTD_PAGE_SIZE, IOVA_START_PFN,
                        DMA_32BIT_PFN);
+
+       err = init_iova_flush_queue(&domain->iovad,
+                                   iommu_flush_iova, iova_entry_free);
+       if (err)
+               return err;
+
        domain_reserve_special_ranges(domain);
 
        /* calculate AGAW */
@@ -1986,14 +1990,6 @@ static void domain_exit(struct dmar_domain *domain)
        if (!domain)
                return;
 
-       /* Flush any lazy unmaps that may reference this domain */
-       if (!intel_iommu_strict) {
-               int cpu;
-
-               for_each_possible_cpu(cpu)
-                       flush_unmaps_timeout(cpu);
-       }
-
        /* Remove associated devices and clear attached or cached domains */
        rcu_read_lock();
        domain_remove_dev_info(domain);
@@ -2277,8 +2273,11 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
                                /*
                                 * Ensure that old small page tables are
                                 * removed to make room for superpage(s).
+                                * We're adding new large pages, so make sure
+                                * we don't remove their parent tables.
                                 */
-                               dma_pte_free_pagetable(domain, iov_pfn, end_pfn);
+                               dma_pte_free_pagetable(domain, iov_pfn, end_pfn,
+                                                      largepage_lvl + 1);
                        } else {
                                pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE;
                        }
@@ -2351,13 +2350,33 @@ static inline int domain_pfn_mapping(struct dmar_domain *domain, unsigned long i
 
 static void domain_context_clear_one(struct intel_iommu *iommu, u8 bus, u8 devfn)
 {
+       unsigned long flags;
+       struct context_entry *context;
+       u16 did_old;
+
        if (!iommu)
                return;
 
-       clear_context_table(iommu, bus, devfn);
-       iommu->flush.flush_context(iommu, 0, 0, 0,
-                                          DMA_CCMD_GLOBAL_INVL);
-       iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH);
+       spin_lock_irqsave(&iommu->lock, flags);
+       context = iommu_context_addr(iommu, bus, devfn, 0);
+       if (!context) {
+               spin_unlock_irqrestore(&iommu->lock, flags);
+               return;
+       }
+       did_old = context_domain_id(context);
+       context_clear_entry(context);
+       __iommu_flush_cache(iommu, context, sizeof(*context));
+       spin_unlock_irqrestore(&iommu->lock, flags);
+       iommu->flush.flush_context(iommu,
+                                  did_old,
+                                  (((u16)bus) << 8) | devfn,
+                                  DMA_CCMD_MASK_NOBIT,
+                                  DMA_CCMD_DEVICE_INVL);
+       iommu->flush.flush_iotlb(iommu,
+                                did_old,
+                                0,
+                                0,
+                                DMA_TLB_DSI_FLUSH);
 }
 
 static inline void unlink_domain_info(struct device_domain_info *info)
@@ -3206,7 +3225,7 @@ static int __init init_dmars(void)
        bool copied_tables = false;
        struct device *dev;
        struct intel_iommu *iommu;
-       int i, ret, cpu;
+       int i, ret;
 
        /*
         * for each drhd
@@ -3239,22 +3258,6 @@ static int __init init_dmars(void)
                goto error;
        }
 
-       for_each_possible_cpu(cpu) {
-               struct deferred_flush_data *dfd = per_cpu_ptr(&deferred_flush,
-                                                             cpu);
-
-               dfd->tables = kzalloc(g_num_of_iommus *
-                                     sizeof(struct deferred_flush_table),
-                                     GFP_KERNEL);
-               if (!dfd->tables) {
-                       ret = -ENOMEM;
-                       goto free_g_iommus;
-               }
-
-               spin_lock_init(&dfd->lock);
-               setup_timer(&dfd->timer, flush_unmaps_timeout, cpu);
-       }
-
        for_each_active_iommu(iommu, drhd) {
                g_iommus[iommu->seq_id] = iommu;
 
@@ -3437,10 +3440,9 @@ free_iommu:
                disable_dmar_iommu(iommu);
                free_dmar_iommu(iommu);
        }
-free_g_iommus:
-       for_each_possible_cpu(cpu)
-               kfree(per_cpu_ptr(&deferred_flush, cpu)->tables);
+
        kfree(g_iommus);
+
 error:
        return ret;
 }
@@ -3645,110 +3647,6 @@ static dma_addr_t intel_map_page(struct device *dev, struct page *page,
                                  dir, *dev->dma_mask);
 }
 
-static void flush_unmaps(struct deferred_flush_data *flush_data)
-{
-       int i, j;
-
-       flush_data->timer_on = 0;
-
-       /* just flush them all */
-       for (i = 0; i < g_num_of_iommus; i++) {
-               struct intel_iommu *iommu = g_iommus[i];
-               struct deferred_flush_table *flush_table =
-                               &flush_data->tables[i];
-               if (!iommu)
-                       continue;
-
-               if (!flush_table->next)
-                       continue;
-
-               /* In caching mode, global flushes turn emulation expensive */
-               if (!cap_caching_mode(iommu->cap))
-                       iommu->flush.flush_iotlb(iommu, 0, 0, 0,
-                                        DMA_TLB_GLOBAL_FLUSH);
-               for (j = 0; j < flush_table->next; j++) {
-                       unsigned long mask;
-                       struct deferred_flush_entry *entry =
-                                               &flush_table->entries[j];
-                       unsigned long iova_pfn = entry->iova_pfn;
-                       unsigned long nrpages = entry->nrpages;
-                       struct dmar_domain *domain = entry->domain;
-                       struct page *freelist = entry->freelist;
-
-                       /* On real hardware multiple invalidations are expensive */
-                       if (cap_caching_mode(iommu->cap))
-                               iommu_flush_iotlb_psi(iommu, domain,
-                                       mm_to_dma_pfn(iova_pfn),
-                                       nrpages, !freelist, 0);
-                       else {
-                               mask = ilog2(nrpages);
-                               iommu_flush_dev_iotlb(domain,
-                                               (uint64_t)iova_pfn << PAGE_SHIFT, mask);
-                       }
-                       free_iova_fast(&domain->iovad, iova_pfn, nrpages);
-                       if (freelist)
-                               dma_free_pagelist(freelist);
-               }
-               flush_table->next = 0;
-       }
-
-       flush_data->size = 0;
-}
-
-static void flush_unmaps_timeout(unsigned long cpuid)
-{
-       struct deferred_flush_data *flush_data = per_cpu_ptr(&deferred_flush, cpuid);
-       unsigned long flags;
-
-       spin_lock_irqsave(&flush_data->lock, flags);
-       flush_unmaps(flush_data);
-       spin_unlock_irqrestore(&flush_data->lock, flags);
-}
-
-static void add_unmap(struct dmar_domain *dom, unsigned long iova_pfn,
-                     unsigned long nrpages, struct page *freelist)
-{
-       unsigned long flags;
-       int entry_id, iommu_id;
-       struct intel_iommu *iommu;
-       struct deferred_flush_entry *entry;
-       struct deferred_flush_data *flush_data;
-
-       flush_data = raw_cpu_ptr(&deferred_flush);
-
-       /* Flush all CPUs' entries to avoid deferring too much.  If
-        * this becomes a bottleneck, can just flush us, and rely on
-        * flush timer for the rest.
-        */
-       if (flush_data->size == HIGH_WATER_MARK) {
-               int cpu;
-
-               for_each_online_cpu(cpu)
-                       flush_unmaps_timeout(cpu);
-       }
-
-       spin_lock_irqsave(&flush_data->lock, flags);
-
-       iommu = domain_get_iommu(dom);
-       iommu_id = iommu->seq_id;
-
-       entry_id = flush_data->tables[iommu_id].next;
-       ++(flush_data->tables[iommu_id].next);
-
-       entry = &flush_data->tables[iommu_id].entries[entry_id];
-       entry->domain = dom;
-       entry->iova_pfn = iova_pfn;
-       entry->nrpages = nrpages;
-       entry->freelist = freelist;
-
-       if (!flush_data->timer_on) {
-               mod_timer(&flush_data->timer, jiffies + msecs_to_jiffies(10));
-               flush_data->timer_on = 1;
-       }
-       flush_data->size++;
-       spin_unlock_irqrestore(&flush_data->lock, flags);
-}
-
 static void intel_unmap(struct device *dev, dma_addr_t dev_addr, size_t size)
 {
        struct dmar_domain *domain;
@@ -3784,7 +3682,8 @@ static void intel_unmap(struct device *dev, dma_addr_t dev_addr, size_t size)
                free_iova_fast(&domain->iovad, iova_pfn, dma_to_mm_pfn(nrpages));
                dma_free_pagelist(freelist);
        } else {
-               add_unmap(domain, iova_pfn, nrpages, freelist);
+               queue_iova(&domain->iovad, iova_pfn, nrpages,
+                          (unsigned long)freelist);
                /*
                 * queue up the release of the unmap to save the 1/6th of the
                 * cpu used up by the iotlb flush operation...
@@ -3938,7 +3837,8 @@ static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nele
        ret = domain_sg_mapping(domain, start_vpfn, sglist, size, prot);
        if (unlikely(ret)) {
                dma_pte_free_pagetable(domain, start_vpfn,
-                                      start_vpfn + size - 1);
+                                      start_vpfn + size - 1,
+                                      agaw_to_level(domain->agaw) + 1);
                free_iova_fast(&domain->iovad, iova_pfn, dma_to_mm_pfn(size));
                return 0;
        }
@@ -4721,7 +4621,6 @@ static void free_all_cpu_cached_iovas(unsigned int cpu)
 static int intel_iommu_cpu_dead(unsigned int cpu)
 {
        free_all_cpu_cached_iovas(cpu);
-       flush_unmaps_timeout(cpu);
        return 0;
 }
 
@@ -4736,7 +4635,9 @@ static void intel_disable_iommus(void)
 
 static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev)
 {
-       return container_of(dev, struct intel_iommu, iommu.dev);
+       struct iommu_device *iommu_dev = dev_to_iommu_device(dev);
+
+       return container_of(iommu_dev, struct intel_iommu, iommu);
 }
 
 static ssize_t intel_iommu_show_version(struct device *dev,
@@ -5341,7 +5242,8 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
        sdev->sid = PCI_DEVID(info->bus, info->devfn);
 
        if (!(ctx_lo & CONTEXT_PASIDE)) {
-               context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
+               if (iommu->pasid_state_table)
+                       context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
                context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
                        intel_iommu_get_pts(iommu);
 
index f167c0d84ebfb7f5937eb798c9cdbd8bd9abe6c6..0c9f0773601dec05cc3e9faa3d893621dc98d9b2 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pci-ats.h>
 #include <linux/dmar.h>
 #include <linux/interrupt.h>
+#include <asm/page.h>
 
 static irqreturn_t prq_event_thread(int irq, void *d);
 
@@ -555,6 +556,14 @@ static bool access_error(struct vm_area_struct *vma, struct page_req_dsc *req)
        return (requested & ~vma->vm_flags) != 0;
 }
 
+static bool is_canonical_address(u64 addr)
+{
+       int shift = 64 - (__VIRTUAL_MASK_SHIFT + 1);
+       long saddr = (long) addr;
+
+       return (((saddr << shift) >> shift) == saddr);
+}
+
 static irqreturn_t prq_event_thread(int irq, void *d)
 {
        struct intel_iommu *iommu = d;
@@ -612,6 +621,11 @@ static irqreturn_t prq_event_thread(int irq, void *d)
                /* If the mm is already defunct, don't handle faults. */
                if (!mmget_not_zero(svm->mm))
                        goto bad_req;
+
+               /* If address is not canonical, return invalid response */
+               if (!is_canonical_address(address))
+                       goto bad_req;
+
                down_read(&svm->mm->mmap_sem);
                vma = find_extend_vma(svm->mm, address);
                if (!vma || address < vma->vm_start)
index c58351ed61c14309c7a72346bd56f659a7039637..36d1a7ce7fc4cc922cade9642b5d64c05e5d8e19 100644 (file)
@@ -62,32 +62,40 @@ int iommu_device_sysfs_add(struct iommu_device *iommu,
        va_list vargs;
        int ret;
 
-       device_initialize(&iommu->dev);
+       iommu->dev = kzalloc(sizeof(*iommu->dev), GFP_KERNEL);
+       if (!iommu->dev)
+               return -ENOMEM;
 
-       iommu->dev.class = &iommu_class;
-       iommu->dev.parent = parent;
-       iommu->dev.groups = groups;
+       device_initialize(iommu->dev);
+
+       iommu->dev->class = &iommu_class;
+       iommu->dev->parent = parent;
+       iommu->dev->groups = groups;
 
        va_start(vargs, fmt);
-       ret = kobject_set_name_vargs(&iommu->dev.kobj, fmt, vargs);
+       ret = kobject_set_name_vargs(&iommu->dev->kobj, fmt, vargs);
        va_end(vargs);
        if (ret)
                goto error;
 
-       ret = device_add(&iommu->dev);
+       ret = device_add(iommu->dev);
        if (ret)
                goto error;
 
+       dev_set_drvdata(iommu->dev, iommu);
+
        return 0;
 
 error:
-       put_device(&iommu->dev);
+       put_device(iommu->dev);
        return ret;
 }
 
 void iommu_device_sysfs_remove(struct iommu_device *iommu)
 {
-       device_unregister(&iommu->dev);
+       dev_set_drvdata(iommu->dev, NULL);
+       device_unregister(iommu->dev);
+       iommu->dev = NULL;
 }
 /*
  * IOMMU drivers can indicate a device is managed by a given IOMMU using
@@ -102,14 +110,14 @@ int iommu_device_link(struct iommu_device *iommu, struct device *link)
        if (!iommu || IS_ERR(iommu))
                return -ENODEV;
 
-       ret = sysfs_add_link_to_group(&iommu->dev.kobj, "devices",
+       ret = sysfs_add_link_to_group(&iommu->dev->kobj, "devices",
                                      &link->kobj, dev_name(link));
        if (ret)
                return ret;
 
-       ret = sysfs_create_link_nowarn(&link->kobj, &iommu->dev.kobj, "iommu");
+       ret = sysfs_create_link_nowarn(&link->kobj, &iommu->dev->kobj, "iommu");
        if (ret)
-               sysfs_remove_link_from_group(&iommu->dev.kobj, "devices",
+               sysfs_remove_link_from_group(&iommu->dev->kobj, "devices",
                                             dev_name(link));
 
        return ret;
@@ -121,5 +129,5 @@ void iommu_device_unlink(struct iommu_device *iommu, struct device *link)
                return;
 
        sysfs_remove_link(&link->kobj, "iommu");
-       sysfs_remove_link_from_group(&iommu->dev.kobj, "devices", dev_name(link));
+       sysfs_remove_link_from_group(&iommu->dev->kobj, "devices", dev_name(link));
 }
index 3f6ea160afed3bdf0e06a220b89e53c04b7ba84f..3de5c0bcb5cc9f32b6fb615ce38f5729ae86d407 100644 (file)
@@ -527,6 +527,8 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
 
        }
 
+       iommu_flush_tlb_all(domain);
+
 out:
        iommu_put_resv_regions(dev, &mappings);
 
@@ -1005,11 +1007,10 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
        if (group)
                return group;
 
-       group = ERR_PTR(-EINVAL);
-
-       if (ops && ops->device_group)
-               group = ops->device_group(dev);
+       if (!ops)
+               return ERR_PTR(-EINVAL);
 
+       group = ops->device_group(dev);
        if (WARN_ON_ONCE(group == NULL))
                return ERR_PTR(-EINVAL);
 
@@ -1283,6 +1284,10 @@ 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;
 
@@ -1298,12 +1303,8 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
        int ret;
 
        group = iommu_group_get(dev);
-       /* FIXME: Remove this when groups a mandatory for iommu drivers */
-       if (group == NULL)
-               return __iommu_attach_device(domain, dev);
-
        /*
-        * We have a group - lock it to make sure the device-count doesn't
+        * Lock the group to make sure the device-count doesn't
         * change while we are attaching
         */
        mutex_lock(&group->mutex);
@@ -1324,6 +1325,10 @@ EXPORT_SYMBOL_GPL(iommu_attach_device);
 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))
+               return;
+
        if (unlikely(domain->ops->detach_dev == NULL))
                return;
 
@@ -1336,9 +1341,6 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
        struct iommu_group *group;
 
        group = iommu_group_get(dev);
-       /* FIXME: Remove this when groups a mandatory for iommu drivers */
-       if (group == NULL)
-               return __iommu_detach_device(domain, dev);
 
        mutex_lock(&group->mutex);
        if (iommu_group_device_count(group) != 1) {
@@ -1360,8 +1362,7 @@ struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
        struct iommu_group *group;
 
        group = iommu_group_get(dev);
-       /* FIXME: Remove this when groups a mandatory for iommu drivers */
-       if (group == NULL)
+       if (!group)
                return NULL;
 
        domain = group->domain;
@@ -1556,13 +1557,16 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
 }
 EXPORT_SYMBOL_GPL(iommu_map);
 
-size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
+static size_t __iommu_unmap(struct iommu_domain *domain,
+                           unsigned long iova, size_t size,
+                           bool sync)
 {
+       const struct iommu_ops *ops = domain->ops;
        size_t unmapped_page, unmapped = 0;
-       unsigned int min_pagesz;
        unsigned long orig_iova = iova;
+       unsigned int min_pagesz;
 
-       if (unlikely(domain->ops->unmap == NULL ||
+       if (unlikely(ops->unmap == NULL ||
                     domain->pgsize_bitmap == 0UL))
                return -ENODEV;
 
@@ -1592,10 +1596,13 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
        while (unmapped < size) {
                size_t pgsize = iommu_pgsize(domain, iova, size - unmapped);
 
-               unmapped_page = domain->ops->unmap(domain, iova, pgsize);
+               unmapped_page = ops->unmap(domain, iova, pgsize);
                if (!unmapped_page)
                        break;
 
+               if (sync && ops->iotlb_range_add)
+                       ops->iotlb_range_add(domain, iova, pgsize);
+
                pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
                         iova, unmapped_page);
 
@@ -1603,11 +1610,27 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
                unmapped += unmapped_page;
        }
 
+       if (sync && ops->iotlb_sync)
+               ops->iotlb_sync(domain);
+
        trace_unmap(orig_iova, size, unmapped);
        return unmapped;
 }
+
+size_t iommu_unmap(struct iommu_domain *domain,
+                  unsigned long iova, size_t size)
+{
+       return __iommu_unmap(domain, iova, size, true);
+}
 EXPORT_SYMBOL_GPL(iommu_unmap);
 
+size_t iommu_unmap_fast(struct iommu_domain *domain,
+                       unsigned long iova, size_t size)
+{
+       return __iommu_unmap(domain, iova, size, false);
+}
+EXPORT_SYMBOL_GPL(iommu_unmap_fast);
+
 size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
                         struct scatterlist *sg, unsigned int nents, int prot)
 {
index 246f14c83944c8c2bcff3bb25eafd8d13a262266..33edfa794ae9f5514c5113fa27597a12373f2a5c 100644 (file)
@@ -32,6 +32,8 @@ static unsigned long iova_rcache_get(struct iova_domain *iovad,
                                     unsigned long limit_pfn);
 static void init_iova_rcaches(struct iova_domain *iovad);
 static void free_iova_rcaches(struct iova_domain *iovad);
+static void fq_destroy_all_entries(struct iova_domain *iovad);
+static void fq_flush_timeout(unsigned long data);
 
 void
 init_iova_domain(struct iova_domain *iovad, unsigned long granule,
@@ -50,10 +52,61 @@ init_iova_domain(struct iova_domain *iovad, unsigned long granule,
        iovad->granule = granule;
        iovad->start_pfn = start_pfn;
        iovad->dma_32bit_pfn = pfn_32bit + 1;
+       iovad->flush_cb = NULL;
+       iovad->fq = NULL;
        init_iova_rcaches(iovad);
 }
 EXPORT_SYMBOL_GPL(init_iova_domain);
 
+static void free_iova_flush_queue(struct iova_domain *iovad)
+{
+       if (!iovad->fq)
+               return;
+
+       if (timer_pending(&iovad->fq_timer))
+               del_timer(&iovad->fq_timer);
+
+       fq_destroy_all_entries(iovad);
+
+       free_percpu(iovad->fq);
+
+       iovad->fq         = NULL;
+       iovad->flush_cb   = NULL;
+       iovad->entry_dtor = NULL;
+}
+
+int init_iova_flush_queue(struct iova_domain *iovad,
+                         iova_flush_cb flush_cb, iova_entry_dtor entry_dtor)
+{
+       int cpu;
+
+       atomic64_set(&iovad->fq_flush_start_cnt,  0);
+       atomic64_set(&iovad->fq_flush_finish_cnt, 0);
+
+       iovad->fq = alloc_percpu(struct iova_fq);
+       if (!iovad->fq)
+               return -ENOMEM;
+
+       iovad->flush_cb   = flush_cb;
+       iovad->entry_dtor = entry_dtor;
+
+       for_each_possible_cpu(cpu) {
+               struct iova_fq *fq;
+
+               fq = per_cpu_ptr(iovad->fq, cpu);
+               fq->head = 0;
+               fq->tail = 0;
+
+               spin_lock_init(&fq->lock);
+       }
+
+       setup_timer(&iovad->fq_timer, fq_flush_timeout, (unsigned long)iovad);
+       atomic_set(&iovad->fq_timer_on, 0);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(init_iova_flush_queue);
+
 static struct rb_node *
 __get_cached_rbnode(struct iova_domain *iovad, unsigned long *limit_pfn)
 {
@@ -423,6 +476,135 @@ free_iova_fast(struct iova_domain *iovad, unsigned long pfn, unsigned long size)
 }
 EXPORT_SYMBOL_GPL(free_iova_fast);
 
+#define fq_ring_for_each(i, fq) \
+       for ((i) = (fq)->head; (i) != (fq)->tail; (i) = ((i) + 1) % IOVA_FQ_SIZE)
+
+static inline bool fq_full(struct iova_fq *fq)
+{
+       assert_spin_locked(&fq->lock);
+       return (((fq->tail + 1) % IOVA_FQ_SIZE) == fq->head);
+}
+
+static inline unsigned fq_ring_add(struct iova_fq *fq)
+{
+       unsigned idx = fq->tail;
+
+       assert_spin_locked(&fq->lock);
+
+       fq->tail = (idx + 1) % IOVA_FQ_SIZE;
+
+       return idx;
+}
+
+static void fq_ring_free(struct iova_domain *iovad, struct iova_fq *fq)
+{
+       u64 counter = atomic64_read(&iovad->fq_flush_finish_cnt);
+       unsigned idx;
+
+       assert_spin_locked(&fq->lock);
+
+       fq_ring_for_each(idx, fq) {
+
+               if (fq->entries[idx].counter >= counter)
+                       break;
+
+               if (iovad->entry_dtor)
+                       iovad->entry_dtor(fq->entries[idx].data);
+
+               free_iova_fast(iovad,
+                              fq->entries[idx].iova_pfn,
+                              fq->entries[idx].pages);
+
+               fq->head = (fq->head + 1) % IOVA_FQ_SIZE;
+       }
+}
+
+static void iova_domain_flush(struct iova_domain *iovad)
+{
+       atomic64_inc(&iovad->fq_flush_start_cnt);
+       iovad->flush_cb(iovad);
+       atomic64_inc(&iovad->fq_flush_finish_cnt);
+}
+
+static void fq_destroy_all_entries(struct iova_domain *iovad)
+{
+       int cpu;
+
+       /*
+        * This code runs when the iova_domain is being detroyed, so don't
+        * bother to free iovas, just call the entry_dtor on all remaining
+        * entries.
+        */
+       if (!iovad->entry_dtor)
+               return;
+
+       for_each_possible_cpu(cpu) {
+               struct iova_fq *fq = per_cpu_ptr(iovad->fq, cpu);
+               int idx;
+
+               fq_ring_for_each(idx, fq)
+                       iovad->entry_dtor(fq->entries[idx].data);
+       }
+}
+
+static void fq_flush_timeout(unsigned long data)
+{
+       struct iova_domain *iovad = (struct iova_domain *)data;
+       int cpu;
+
+       atomic_set(&iovad->fq_timer_on, 0);
+       iova_domain_flush(iovad);
+
+       for_each_possible_cpu(cpu) {
+               unsigned long flags;
+               struct iova_fq *fq;
+
+               fq = per_cpu_ptr(iovad->fq, cpu);
+               spin_lock_irqsave(&fq->lock, flags);
+               fq_ring_free(iovad, fq);
+               spin_unlock_irqrestore(&fq->lock, flags);
+       }
+}
+
+void queue_iova(struct iova_domain *iovad,
+               unsigned long pfn, unsigned long pages,
+               unsigned long data)
+{
+       struct iova_fq *fq = get_cpu_ptr(iovad->fq);
+       unsigned long flags;
+       unsigned idx;
+
+       spin_lock_irqsave(&fq->lock, flags);
+
+       /*
+        * First remove all entries from the flush queue that have already been
+        * flushed out on another CPU. This makes the fq_full() check below less
+        * likely to be true.
+        */
+       fq_ring_free(iovad, fq);
+
+       if (fq_full(fq)) {
+               iova_domain_flush(iovad);
+               fq_ring_free(iovad, fq);
+       }
+
+       idx = fq_ring_add(fq);
+
+       fq->entries[idx].iova_pfn = pfn;
+       fq->entries[idx].pages    = pages;
+       fq->entries[idx].data     = data;
+       fq->entries[idx].counter  = atomic64_read(&iovad->fq_flush_start_cnt);
+
+       spin_unlock_irqrestore(&fq->lock, flags);
+
+       if (atomic_cmpxchg(&iovad->fq_timer_on, 0, 1) == 0)
+               mod_timer(&iovad->fq_timer,
+                         jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT));
+
+       put_cpu_ptr(iovad->fq);
+}
+EXPORT_SYMBOL_GPL(queue_iova);
+
 /**
  * put_iova_domain - destroys the iova doamin
  * @iovad: - iova domain in question.
@@ -433,6 +615,7 @@ void put_iova_domain(struct iova_domain *iovad)
        struct rb_node *node;
        unsigned long flags;
 
+       free_iova_flush_queue(iovad);
        free_iova_rcaches(iovad);
        spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
        node = rb_first(&iovad->rbroot);
index 2a38aa15be17d1810382f5d1dd6c0ee982fd084b..195d6e93ac7185aa53ee075521faf0de56ec53bf 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/iommu.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
@@ -35,7 +36,7 @@
 struct ipmmu_vmsa_device {
        struct device *dev;
        void __iomem *base;
-       struct list_head list;
+       struct iommu_device iommu;
 
        unsigned int num_utlbs;
        spinlock_t lock;                        /* Protects ctx and domains[] */
@@ -58,36 +59,18 @@ struct ipmmu_vmsa_domain {
 
 struct ipmmu_vmsa_iommu_priv {
        struct ipmmu_vmsa_device *mmu;
-       unsigned int *utlbs;
-       unsigned int num_utlbs;
        struct device *dev;
        struct list_head list;
 };
 
-static DEFINE_SPINLOCK(ipmmu_devices_lock);
-static LIST_HEAD(ipmmu_devices);
-
 static struct ipmmu_vmsa_domain *to_vmsa_domain(struct iommu_domain *dom)
 {
        return container_of(dom, struct ipmmu_vmsa_domain, io_domain);
 }
 
-
 static struct ipmmu_vmsa_iommu_priv *to_priv(struct device *dev)
 {
-#if defined(CONFIG_ARM)
-       return dev->archdata.iommu;
-#else
-       return dev->iommu_fwspec->iommu_priv;
-#endif
-}
-static void set_priv(struct device *dev, struct ipmmu_vmsa_iommu_priv *p)
-{
-#if defined(CONFIG_ARM)
-       dev->archdata.iommu = p;
-#else
-       dev->iommu_fwspec->iommu_priv = p;
-#endif
+       return dev->iommu_fwspec ? dev->iommu_fwspec->iommu_priv : NULL;
 }
 
 #define TLB_LOOP_TIMEOUT               100     /* 100us */
@@ -312,7 +295,7 @@ static void ipmmu_tlb_add_flush(unsigned long iova, size_t size,
        /* The hardware doesn't support selective TLB flush. */
 }
 
-static struct iommu_gather_ops ipmmu_gather_ops = {
+static const struct iommu_gather_ops ipmmu_gather_ops = {
        .tlb_flush_all = ipmmu_tlb_flush_all,
        .tlb_add_flush = ipmmu_tlb_add_flush,
        .tlb_sync = ipmmu_tlb_flush_all,
@@ -341,6 +324,19 @@ static int ipmmu_domain_allocate_context(struct ipmmu_vmsa_device *mmu,
        return ret;
 }
 
+static void ipmmu_domain_free_context(struct ipmmu_vmsa_device *mmu,
+                                     unsigned int context_id)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&mmu->lock, flags);
+
+       clear_bit(context_id, mmu->ctx);
+       mmu->domains[context_id] = NULL;
+
+       spin_unlock_irqrestore(&mmu->lock, flags);
+}
+
 static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
 {
        u64 ttbr;
@@ -370,22 +366,22 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
         */
        domain->cfg.iommu_dev = domain->mmu->dev;
 
-       domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
-                                          domain);
-       if (!domain->iop)
-               return -EINVAL;
-
        /*
         * Find an unused context.
         */
        ret = ipmmu_domain_allocate_context(domain->mmu, domain);
-       if (ret == IPMMU_CTX_MAX) {
-               free_io_pgtable_ops(domain->iop);
+       if (ret == IPMMU_CTX_MAX)
                return -EBUSY;
-       }
 
        domain->context_id = ret;
 
+       domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
+                                          domain);
+       if (!domain->iop) {
+               ipmmu_domain_free_context(domain->mmu, domain->context_id);
+               return -EINVAL;
+       }
+
        /* TTBR0 */
        ttbr = domain->cfg.arm_lpae_s1_cfg.ttbr[0];
        ipmmu_ctx_write(domain, IMTTLBR0, ttbr);
@@ -426,19 +422,6 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
        return 0;
 }
 
-static void ipmmu_domain_free_context(struct ipmmu_vmsa_device *mmu,
-                                     unsigned int context_id)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&mmu->lock, flags);
-
-       clear_bit(context_id, mmu->ctx);
-       mmu->domains[context_id] = NULL;
-
-       spin_unlock_irqrestore(&mmu->lock, flags);
-}
-
 static void ipmmu_domain_destroy_context(struct ipmmu_vmsa_domain *domain)
 {
        /*
@@ -562,13 +545,14 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,
                               struct device *dev)
 {
        struct ipmmu_vmsa_iommu_priv *priv = to_priv(dev);
+       struct iommu_fwspec *fwspec = dev->iommu_fwspec;
        struct ipmmu_vmsa_device *mmu = priv->mmu;
        struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
        unsigned long flags;
        unsigned int i;
        int ret = 0;
 
-       if (!mmu) {
+       if (!priv || !priv->mmu) {
                dev_err(dev, "Cannot attach to IPMMU\n");
                return -ENXIO;
        }
@@ -595,8 +579,8 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,
        if (ret < 0)
                return ret;
 
-       for (i = 0; i < priv->num_utlbs; ++i)
-               ipmmu_utlb_enable(domain, priv->utlbs[i]);
+       for (i = 0; i < fwspec->num_ids; ++i)
+               ipmmu_utlb_enable(domain, fwspec->ids[i]);
 
        return 0;
 }
@@ -604,12 +588,12 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,
 static void ipmmu_detach_device(struct iommu_domain *io_domain,
                                struct device *dev)
 {
-       struct ipmmu_vmsa_iommu_priv *priv = to_priv(dev);
+       struct iommu_fwspec *fwspec = dev->iommu_fwspec;
        struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
        unsigned int i;
 
-       for (i = 0; i < priv->num_utlbs; ++i)
-               ipmmu_utlb_disable(domain, priv->utlbs[i]);
+       for (i = 0; i < fwspec->num_ids; ++i)
+               ipmmu_utlb_disable(domain, fwspec->ids[i]);
 
        /*
         * TODO: Optimize by disabling the context when no device is attached.
@@ -645,92 +629,36 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
        return domain->iop->iova_to_phys(domain->iop, iova);
 }
 
-static int ipmmu_find_utlbs(struct ipmmu_vmsa_device *mmu, struct device *dev,
-                           unsigned int *utlbs, unsigned int num_utlbs)
-{
-       unsigned int i;
-
-       for (i = 0; i < num_utlbs; ++i) {
-               struct of_phandle_args args;
-               int ret;
-
-               ret = of_parse_phandle_with_args(dev->of_node, "iommus",
-                                                "#iommu-cells", i, &args);
-               if (ret < 0)
-                       return ret;
-
-               of_node_put(args.np);
-
-               if (args.np != mmu->dev->of_node || args.args_count != 1)
-                       return -EINVAL;
-
-               utlbs[i] = args.args[0];
-       }
-
-       return 0;
-}
-
-static int ipmmu_init_platform_device(struct device *dev)
+static int ipmmu_init_platform_device(struct device *dev,
+                                     struct of_phandle_args *args)
 {
+       struct platform_device *ipmmu_pdev;
        struct ipmmu_vmsa_iommu_priv *priv;
-       struct ipmmu_vmsa_device *mmu;
-       unsigned int *utlbs;
-       unsigned int i;
-       int num_utlbs;
-       int ret = -ENODEV;
-
-       /* Find the master corresponding to the device. */
 
-       num_utlbs = of_count_phandle_with_args(dev->of_node, "iommus",
-                                              "#iommu-cells");
-       if (num_utlbs < 0)
+       ipmmu_pdev = of_find_device_by_node(args->np);
+       if (!ipmmu_pdev)
                return -ENODEV;
 
-       utlbs = kcalloc(num_utlbs, sizeof(*utlbs), GFP_KERNEL);
-       if (!utlbs)
-               return -ENOMEM;
-
-       spin_lock(&ipmmu_devices_lock);
-
-       list_for_each_entry(mmu, &ipmmu_devices, list) {
-               ret = ipmmu_find_utlbs(mmu, dev, utlbs, num_utlbs);
-               if (!ret) {
-                       /*
-                        * TODO Take a reference to the MMU to protect
-                        * against device removal.
-                        */
-                       break;
-               }
-       }
-
-       spin_unlock(&ipmmu_devices_lock);
-
-       if (ret < 0)
-               goto error;
-
-       for (i = 0; i < num_utlbs; ++i) {
-               if (utlbs[i] >= mmu->num_utlbs) {
-                       ret = -EINVAL;
-                       goto error;
-               }
-       }
-
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
-               ret = -ENOMEM;
-               goto error;
-       }
+       if (!priv)
+               return -ENOMEM;
 
-       priv->mmu = mmu;
-       priv->utlbs = utlbs;
-       priv->num_utlbs = num_utlbs;
+       priv->mmu = platform_get_drvdata(ipmmu_pdev);
        priv->dev = dev;
-       set_priv(dev, priv);
+       dev->iommu_fwspec->iommu_priv = priv;
        return 0;
+}
 
-error:
-       kfree(utlbs);
-       return ret;
+static int ipmmu_of_xlate(struct device *dev,
+                         struct of_phandle_args *spec)
+{
+       iommu_fwspec_add_ids(dev, spec->args, 1);
+
+       /* Initialize once - xlate() will call multiple times */
+       if (to_priv(dev))
+               return 0;
+
+       return ipmmu_init_platform_device(dev, spec);
 }
 
 #if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
@@ -749,11 +677,11 @@ static int ipmmu_add_device(struct device *dev)
        struct iommu_group *group;
        int ret;
 
-       if (to_priv(dev)) {
-               dev_warn(dev, "IOMMU driver already assigned to device %s\n",
-                        dev_name(dev));
-               return -EINVAL;
-       }
+       /*
+        * Only let through devices that have been verified in xlate()
+        */
+       if (!to_priv(dev))
+               return -ENODEV;
 
        /* Create a device group and add the device to it. */
        group = iommu_group_alloc();
@@ -772,10 +700,6 @@ static int ipmmu_add_device(struct device *dev)
                goto error;
        }
 
-       ret = ipmmu_init_platform_device(dev);
-       if (ret < 0)
-               goto error;
-
        /*
         * Create the ARM mapping, used by the ARM DMA mapping core to allocate
         * VAs. This will allocate a corresponding IOMMU domain.
@@ -816,24 +740,13 @@ error:
        if (!IS_ERR_OR_NULL(group))
                iommu_group_remove_device(dev);
 
-       kfree(to_priv(dev)->utlbs);
-       kfree(to_priv(dev));
-       set_priv(dev, NULL);
-
        return ret;
 }
 
 static void ipmmu_remove_device(struct device *dev)
 {
-       struct ipmmu_vmsa_iommu_priv *priv = to_priv(dev);
-
        arm_iommu_detach_device(dev);
        iommu_group_remove_device(dev);
-
-       kfree(priv->utlbs);
-       kfree(priv);
-
-       set_priv(dev, NULL);
 }
 
 static const struct iommu_ops ipmmu_ops = {
@@ -848,6 +761,7 @@ static const struct iommu_ops ipmmu_ops = {
        .add_device = ipmmu_add_device,
        .remove_device = ipmmu_remove_device,
        .pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
+       .of_xlate = ipmmu_of_xlate,
 };
 
 #endif /* !CONFIG_ARM && CONFIG_IOMMU_DMA */
@@ -890,14 +804,12 @@ static void ipmmu_domain_free_dma(struct iommu_domain *io_domain)
 
 static int ipmmu_add_device_dma(struct device *dev)
 {
-       struct iommu_fwspec *fwspec = dev->iommu_fwspec;
        struct iommu_group *group;
 
        /*
         * Only let through devices that have been verified in xlate()
-        * We may get called with dev->iommu_fwspec set to NULL.
         */
-       if (!fwspec || !fwspec->iommu_priv)
+       if (!to_priv(dev))
                return -ENODEV;
 
        group = iommu_group_get_for_dev(dev);
@@ -957,19 +869,6 @@ static struct iommu_group *ipmmu_find_group_dma(struct device *dev)
        return group;
 }
 
-static int ipmmu_of_xlate_dma(struct device *dev,
-                             struct of_phandle_args *spec)
-{
-       /* If the IPMMU device is disabled in DT then return error
-        * to make sure the of_iommu code does not install ops
-        * even though the iommu device is disabled
-        */
-       if (!of_device_is_available(spec->np))
-               return -ENODEV;
-
-       return ipmmu_init_platform_device(dev);
-}
-
 static const struct iommu_ops ipmmu_ops = {
        .domain_alloc = ipmmu_domain_alloc_dma,
        .domain_free = ipmmu_domain_free_dma,
@@ -983,7 +882,7 @@ static const struct iommu_ops ipmmu_ops = {
        .remove_device = ipmmu_remove_device_dma,
        .device_group = ipmmu_find_group_dma,
        .pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
-       .of_xlate = ipmmu_of_xlate_dma,
+       .of_xlate = ipmmu_of_xlate,
 };
 
 #endif /* CONFIG_IOMMU_DMA */
@@ -1054,16 +953,24 @@ static int ipmmu_probe(struct platform_device *pdev)
 
        ipmmu_device_reset(mmu);
 
+       ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL,
+                                    dev_name(&pdev->dev));
+       if (ret)
+               return ret;
+
+       iommu_device_set_ops(&mmu->iommu, &ipmmu_ops);
+       iommu_device_set_fwnode(&mmu->iommu, &pdev->dev.of_node->fwnode);
+
+       ret = iommu_device_register(&mmu->iommu);
+       if (ret)
+               return ret;
+
        /*
         * We can't create the ARM mapping here as it requires the bus to have
         * an IOMMU, which only happens when bus_set_iommu() is called in
         * ipmmu_init() after the probe function returns.
         */
 
-       spin_lock(&ipmmu_devices_lock);
-       list_add(&mmu->list, &ipmmu_devices);
-       spin_unlock(&ipmmu_devices_lock);
-
        platform_set_drvdata(pdev, mmu);
 
        return 0;
@@ -1073,9 +980,8 @@ static int ipmmu_remove(struct platform_device *pdev)
 {
        struct ipmmu_vmsa_device *mmu = platform_get_drvdata(pdev);
 
-       spin_lock(&ipmmu_devices_lock);
-       list_del(&mmu->list);
-       spin_unlock(&ipmmu_devices_lock);
+       iommu_device_sysfs_remove(&mmu->iommu);
+       iommu_device_unregister(&mmu->iommu);
 
 #if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
        arm_iommu_release_mapping(mmu->mapping);
index d0448353d5011dae8376f43569e169c8051001db..04f4d51ffacb1e50ae3f87f04fd3b23306f7b55b 100644 (file)
@@ -393,6 +393,7 @@ static struct msm_iommu_dev *find_iommu_for_dev(struct device *dev)
 static int msm_iommu_add_device(struct device *dev)
 {
        struct msm_iommu_dev *iommu;
+       struct iommu_group *group;
        unsigned long flags;
        int ret = 0;
 
@@ -406,7 +407,16 @@ static int msm_iommu_add_device(struct device *dev)
 
        spin_unlock_irqrestore(&msm_iommu_lock, flags);
 
-       return ret;
+       if (ret)
+               return ret;
+
+       group = iommu_group_get_for_dev(dev);
+       if (IS_ERR(group))
+               return PTR_ERR(group);
+
+       iommu_group_put(group);
+
+       return 0;
 }
 
 static void msm_iommu_remove_device(struct device *dev)
@@ -421,6 +431,8 @@ static void msm_iommu_remove_device(struct device *dev)
                iommu_device_unlink(&iommu->iommu, dev);
 
        spin_unlock_irqrestore(&msm_iommu_lock, flags);
+
+       iommu_group_remove_device(dev);
 }
 
 static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
@@ -700,6 +712,7 @@ static struct iommu_ops msm_iommu_ops = {
        .iova_to_phys = msm_iommu_iova_to_phys,
        .add_device = msm_iommu_add_device,
        .remove_device = msm_iommu_remove_device,
+       .device_group = generic_device_group,
        .pgsize_bitmap = MSM_IOMMU_PGSIZES,
        .of_xlate = qcom_iommu_of_xlate,
 };
index 91c6d367ab3593b99a6c9cfb9be01855e8372af2..bd515be5b380e32ac224b55d5b9a2dfff26a15ef 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <asm/barrier.h>
-#include <dt-bindings/memory/mt8173-larb-port.h>
 #include <soc/mediatek/smi.h>
 
 #include "mtk_iommu.h"
 
 #define REG_MMU_CTRL_REG                       0x110
 #define F_MMU_PREFETCH_RT_REPLACE_MOD          BIT(4)
-#define F_MMU_TF_PROTECT_SEL(prot)             (((prot) & 0x3) << 5)
+#define F_MMU_TF_PROTECT_SEL_SHIFT(data) \
+       ((data)->m4u_plat == M4U_MT2712 ? 4 : 5)
+/* It's named by F_MMU_TF_PROT_SEL in mt2712. */
+#define F_MMU_TF_PROTECT_SEL(prot, data) \
+       (((prot) & 0x3) << F_MMU_TF_PROTECT_SEL_SHIFT(data))
 
 #define REG_MMU_IVRP_PADDR                     0x114
 #define F_MMU_IVRP_PA_SET(pa, ext)             (((pa) >> 1) | ((!!(ext)) << 31))
+#define REG_MMU_VLD_PA_RNG                     0x118
+#define F_MMU_VLD_PA_RNG(EA, SA)               (((EA) << 8) | (SA))
 
 #define REG_MMU_INT_CONTROL0                   0x120
 #define F_L2_MULIT_HIT_EN                      BIT(0)
@@ -82,7 +87,6 @@
 #define REG_MMU_FAULT_ST1                      0x134
 
 #define REG_MMU_FAULT_VA                       0x13c
-#define F_MMU_FAULT_VA_MSK                     0xfffff000
 #define F_MMU_FAULT_VA_WRITE_BIT               BIT(1)
 #define F_MMU_FAULT_VA_LAYER_BIT               BIT(0)
 
 
 #define MTK_PROTECT_PA_ALIGN                   128
 
+/*
+ * Get the local arbiter ID and the portid within the larb arbiter
+ * from mtk_m4u_id which is defined by MTK_M4U_ID.
+ */
+#define MTK_M4U_TO_LARB(id)            (((id) >> 5) & 0xf)
+#define MTK_M4U_TO_PORT(id)            ((id) & 0x1f)
+
 struct mtk_iommu_domain {
        spinlock_t                      pgtlock; /* lock for page table */
 
@@ -104,6 +115,27 @@ struct mtk_iommu_domain {
 
 static struct iommu_ops mtk_iommu_ops;
 
+static LIST_HEAD(m4ulist);     /* List all the M4U HWs */
+
+#define for_each_m4u(data)     list_for_each_entry(data, &m4ulist, list)
+
+/*
+ * There may be 1 or 2 M4U HWs, But we always expect they are in the same domain
+ * for the performance.
+ *
+ * Here always return the mtk_iommu_data of the first probed M4U where the
+ * iommu domain information is recorded.
+ */
+static struct mtk_iommu_data *mtk_iommu_get_m4u_data(void)
+{
+       struct mtk_iommu_data *data;
+
+       for_each_m4u(data)
+               return data;
+
+       return NULL;
+}
+
 static struct mtk_iommu_domain *to_mtk_domain(struct iommu_domain *dom)
 {
        return container_of(dom, struct mtk_iommu_domain, domain);
@@ -113,9 +145,12 @@ static void mtk_iommu_tlb_flush_all(void *cookie)
 {
        struct mtk_iommu_data *data = cookie;
 
-       writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0, data->base + REG_MMU_INV_SEL);
-       writel_relaxed(F_ALL_INVLD, data->base + REG_MMU_INVALIDATE);
-       wmb(); /* Make sure the tlb flush all done */
+       for_each_m4u(data) {
+               writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0,
+                              data->base + REG_MMU_INV_SEL);
+               writel_relaxed(F_ALL_INVLD, data->base + REG_MMU_INVALIDATE);
+               wmb(); /* Make sure the tlb flush all done */
+       }
 }
 
 static void mtk_iommu_tlb_add_flush_nosync(unsigned long iova, size_t size,
@@ -124,12 +159,17 @@ static void mtk_iommu_tlb_add_flush_nosync(unsigned long iova, size_t size,
 {
        struct mtk_iommu_data *data = cookie;
 
-       writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0, data->base + REG_MMU_INV_SEL);
+       for_each_m4u(data) {
+               writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0,
+                              data->base + REG_MMU_INV_SEL);
 
-       writel_relaxed(iova, data->base + REG_MMU_INVLD_START_A);
-       writel_relaxed(iova + size - 1, data->base + REG_MMU_INVLD_END_A);
-       writel_relaxed(F_MMU_INV_RANGE, data->base + REG_MMU_INVALIDATE);
-       data->tlb_flush_active = true;
+               writel_relaxed(iova, data->base + REG_MMU_INVLD_START_A);
+               writel_relaxed(iova + size - 1,
+                              data->base + REG_MMU_INVLD_END_A);
+               writel_relaxed(F_MMU_INV_RANGE,
+                              data->base + REG_MMU_INVALIDATE);
+               data->tlb_flush_active = true;
+       }
 }
 
 static void mtk_iommu_tlb_sync(void *cookie)
@@ -138,20 +178,22 @@ static void mtk_iommu_tlb_sync(void *cookie)
        int ret;
        u32 tmp;
 
-       /* Avoid timing out if there's nothing to wait for */
-       if (!data->tlb_flush_active)
-               return;
+       for_each_m4u(data) {
+               /* Avoid timing out if there's nothing to wait for */
+               if (!data->tlb_flush_active)
+                       return;
 
-       ret = readl_poll_timeout_atomic(data->base + REG_MMU_CPE_DONE, tmp,
-                                       tmp != 0, 10, 100000);
-       if (ret) {
-               dev_warn(data->dev,
-                        "Partial TLB flush timed out, falling back to full flush\n");
-               mtk_iommu_tlb_flush_all(cookie);
+               ret = readl_poll_timeout_atomic(data->base + REG_MMU_CPE_DONE,
+                                               tmp, tmp != 0, 10, 100000);
+               if (ret) {
+                       dev_warn(data->dev,
+                                "Partial TLB flush timed out, falling back to full flush\n");
+                       mtk_iommu_tlb_flush_all(cookie);
+               }
+               /* Clear the CPE status */
+               writel_relaxed(0, data->base + REG_MMU_CPE_DONE);
+               data->tlb_flush_active = false;
        }
-       /* Clear the CPE status */
-       writel_relaxed(0, data->base + REG_MMU_CPE_DONE);
-       data->tlb_flush_active = false;
 }
 
 static const struct iommu_gather_ops mtk_iommu_gather_ops = {
@@ -173,7 +215,6 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
        fault_iova = readl_relaxed(data->base + REG_MMU_FAULT_VA);
        layer = fault_iova & F_MMU_FAULT_VA_LAYER_BIT;
        write = fault_iova & F_MMU_FAULT_VA_WRITE_BIT;
-       fault_iova &= F_MMU_FAULT_VA_MSK;
        fault_pa = readl_relaxed(data->base + REG_MMU_INVLD_PA);
        regval = readl_relaxed(data->base + REG_MMU_INT_ID);
        fault_larb = F_MMU0_INT_ID_LARB_ID(regval);
@@ -221,9 +262,9 @@ static void mtk_iommu_config(struct mtk_iommu_data *data,
        }
 }
 
-static int mtk_iommu_domain_finalise(struct mtk_iommu_data *data)
+static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom)
 {
-       struct mtk_iommu_domain *dom = data->m4u_dom;
+       struct mtk_iommu_data *data = mtk_iommu_get_m4u_data();
 
        spin_lock_init(&dom->pgtlock);
 
@@ -249,9 +290,6 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_data *data)
 
        /* Update our support page sizes bitmap */
        dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap;
-
-       writel(data->m4u_dom->cfg.arm_v7s_cfg.ttbr[0],
-              data->base + REG_MMU_PT_BASE_ADDR);
        return 0;
 }
 
@@ -266,20 +304,30 @@ static struct iommu_domain *mtk_iommu_domain_alloc(unsigned type)
        if (!dom)
                return NULL;
 
-       if (iommu_get_dma_cookie(&dom->domain)) {
-               kfree(dom);
-               return NULL;
-       }
+       if (iommu_get_dma_cookie(&dom->domain))
+               goto  free_dom;
+
+       if (mtk_iommu_domain_finalise(dom))
+               goto  put_dma_cookie;
 
        dom->domain.geometry.aperture_start = 0;
        dom->domain.geometry.aperture_end = DMA_BIT_MASK(32);
        dom->domain.geometry.force_aperture = true;
 
        return &dom->domain;
+
+put_dma_cookie:
+       iommu_put_dma_cookie(&dom->domain);
+free_dom:
+       kfree(dom);
+       return NULL;
 }
 
 static void mtk_iommu_domain_free(struct iommu_domain *domain)
 {
+       struct mtk_iommu_domain *dom = to_mtk_domain(domain);
+
+       free_io_pgtable_ops(dom->iop);
        iommu_put_dma_cookie(domain);
        kfree(to_mtk_domain(domain));
 }
@@ -289,22 +337,15 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
 {
        struct mtk_iommu_domain *dom = to_mtk_domain(domain);
        struct mtk_iommu_data *data = dev->iommu_fwspec->iommu_priv;
-       int ret;
 
        if (!data)
                return -ENODEV;
 
+       /* Update the pgtable base address register of the M4U HW */
        if (!data->m4u_dom) {
                data->m4u_dom = dom;
-               ret = mtk_iommu_domain_finalise(data);
-               if (ret) {
-                       data->m4u_dom = NULL;
-                       return ret;
-               }
-       } else if (data->m4u_dom != dom) {
-               /* All the client devices should be in the same m4u domain */
-               dev_err(dev, "try to attach into the error iommu domain\n");
-               return -EPERM;
+               writel(dom->cfg.arm_v7s_cfg.ttbr[0],
+                      data->base + REG_MMU_PT_BASE_ADDR);
        }
 
        mtk_iommu_config(data, dev, true);
@@ -354,6 +395,7 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
                                          dma_addr_t iova)
 {
        struct mtk_iommu_domain *dom = to_mtk_domain(domain);
+       struct mtk_iommu_data *data = mtk_iommu_get_m4u_data();
        unsigned long flags;
        phys_addr_t pa;
 
@@ -361,6 +403,9 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
        pa = dom->iop->iova_to_phys(dom->iop, iova);
        spin_unlock_irqrestore(&dom->pgtlock, flags);
 
+       if (data->enable_4GB)
+               pa |= BIT_ULL(32);
+
        return pa;
 }
 
@@ -399,7 +444,7 @@ static void mtk_iommu_remove_device(struct device *dev)
 
 static struct iommu_group *mtk_iommu_device_group(struct device *dev)
 {
-       struct mtk_iommu_data *data = dev->iommu_fwspec->iommu_priv;
+       struct mtk_iommu_data *data = mtk_iommu_get_m4u_data();
 
        if (!data)
                return ERR_PTR(-ENODEV);
@@ -464,8 +509,9 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
                return ret;
        }
 
-       regval = F_MMU_PREFETCH_RT_REPLACE_MOD |
-               F_MMU_TF_PROTECT_SEL(2);
+       regval = F_MMU_TF_PROTECT_SEL(2, data);
+       if (data->m4u_plat == M4U_MT8173)
+               regval |= F_MMU_PREFETCH_RT_REPLACE_MOD;
        writel_relaxed(regval, data->base + REG_MMU_CTRL_REG);
 
        regval = F_L2_MULIT_HIT_EN |
@@ -487,9 +533,19 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
 
        writel_relaxed(F_MMU_IVRP_PA_SET(data->protect_base, data->enable_4GB),
                       data->base + REG_MMU_IVRP_PADDR);
-
+       if (data->enable_4GB && data->m4u_plat != M4U_MT8173) {
+               /*
+                * If 4GB mode is enabled, the validate PA range is from
+                * 0x1_0000_0000 to 0x1_ffff_ffff. here record bit[32:30].
+                */
+               regval = F_MMU_VLD_PA_RNG(7, 4);
+               writel_relaxed(regval, data->base + REG_MMU_VLD_PA_RNG);
+       }
        writel_relaxed(0, data->base + REG_MMU_DCM_DIS);
-       writel_relaxed(0, data->base + REG_MMU_STANDARD_AXI_MODE);
+
+       /* It's MISC control register whose default value is ok except mt8173.*/
+       if (data->m4u_plat == M4U_MT8173)
+               writel_relaxed(0, data->base + REG_MMU_STANDARD_AXI_MODE);
 
        if (devm_request_irq(data->dev, data->irq, mtk_iommu_isr, 0,
                             dev_name(data->dev), (void *)data)) {
@@ -521,6 +577,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
        if (!data)
                return -ENOMEM;
        data->dev = dev;
+       data->m4u_plat = (enum mtk_iommu_plat)of_device_get_match_data(dev);
 
        /* Protect memory. HW will access here while translation fault.*/
        protect = devm_kzalloc(dev, MTK_PROTECT_PA_ALIGN * 2, GFP_KERNEL);
@@ -529,7 +586,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
        data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
 
        /* Whether the current dram is over 4GB */
-       data->enable_4GB = !!(max_pfn > (0xffffffffUL >> PAGE_SHIFT));
+       data->enable_4GB = !!(max_pfn > (BIT_ULL(32) >> PAGE_SHIFT));
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        data->base = devm_ioremap_resource(dev, res);
@@ -554,6 +611,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
        for (i = 0; i < larb_nr; i++) {
                struct device_node *larbnode;
                struct platform_device *plarbdev;
+               u32 id;
 
                larbnode = of_parse_phandle(dev->of_node, "mediatek,larbs", i);
                if (!larbnode)
@@ -562,17 +620,14 @@ static int mtk_iommu_probe(struct platform_device *pdev)
                if (!of_device_is_available(larbnode))
                        continue;
 
+               ret = of_property_read_u32(larbnode, "mediatek,larb-id", &id);
+               if (ret)/* The id is consecutive if there is no this property */
+                       id = i;
+
                plarbdev = of_find_device_by_node(larbnode);
-               if (!plarbdev) {
-                       plarbdev = of_platform_device_create(
-                                               larbnode, NULL,
-                                               platform_bus_type.dev_root);
-                       if (!plarbdev) {
-                               of_node_put(larbnode);
-                               return -EPROBE_DEFER;
-                       }
-               }
-               data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
+               if (!plarbdev)
+                       return -EPROBE_DEFER;
+               data->smi_imu.larb_imu[id].dev = &plarbdev->dev;
 
                component_match_add_release(dev, &match, release_of,
                                            compare_of, larbnode);
@@ -596,6 +651,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
+       list_add_tail(&data->list, &m4ulist);
+
        if (!iommu_present(&platform_bus_type))
                bus_set_iommu(&platform_bus_type, &mtk_iommu_ops);
 
@@ -612,7 +669,6 @@ static int mtk_iommu_remove(struct platform_device *pdev)
        if (iommu_present(&platform_bus_type))
                bus_set_iommu(&platform_bus_type, NULL);
 
-       free_io_pgtable_ops(data->m4u_dom->iop);
        clk_disable_unprepare(data->bclk);
        devm_free_irq(&pdev->dev, data->irq, data);
        component_master_del(&pdev->dev, &mtk_iommu_com_ops);
@@ -631,6 +687,7 @@ static int __maybe_unused mtk_iommu_suspend(struct device *dev)
        reg->ctrl_reg = readl_relaxed(base + REG_MMU_CTRL_REG);
        reg->int_control0 = readl_relaxed(base + REG_MMU_INT_CONTROL0);
        reg->int_main_control = readl_relaxed(base + REG_MMU_INT_MAIN_CONTROL);
+       clk_disable_unprepare(data->bclk);
        return 0;
 }
 
@@ -639,9 +696,13 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev)
        struct mtk_iommu_data *data = dev_get_drvdata(dev);
        struct mtk_iommu_suspend_reg *reg = &data->reg;
        void __iomem *base = data->base;
+       int ret;
 
-       writel_relaxed(data->m4u_dom->cfg.arm_v7s_cfg.ttbr[0],
-                      base + REG_MMU_PT_BASE_ADDR);
+       ret = clk_prepare_enable(data->bclk);
+       if (ret) {
+               dev_err(data->dev, "Failed to enable clk(%d) in resume\n", ret);
+               return ret;
+       }
        writel_relaxed(reg->standard_axi_mode,
                       base + REG_MMU_STANDARD_AXI_MODE);
        writel_relaxed(reg->dcm_dis, base + REG_MMU_DCM_DIS);
@@ -650,15 +711,19 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev)
        writel_relaxed(reg->int_main_control, base + REG_MMU_INT_MAIN_CONTROL);
        writel_relaxed(F_MMU_IVRP_PA_SET(data->protect_base, data->enable_4GB),
                       base + REG_MMU_IVRP_PADDR);
+       if (data->m4u_dom)
+               writel(data->m4u_dom->cfg.arm_v7s_cfg.ttbr[0],
+                      base + REG_MMU_PT_BASE_ADDR);
        return 0;
 }
 
-const struct dev_pm_ops mtk_iommu_pm_ops = {
-       SET_SYSTEM_SLEEP_PM_OPS(mtk_iommu_suspend, mtk_iommu_resume)
+static const struct dev_pm_ops mtk_iommu_pm_ops = {
+       SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_iommu_suspend, mtk_iommu_resume)
 };
 
 static const struct of_device_id mtk_iommu_of_ids[] = {
-       { .compatible = "mediatek,mt8173-m4u", },
+       { .compatible = "mediatek,mt2712-m4u", .data = (void *)M4U_MT2712},
+       { .compatible = "mediatek,mt8173-m4u", .data = (void *)M4U_MT8173},
        {}
 };
 
@@ -667,27 +732,20 @@ static struct platform_driver mtk_iommu_driver = {
        .remove = mtk_iommu_remove,
        .driver = {
                .name = "mtk-iommu",
-               .of_match_table = mtk_iommu_of_ids,
+               .of_match_table = of_match_ptr(mtk_iommu_of_ids),
                .pm = &mtk_iommu_pm_ops,
        }
 };
 
-static int mtk_iommu_init_fn(struct device_node *np)
+static int __init mtk_iommu_init(void)
 {
        int ret;
-       struct platform_device *pdev;
-
-       pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-       if (!pdev)
-               return -ENOMEM;
 
        ret = platform_driver_register(&mtk_iommu_driver);
-       if (ret) {
-               pr_err("%s: Failed to register driver\n", __func__);
-               return ret;
-       }
+       if (ret != 0)
+               pr_err("Failed to register MTK IOMMU driver\n");
 
-       return 0;
+       return ret;
 }
 
-IOMMU_OF_DECLARE(mtkm4u, "mediatek,mt8173-m4u", mtk_iommu_init_fn);
+subsys_initcall(mtk_iommu_init)
index c06cc91b5d9a1e63ec0984927b6c7722b5242f82..b4451a1c7c2f167060edac5dbe5ce53a99b21144 100644 (file)
@@ -34,6 +34,12 @@ struct mtk_iommu_suspend_reg {
        u32                             int_main_control;
 };
 
+enum mtk_iommu_plat {
+       M4U_MT2701,
+       M4U_MT2712,
+       M4U_MT8173,
+};
+
 struct mtk_iommu_domain;
 
 struct mtk_iommu_data {
@@ -50,6 +56,9 @@ struct mtk_iommu_data {
        bool                            tlb_flush_active;
 
        struct iommu_device             iommu;
+       enum mtk_iommu_plat             m4u_plat;
+
+       struct list_head                list;
 };
 
 static inline int compare_of(struct device *dev, void *data)
index 8cb60829a7a1d8754017e100a010ed85f8e568c9..e60e3dba85a0d7c0457d9bdf650de2c350a5d11b 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/of_pci.h>
 #include <linux/slab.h>
 
+#define NO_IOMMU       1
+
 static const struct of_device_id __iommu_of_table_sentinel
        __used __section(__iommu_of_table_end);
 
@@ -109,8 +111,8 @@ static bool of_iommu_driver_present(struct device_node *np)
        return of_match_node(&__iommu_of_table, np);
 }
 
-static const struct iommu_ops
-*of_iommu_xlate(struct device *dev, struct of_phandle_args *iommu_spec)
+static int of_iommu_xlate(struct device *dev,
+                         struct of_phandle_args *iommu_spec)
 {
        const struct iommu_ops *ops;
        struct fwnode_handle *fwnode = &iommu_spec->np->fwnode;
@@ -120,95 +122,53 @@ static const struct iommu_ops
        if ((ops && !ops->of_xlate) ||
            !of_device_is_available(iommu_spec->np) ||
            (!ops && !of_iommu_driver_present(iommu_spec->np)))
-               return NULL;
+               return NO_IOMMU;
 
        err = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops);
        if (err)
-               return ERR_PTR(err);
+               return err;
        /*
         * The otherwise-empty fwspec handily serves to indicate the specific
         * IOMMU device we're waiting for, which will be useful if we ever get
         * a proper probe-ordering dependency mechanism in future.
         */
        if (!ops)
-               return ERR_PTR(-EPROBE_DEFER);
-
-       err = ops->of_xlate(dev, iommu_spec);
-       if (err)
-               return ERR_PTR(err);
+               return -EPROBE_DEFER;
 
-       return ops;
+       return ops->of_xlate(dev, iommu_spec);
 }
 
-static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data)
-{
-       struct of_phandle_args *iommu_spec = data;
-
-       iommu_spec->args[0] = alias;
-       return iommu_spec->np == pdev->bus->dev.of_node;
-}
+struct of_pci_iommu_alias_info {
+       struct device *dev;
+       struct device_node *np;
+};
 
-static const struct iommu_ops
-*of_pci_iommu_init(struct pci_dev *pdev, struct device_node *bridge_np)
+static int of_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data)
 {
-       const struct iommu_ops *ops;
-       struct of_phandle_args iommu_spec;
+       struct of_pci_iommu_alias_info *info = data;
+       struct of_phandle_args iommu_spec = { .args_count = 1 };
        int err;
 
-       /*
-        * Start by tracing the RID alias down the PCI topology as
-        * far as the host bridge whose OF node we have...
-        * (we're not even attempting to handle multi-alias devices yet)
-        */
-       iommu_spec.args_count = 1;
-       iommu_spec.np = bridge_np;
-       pci_for_each_dma_alias(pdev, __get_pci_rid, &iommu_spec);
-       /*
-        * ...then find out what that becomes once it escapes the PCI
-        * bus into the system beyond, and which IOMMU it ends up at.
-        */
-       iommu_spec.np = NULL;
-       err = of_pci_map_rid(bridge_np, iommu_spec.args[0], "iommu-map",
+       err = of_pci_map_rid(info->np, alias, "iommu-map",
                             "iommu-map-mask", &iommu_spec.np,
                             iommu_spec.args);
        if (err)
-               return err == -ENODEV ? NULL : ERR_PTR(err);
-
-       ops = of_iommu_xlate(&pdev->dev, &iommu_spec);
+               return err == -ENODEV ? NO_IOMMU : err;
 
+       err = of_iommu_xlate(info->dev, &iommu_spec);
        of_node_put(iommu_spec.np);
-       return ops;
-}
-
-static const struct iommu_ops
-*of_platform_iommu_init(struct device *dev, struct device_node *np)
-{
-       struct of_phandle_args iommu_spec;
-       const struct iommu_ops *ops = NULL;
-       int idx = 0;
-
-       /*
-        * We don't currently walk up the tree looking for a parent IOMMU.
-        * See the `Notes:' section of
-        * Documentation/devicetree/bindings/iommu/iommu.txt
-        */
-       while (!of_parse_phandle_with_args(np, "iommus", "#iommu-cells",
-                                          idx, &iommu_spec)) {
-               ops = of_iommu_xlate(dev, &iommu_spec);
-               of_node_put(iommu_spec.np);
-               idx++;
-               if (IS_ERR_OR_NULL(ops))
-                       break;
-       }
+       if (err)
+               return err;
 
-       return ops;
+       return info->np == pdev->bus->dev.of_node;
 }
 
 const struct iommu_ops *of_iommu_configure(struct device *dev,
                                           struct device_node *master_np)
 {
-       const struct iommu_ops *ops;
+       const struct iommu_ops *ops = NULL;
        struct iommu_fwspec *fwspec = dev->iommu_fwspec;
+       int err = NO_IOMMU;
 
        if (!master_np)
                return NULL;
@@ -221,25 +181,54 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
                iommu_fwspec_free(dev);
        }
 
-       if (dev_is_pci(dev))
-               ops = of_pci_iommu_init(to_pci_dev(dev), master_np);
-       else
-               ops = of_platform_iommu_init(dev, master_np);
+       /*
+        * We don't currently walk up the tree looking for a parent IOMMU.
+        * See the `Notes:' section of
+        * Documentation/devicetree/bindings/iommu/iommu.txt
+        */
+       if (dev_is_pci(dev)) {
+               struct of_pci_iommu_alias_info info = {
+                       .dev = dev,
+                       .np = master_np,
+               };
+
+               err = pci_for_each_dma_alias(to_pci_dev(dev),
+                                            of_pci_iommu_init, &info);
+       } else {
+               struct of_phandle_args iommu_spec;
+               int idx = 0;
+
+               while (!of_parse_phandle_with_args(master_np, "iommus",
+                                                  "#iommu-cells",
+                                                  idx, &iommu_spec)) {
+                       err = of_iommu_xlate(dev, &iommu_spec);
+                       of_node_put(iommu_spec.np);
+                       idx++;
+                       if (err)
+                               break;
+               }
+       }
+
+       /*
+        * Two success conditions can be represented by non-negative err here:
+        * >0 : there is no IOMMU, or one was unavailable for non-fatal reasons
+        *  0 : we found an IOMMU, and dev->fwspec is initialised appropriately
+        * <0 : any actual error
+        */
+       if (!err)
+               ops = dev->iommu_fwspec->ops;
        /*
         * If we have reason to believe the IOMMU driver missed the initial
         * add_device callback for dev, replay it to get things in order.
         */
-       if (!IS_ERR_OR_NULL(ops) && ops->add_device &&
-           dev->bus && !dev->iommu_group) {
-               int err = ops->add_device(dev);
-
-               if (err)
-                       ops = ERR_PTR(err);
-       }
+       if (ops && ops->add_device && dev->bus && !dev->iommu_group)
+               err = ops->add_device(dev);
 
        /* Ignore all other errors apart from EPROBE_DEFER */
-       if (IS_ERR(ops) && (PTR_ERR(ops) != -EPROBE_DEFER)) {
-               dev_dbg(dev, "Adding to IOMMU failed: %ld\n", PTR_ERR(ops));
+       if (err == -EPROBE_DEFER) {
+               ops = ERR_PTR(err);
+       } else if (err < 0) {
+               dev_dbg(dev, "Adding to IOMMU failed: %d\n", err);
                ops = NULL;
        }
 
@@ -255,8 +244,7 @@ static int __init of_iommu_init(void)
                const of_iommu_init_fn init_fn = match->data;
 
                if (init_fn && init_fn(np))
-                       pr_err("Failed to initialise IOMMU %s\n",
-                               of_node_full_name(np));
+                       pr_err("Failed to initialise IOMMU %pOF\n", np);
        }
 
        return 0;
index 641e035cf86661b5da9239f8a60e28c252fa2f7e..bd67e1b2c64eadf25f5b10d120cf1214b120b54f 100644 (file)
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
@@ -29,8 +30,6 @@
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
 
-#include <asm/cacheflush.h>
-
 #include <linux/platform_data/iommu-omap.h>
 
 #include "omap-iopgtable.h"
@@ -454,36 +453,35 @@ static void flush_iotlb_all(struct omap_iommu *obj)
 /*
  *     H/W pagetable operations
  */
-static void flush_iopgd_range(u32 *first, u32 *last)
+static void flush_iopte_range(struct device *dev, dma_addr_t dma,
+                             unsigned long offset, int num_entries)
 {
-       /* FIXME: L2 cache should be taken care of if it exists */
-       do {
-               asm("mcr        p15, 0, %0, c7, c10, 1 @ flush_pgd"
-                   : : "r" (first));
-               first += L1_CACHE_BYTES / sizeof(*first);
-       } while (first <= last);
-}
+       size_t size = num_entries * sizeof(u32);
 
-static void flush_iopte_range(u32 *first, u32 *last)
-{
-       /* FIXME: L2 cache should be taken care of if it exists */
-       do {
-               asm("mcr        p15, 0, %0, c7, c10, 1 @ flush_pte"
-                   : : "r" (first));
-               first += L1_CACHE_BYTES / sizeof(*first);
-       } while (first <= last);
+       dma_sync_single_range_for_device(dev, dma, offset, size, DMA_TO_DEVICE);
 }
 
-static void iopte_free(u32 *iopte)
+static void iopte_free(struct omap_iommu *obj, u32 *iopte, bool dma_valid)
 {
+       dma_addr_t pt_dma;
+
        /* Note: freed iopte's must be clean ready for re-use */
-       if (iopte)
+       if (iopte) {
+               if (dma_valid) {
+                       pt_dma = virt_to_phys(iopte);
+                       dma_unmap_single(obj->dev, pt_dma, IOPTE_TABLE_SIZE,
+                                        DMA_TO_DEVICE);
+               }
+
                kmem_cache_free(iopte_cachep, iopte);
+       }
 }
 
-static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)
+static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd,
+                       dma_addr_t *pt_dma, u32 da)
 {
        u32 *iopte;
+       unsigned long offset = iopgd_index(da) * sizeof(da);
 
        /* a table has already existed */
        if (*iopgd)
@@ -500,18 +498,38 @@ static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)
                if (!iopte)
                        return ERR_PTR(-ENOMEM);
 
+               *pt_dma = dma_map_single(obj->dev, iopte, IOPTE_TABLE_SIZE,
+                                        DMA_TO_DEVICE);
+               if (dma_mapping_error(obj->dev, *pt_dma)) {
+                       dev_err(obj->dev, "DMA map error for L2 table\n");
+                       iopte_free(obj, iopte, false);
+                       return ERR_PTR(-ENOMEM);
+               }
+
+               /*
+                * we rely on dma address and the physical address to be
+                * the same for mapping the L2 table
+                */
+               if (WARN_ON(*pt_dma != virt_to_phys(iopte))) {
+                       dev_err(obj->dev, "DMA translation error for L2 table\n");
+                       dma_unmap_single(obj->dev, *pt_dma, IOPTE_TABLE_SIZE,
+                                        DMA_TO_DEVICE);
+                       iopte_free(obj, iopte, false);
+                       return ERR_PTR(-ENOMEM);
+               }
+
                *iopgd = virt_to_phys(iopte) | IOPGD_TABLE;
-               flush_iopgd_range(iopgd, iopgd);
 
+               flush_iopte_range(obj->dev, obj->pd_dma, offset, 1);
                dev_vdbg(obj->dev, "%s: a new pte:%p\n", __func__, iopte);
        } else {
                /* We raced, free the reduniovant table */
-               iopte_free(iopte);
+               iopte_free(obj, iopte, false);
        }
 
 pte_ready:
        iopte = iopte_offset(iopgd, da);
-
+       *pt_dma = virt_to_phys(iopte);
        dev_vdbg(obj->dev,
                 "%s: da:%08x pgd:%p *pgd:%08x pte:%p *pte:%08x\n",
                 __func__, da, iopgd, *iopgd, iopte, *iopte);
@@ -522,6 +540,7 @@ pte_ready:
 static int iopgd_alloc_section(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 {
        u32 *iopgd = iopgd_offset(obj, da);
+       unsigned long offset = iopgd_index(da) * sizeof(da);
 
        if ((da | pa) & ~IOSECTION_MASK) {
                dev_err(obj->dev, "%s: %08x:%08x should aligned on %08lx\n",
@@ -530,13 +549,14 @@ static int iopgd_alloc_section(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
        }
 
        *iopgd = (pa & IOSECTION_MASK) | prot | IOPGD_SECTION;
-       flush_iopgd_range(iopgd, iopgd);
+       flush_iopte_range(obj->dev, obj->pd_dma, offset, 1);
        return 0;
 }
 
 static int iopgd_alloc_super(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 {
        u32 *iopgd = iopgd_offset(obj, da);
+       unsigned long offset = iopgd_index(da) * sizeof(da);
        int i;
 
        if ((da | pa) & ~IOSUPER_MASK) {
@@ -547,20 +567,22 @@ static int iopgd_alloc_super(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 
        for (i = 0; i < 16; i++)
                *(iopgd + i) = (pa & IOSUPER_MASK) | prot | IOPGD_SUPER;
-       flush_iopgd_range(iopgd, iopgd + 15);
+       flush_iopte_range(obj->dev, obj->pd_dma, offset, 16);
        return 0;
 }
 
 static int iopte_alloc_page(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 {
        u32 *iopgd = iopgd_offset(obj, da);
-       u32 *iopte = iopte_alloc(obj, iopgd, da);
+       dma_addr_t pt_dma;
+       u32 *iopte = iopte_alloc(obj, iopgd, &pt_dma, da);
+       unsigned long offset = iopte_index(da) * sizeof(da);
 
        if (IS_ERR(iopte))
                return PTR_ERR(iopte);
 
        *iopte = (pa & IOPAGE_MASK) | prot | IOPTE_SMALL;
-       flush_iopte_range(iopte, iopte);
+       flush_iopte_range(obj->dev, pt_dma, offset, 1);
 
        dev_vdbg(obj->dev, "%s: da:%08x pa:%08x pte:%p *pte:%08x\n",
                 __func__, da, pa, iopte, *iopte);
@@ -571,7 +593,9 @@ static int iopte_alloc_page(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 static int iopte_alloc_large(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 {
        u32 *iopgd = iopgd_offset(obj, da);
-       u32 *iopte = iopte_alloc(obj, iopgd, da);
+       dma_addr_t pt_dma;
+       u32 *iopte = iopte_alloc(obj, iopgd, &pt_dma, da);
+       unsigned long offset = iopte_index(da) * sizeof(da);
        int i;
 
        if ((da | pa) & ~IOLARGE_MASK) {
@@ -585,7 +609,7 @@ static int iopte_alloc_large(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
 
        for (i = 0; i < 16; i++)
                *(iopte + i) = (pa & IOLARGE_MASK) | prot | IOPTE_LARGE;
-       flush_iopte_range(iopte, iopte + 15);
+       flush_iopte_range(obj->dev, pt_dma, offset, 16);
        return 0;
 }
 
@@ -674,6 +698,9 @@ static size_t iopgtable_clear_entry_core(struct omap_iommu *obj, u32 da)
        size_t bytes;
        u32 *iopgd = iopgd_offset(obj, da);
        int nent = 1;
+       dma_addr_t pt_dma;
+       unsigned long pd_offset = iopgd_index(da) * sizeof(da);
+       unsigned long pt_offset = iopte_index(da) * sizeof(da);
 
        if (!*iopgd)
                return 0;
@@ -690,7 +717,8 @@ static size_t iopgtable_clear_entry_core(struct omap_iommu *obj, u32 da)
                }
                bytes *= nent;
                memset(iopte, 0, nent * sizeof(*iopte));
-               flush_iopte_range(iopte, iopte + (nent - 1) * sizeof(*iopte));
+               pt_dma = virt_to_phys(iopte);
+               flush_iopte_range(obj->dev, pt_dma, pt_offset, nent);
 
                /*
                 * do table walk to check if this table is necessary or not
@@ -700,7 +728,7 @@ static size_t iopgtable_clear_entry_core(struct omap_iommu *obj, u32 da)
                        if (iopte[i])
                                goto out;
 
-               iopte_free(iopte);
+               iopte_free(obj, iopte, true);
                nent = 1; /* for the next L1 entry */
        } else {
                bytes = IOPGD_SIZE;
@@ -712,7 +740,7 @@ static size_t iopgtable_clear_entry_core(struct omap_iommu *obj, u32 da)
                bytes *= nent;
        }
        memset(iopgd, 0, nent * sizeof(*iopgd));
-       flush_iopgd_range(iopgd, iopgd + (nent - 1) * sizeof(*iopgd));
+       flush_iopte_range(obj->dev, obj->pd_dma, pd_offset, nent);
 out:
        return bytes;
 }
@@ -738,6 +766,7 @@ static size_t iopgtable_clear_entry(struct omap_iommu *obj, u32 da)
 
 static void iopgtable_clear_entry_all(struct omap_iommu *obj)
 {
+       unsigned long offset;
        int i;
 
        spin_lock(&obj->page_table_lock);
@@ -748,15 +777,16 @@ static void iopgtable_clear_entry_all(struct omap_iommu *obj)
 
                da = i << IOPGD_SHIFT;
                iopgd = iopgd_offset(obj, da);
+               offset = iopgd_index(da) * sizeof(da);
 
                if (!*iopgd)
                        continue;
 
                if (iopgd_is_table(*iopgd))
-                       iopte_free(iopte_offset(iopgd, 0));
+                       iopte_free(obj, iopte_offset(iopgd, 0), true);
 
                *iopgd = 0;
-               flush_iopgd_range(iopgd, iopgd);
+               flush_iopte_range(obj->dev, obj->pd_dma, offset, 1);
        }
 
        flush_iotlb_all(obj);
@@ -786,7 +816,7 @@ static irqreturn_t iommu_fault_handler(int irq, void *data)
        if (!report_iommu_fault(domain, obj->dev, da, 0))
                return IRQ_HANDLED;
 
-       iommu_disable(obj);
+       iommu_write_reg(obj, 0, MMU_IRQENABLE);
 
        iopgd = iopgd_offset(obj, da);
 
@@ -815,10 +845,18 @@ static int omap_iommu_attach(struct omap_iommu *obj, u32 *iopgd)
 
        spin_lock(&obj->iommu_lock);
 
+       obj->pd_dma = dma_map_single(obj->dev, iopgd, IOPGD_TABLE_SIZE,
+                                    DMA_TO_DEVICE);
+       if (dma_mapping_error(obj->dev, obj->pd_dma)) {
+               dev_err(obj->dev, "DMA map error for L1 table\n");
+               err = -ENOMEM;
+               goto out_err;
+       }
+
        obj->iopgd = iopgd;
        err = iommu_enable(obj);
        if (err)
-               goto err_enable;
+               goto out_err;
        flush_iotlb_all(obj);
 
        spin_unlock(&obj->iommu_lock);
@@ -827,7 +865,7 @@ static int omap_iommu_attach(struct omap_iommu *obj, u32 *iopgd)
 
        return 0;
 
-err_enable:
+out_err:
        spin_unlock(&obj->iommu_lock);
 
        return err;
@@ -844,7 +882,10 @@ static void omap_iommu_detach(struct omap_iommu *obj)
 
        spin_lock(&obj->iommu_lock);
 
+       dma_unmap_single(obj->dev, obj->pd_dma, IOPGD_TABLE_SIZE,
+                        DMA_TO_DEVICE);
        iommu_disable(obj);
+       obj->pd_dma = 0;
        obj->iopgd = NULL;
 
        spin_unlock(&obj->iommu_lock);
@@ -1008,11 +1049,6 @@ static struct platform_driver omap_iommu_driver = {
        },
 };
 
-static void iopte_cachep_ctor(void *iopte)
-{
-       clean_dcache_area(iopte, IOPTE_TABLE_SIZE);
-}
-
 static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, int pgsz)
 {
        memset(e, 0, sizeof(*e));
@@ -1159,7 +1195,6 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
        if (WARN_ON(!IS_ALIGNED((long)omap_domain->pgtable, IOPGD_TABLE_SIZE)))
                goto fail_align;
 
-       clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE);
        spin_lock_init(&omap_domain->lock);
 
        omap_domain->domain.geometry.aperture_start = 0;
@@ -1347,7 +1382,7 @@ static int __init omap_iommu_init(void)
        of_node_put(np);
 
        p = kmem_cache_create("iopte_cache", IOPTE_TABLE_SIZE, align, flags,
-                             iopte_cachep_ctor);
+                             NULL);
        if (!p)
                return -ENOMEM;
        iopte_cachep = p;
index 6e70515e60385bfdadb520242107d045f8e82ec4..a675af29a6ec7ec4fc0f7f2424484205c6cc945b 100644 (file)
@@ -61,6 +61,7 @@ struct omap_iommu {
         */
        u32             *iopgd;
        spinlock_t      page_table_lock; /* protect iopgd */
+       dma_addr_t      pd_dma;
 
        int             nr_tlb_entries;
 
diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c
new file mode 100644 (file)
index 0000000..c8a587d
--- /dev/null
@@ -0,0 +1,930 @@
+/*
+ * IOMMU API for QCOM secure IOMMUs.  Somewhat based on arm-smmu.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2013 ARM Limited
+ * Copyright (C) 2017 Red Hat
+ */
+
+#include <linux/atomic.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-iommu.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/io-64-nonatomic-hi-lo.h>
+#include <linux/iommu.h>
+#include <linux/iopoll.h>
+#include <linux/kconfig.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/of_iommu.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/qcom_scm.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+#include "io-pgtable.h"
+#include "arm-smmu-regs.h"
+
+#define SMMU_INTR_SEL_NS     0x2000
+
+struct qcom_iommu_ctx;
+
+struct qcom_iommu_dev {
+       /* IOMMU core code handle */
+       struct iommu_device      iommu;
+       struct device           *dev;
+       struct clk              *iface_clk;
+       struct clk              *bus_clk;
+       void __iomem            *local_base;
+       u32                      sec_id;
+       u8                       num_ctxs;
+       struct qcom_iommu_ctx   *ctxs[0];   /* indexed by asid-1 */
+};
+
+struct qcom_iommu_ctx {
+       struct device           *dev;
+       void __iomem            *base;
+       bool                     secure_init;
+       u8                       asid;      /* asid and ctx bank # are 1:1 */
+};
+
+struct qcom_iommu_domain {
+       struct io_pgtable_ops   *pgtbl_ops;
+       spinlock_t               pgtbl_lock;
+       struct mutex             init_mutex; /* Protects iommu pointer */
+       struct iommu_domain      domain;
+       struct qcom_iommu_dev   *iommu;
+};
+
+static struct qcom_iommu_domain *to_qcom_iommu_domain(struct iommu_domain *dom)
+{
+       return container_of(dom, struct qcom_iommu_domain, domain);
+}
+
+static const struct iommu_ops qcom_iommu_ops;
+
+static struct qcom_iommu_dev * to_iommu(struct iommu_fwspec *fwspec)
+{
+       if (!fwspec || fwspec->ops != &qcom_iommu_ops)
+               return NULL;
+       return fwspec->iommu_priv;
+}
+
+static struct qcom_iommu_ctx * to_ctx(struct iommu_fwspec *fwspec, unsigned asid)
+{
+       struct qcom_iommu_dev *qcom_iommu = to_iommu(fwspec);
+       if (!qcom_iommu)
+               return NULL;
+       return qcom_iommu->ctxs[asid - 1];
+}
+
+static inline void
+iommu_writel(struct qcom_iommu_ctx *ctx, unsigned reg, u32 val)
+{
+       writel_relaxed(val, ctx->base + reg);
+}
+
+static inline void
+iommu_writeq(struct qcom_iommu_ctx *ctx, unsigned reg, u64 val)
+{
+       writeq_relaxed(val, ctx->base + reg);
+}
+
+static inline u32
+iommu_readl(struct qcom_iommu_ctx *ctx, unsigned reg)
+{
+       return readl_relaxed(ctx->base + reg);
+}
+
+static inline u64
+iommu_readq(struct qcom_iommu_ctx *ctx, unsigned reg)
+{
+       return readq_relaxed(ctx->base + reg);
+}
+
+static void qcom_iommu_tlb_sync(void *cookie)
+{
+       struct iommu_fwspec *fwspec = cookie;
+       unsigned i;
+
+       for (i = 0; i < fwspec->num_ids; i++) {
+               struct qcom_iommu_ctx *ctx = to_ctx(fwspec, fwspec->ids[i]);
+               unsigned int val, ret;
+
+               iommu_writel(ctx, ARM_SMMU_CB_TLBSYNC, 0);
+
+               ret = readl_poll_timeout(ctx->base + ARM_SMMU_CB_TLBSTATUS, val,
+                                        (val & 0x1) == 0, 0, 5000000);
+               if (ret)
+                       dev_err(ctx->dev, "timeout waiting for TLB SYNC\n");
+       }
+}
+
+static void qcom_iommu_tlb_inv_context(void *cookie)
+{
+       struct iommu_fwspec *fwspec = cookie;
+       unsigned i;
+
+       for (i = 0; i < fwspec->num_ids; i++) {
+               struct qcom_iommu_ctx *ctx = to_ctx(fwspec, fwspec->ids[i]);
+               iommu_writel(ctx, ARM_SMMU_CB_S1_TLBIASID, ctx->asid);
+       }
+
+       qcom_iommu_tlb_sync(cookie);
+}
+
+static void qcom_iommu_tlb_inv_range_nosync(unsigned long iova, size_t size,
+                                           size_t granule, bool leaf, void *cookie)
+{
+       struct iommu_fwspec *fwspec = cookie;
+       unsigned i, reg;
+
+       reg = leaf ? ARM_SMMU_CB_S1_TLBIVAL : ARM_SMMU_CB_S1_TLBIVA;
+
+       for (i = 0; i < fwspec->num_ids; i++) {
+               struct qcom_iommu_ctx *ctx = to_ctx(fwspec, fwspec->ids[i]);
+               size_t s = size;
+
+               iova &= ~12UL;
+               iova |= ctx->asid;
+               do {
+                       iommu_writel(ctx, reg, iova);
+                       iova += granule;
+               } while (s -= granule);
+       }
+}
+
+static const struct iommu_gather_ops qcom_gather_ops = {
+       .tlb_flush_all  = qcom_iommu_tlb_inv_context,
+       .tlb_add_flush  = qcom_iommu_tlb_inv_range_nosync,
+       .tlb_sync       = qcom_iommu_tlb_sync,
+};
+
+static irqreturn_t qcom_iommu_fault(int irq, void *dev)
+{
+       struct qcom_iommu_ctx *ctx = dev;
+       u32 fsr, fsynr;
+       u64 iova;
+
+       fsr = iommu_readl(ctx, ARM_SMMU_CB_FSR);
+
+       if (!(fsr & FSR_FAULT))
+               return IRQ_NONE;
+
+       fsynr = iommu_readl(ctx, ARM_SMMU_CB_FSYNR0);
+       iova = iommu_readq(ctx, ARM_SMMU_CB_FAR);
+
+       dev_err_ratelimited(ctx->dev,
+                           "Unhandled context fault: fsr=0x%x, "
+                           "iova=0x%016llx, fsynr=0x%x, cb=%d\n",
+                           fsr, iova, fsynr, ctx->asid);
+
+       iommu_writel(ctx, ARM_SMMU_CB_FSR, fsr);
+
+       return IRQ_HANDLED;
+}
+
+static int qcom_iommu_init_domain(struct iommu_domain *domain,
+                                 struct qcom_iommu_dev *qcom_iommu,
+                                 struct iommu_fwspec *fwspec)
+{
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       struct io_pgtable_ops *pgtbl_ops;
+       struct io_pgtable_cfg pgtbl_cfg;
+       int i, ret = 0;
+       u32 reg;
+
+       mutex_lock(&qcom_domain->init_mutex);
+       if (qcom_domain->iommu)
+               goto out_unlock;
+
+       pgtbl_cfg = (struct io_pgtable_cfg) {
+               .pgsize_bitmap  = qcom_iommu_ops.pgsize_bitmap,
+               .ias            = 32,
+               .oas            = 40,
+               .tlb            = &qcom_gather_ops,
+               .iommu_dev      = qcom_iommu->dev,
+       };
+
+       qcom_domain->iommu = qcom_iommu;
+       pgtbl_ops = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &pgtbl_cfg, fwspec);
+       if (!pgtbl_ops) {
+               dev_err(qcom_iommu->dev, "failed to allocate pagetable ops\n");
+               ret = -ENOMEM;
+               goto out_clear_iommu;
+       }
+
+       /* Update the domain's page sizes to reflect the page table format */
+       domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
+       domain->geometry.aperture_end = (1ULL << pgtbl_cfg.ias) - 1;
+       domain->geometry.force_aperture = true;
+
+       for (i = 0; i < fwspec->num_ids; i++) {
+               struct qcom_iommu_ctx *ctx = to_ctx(fwspec, fwspec->ids[i]);
+
+               if (!ctx->secure_init) {
+                       ret = qcom_scm_restore_sec_cfg(qcom_iommu->sec_id, ctx->asid);
+                       if (ret) {
+                               dev_err(qcom_iommu->dev, "secure init failed: %d\n", ret);
+                               goto out_clear_iommu;
+                       }
+                       ctx->secure_init = true;
+               }
+
+               /* TTBRs */
+               iommu_writeq(ctx, ARM_SMMU_CB_TTBR0,
+                               pgtbl_cfg.arm_lpae_s1_cfg.ttbr[0] |
+                               ((u64)ctx->asid << TTBRn_ASID_SHIFT));
+               iommu_writeq(ctx, ARM_SMMU_CB_TTBR1,
+                               pgtbl_cfg.arm_lpae_s1_cfg.ttbr[1] |
+                               ((u64)ctx->asid << TTBRn_ASID_SHIFT));
+
+               /* TTBCR */
+               iommu_writel(ctx, ARM_SMMU_CB_TTBCR2,
+                               (pgtbl_cfg.arm_lpae_s1_cfg.tcr >> 32) |
+                               TTBCR2_SEP_UPSTREAM);
+               iommu_writel(ctx, ARM_SMMU_CB_TTBCR,
+                               pgtbl_cfg.arm_lpae_s1_cfg.tcr);
+
+               /* MAIRs (stage-1 only) */
+               iommu_writel(ctx, ARM_SMMU_CB_S1_MAIR0,
+                               pgtbl_cfg.arm_lpae_s1_cfg.mair[0]);
+               iommu_writel(ctx, ARM_SMMU_CB_S1_MAIR1,
+                               pgtbl_cfg.arm_lpae_s1_cfg.mair[1]);
+
+               /* SCTLR */
+               reg = SCTLR_CFIE | SCTLR_CFRE | SCTLR_AFE | SCTLR_TRE |
+                       SCTLR_M | SCTLR_S1_ASIDPNE;
+
+               if (IS_ENABLED(CONFIG_BIG_ENDIAN))
+                       reg |= SCTLR_E;
+
+               iommu_writel(ctx, ARM_SMMU_CB_SCTLR, reg);
+       }
+
+       mutex_unlock(&qcom_domain->init_mutex);
+
+       /* Publish page table ops for map/unmap */
+       qcom_domain->pgtbl_ops = pgtbl_ops;
+
+       return 0;
+
+out_clear_iommu:
+       qcom_domain->iommu = NULL;
+out_unlock:
+       mutex_unlock(&qcom_domain->init_mutex);
+       return ret;
+}
+
+static struct iommu_domain *qcom_iommu_domain_alloc(unsigned type)
+{
+       struct qcom_iommu_domain *qcom_domain;
+
+       if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
+               return NULL;
+       /*
+        * Allocate the domain and initialise some of its data structures.
+        * We can't really do anything meaningful until we've added a
+        * master.
+        */
+       qcom_domain = kzalloc(sizeof(*qcom_domain), GFP_KERNEL);
+       if (!qcom_domain)
+               return NULL;
+
+       if (type == IOMMU_DOMAIN_DMA &&
+           iommu_get_dma_cookie(&qcom_domain->domain)) {
+               kfree(qcom_domain);
+               return NULL;
+       }
+
+       mutex_init(&qcom_domain->init_mutex);
+       spin_lock_init(&qcom_domain->pgtbl_lock);
+
+       return &qcom_domain->domain;
+}
+
+static void qcom_iommu_domain_free(struct iommu_domain *domain)
+{
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+
+       if (WARN_ON(qcom_domain->iommu))    /* forgot to detach? */
+               return;
+
+       iommu_put_dma_cookie(domain);
+
+       /* NOTE: unmap can be called after client device is powered off,
+        * for example, with GPUs or anything involving dma-buf.  So we
+        * cannot rely on the device_link.  Make sure the IOMMU is on to
+        * avoid unclocked accesses in the TLB inv path:
+        */
+       pm_runtime_get_sync(qcom_domain->iommu->dev);
+
+       free_io_pgtable_ops(qcom_domain->pgtbl_ops);
+
+       pm_runtime_put_sync(qcom_domain->iommu->dev);
+
+       kfree(qcom_domain);
+}
+
+static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
+{
+       struct qcom_iommu_dev *qcom_iommu = to_iommu(dev->iommu_fwspec);
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       int ret;
+
+       if (!qcom_iommu) {
+               dev_err(dev, "cannot attach to IOMMU, is it on the same bus?\n");
+               return -ENXIO;
+       }
+
+       /* Ensure that the domain is finalized */
+       pm_runtime_get_sync(qcom_iommu->dev);
+       ret = qcom_iommu_init_domain(domain, qcom_iommu, dev->iommu_fwspec);
+       pm_runtime_put_sync(qcom_iommu->dev);
+       if (ret < 0)
+               return ret;
+
+       /*
+        * Sanity check the domain. We don't support domains across
+        * different IOMMUs.
+        */
+       if (qcom_domain->iommu != qcom_iommu) {
+               dev_err(dev, "cannot attach to IOMMU %s while already "
+                       "attached to domain on IOMMU %s\n",
+                       dev_name(qcom_domain->iommu->dev),
+                       dev_name(qcom_iommu->dev));
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static void qcom_iommu_detach_dev(struct iommu_domain *domain, struct device *dev)
+{
+       struct iommu_fwspec *fwspec = dev->iommu_fwspec;
+       struct qcom_iommu_dev *qcom_iommu = to_iommu(fwspec);
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       unsigned i;
+
+       if (!qcom_domain->iommu)
+               return;
+
+       pm_runtime_get_sync(qcom_iommu->dev);
+       for (i = 0; i < fwspec->num_ids; i++) {
+               struct qcom_iommu_ctx *ctx = to_ctx(fwspec, fwspec->ids[i]);
+
+               /* Disable the context bank: */
+               iommu_writel(ctx, ARM_SMMU_CB_SCTLR, 0);
+       }
+       pm_runtime_put_sync(qcom_iommu->dev);
+
+       qcom_domain->iommu = NULL;
+}
+
+static int qcom_iommu_map(struct iommu_domain *domain, unsigned long iova,
+                         phys_addr_t paddr, size_t size, int prot)
+{
+       int ret;
+       unsigned long flags;
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       struct io_pgtable_ops *ops = qcom_domain->pgtbl_ops;
+
+       if (!ops)
+               return -ENODEV;
+
+       spin_lock_irqsave(&qcom_domain->pgtbl_lock, flags);
+       ret = ops->map(ops, iova, paddr, size, prot);
+       spin_unlock_irqrestore(&qcom_domain->pgtbl_lock, flags);
+       return ret;
+}
+
+static size_t qcom_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
+                              size_t size)
+{
+       size_t ret;
+       unsigned long flags;
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       struct io_pgtable_ops *ops = qcom_domain->pgtbl_ops;
+
+       if (!ops)
+               return 0;
+
+       /* NOTE: unmap can be called after client device is powered off,
+        * for example, with GPUs or anything involving dma-buf.  So we
+        * cannot rely on the device_link.  Make sure the IOMMU is on to
+        * avoid unclocked accesses in the TLB inv path:
+        */
+       pm_runtime_get_sync(qcom_domain->iommu->dev);
+       spin_lock_irqsave(&qcom_domain->pgtbl_lock, flags);
+       ret = ops->unmap(ops, iova, size);
+       spin_unlock_irqrestore(&qcom_domain->pgtbl_lock, flags);
+       pm_runtime_put_sync(qcom_domain->iommu->dev);
+
+       return ret;
+}
+
+static phys_addr_t qcom_iommu_iova_to_phys(struct iommu_domain *domain,
+                                          dma_addr_t iova)
+{
+       phys_addr_t ret;
+       unsigned long flags;
+       struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
+       struct io_pgtable_ops *ops = qcom_domain->pgtbl_ops;
+
+       if (!ops)
+               return 0;
+
+       spin_lock_irqsave(&qcom_domain->pgtbl_lock, flags);
+       ret = ops->iova_to_phys(ops, iova);
+       spin_unlock_irqrestore(&qcom_domain->pgtbl_lock, flags);
+
+       return ret;
+}
+
+static bool qcom_iommu_capable(enum iommu_cap cap)
+{
+       switch (cap) {
+       case IOMMU_CAP_CACHE_COHERENCY:
+               /*
+                * Return true here as the SMMU can always send out coherent
+                * requests.
+                */
+               return true;
+       case IOMMU_CAP_NOEXEC:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static int qcom_iommu_add_device(struct device *dev)
+{
+       struct qcom_iommu_dev *qcom_iommu = to_iommu(dev->iommu_fwspec);
+       struct iommu_group *group;
+       struct device_link *link;
+
+       if (!qcom_iommu)
+               return -ENODEV;
+
+       /*
+        * Establish the link between iommu and master, so that the
+        * iommu gets runtime enabled/disabled as per the master's
+        * needs.
+        */
+       link = device_link_add(dev, qcom_iommu->dev, DL_FLAG_PM_RUNTIME);
+       if (!link) {
+               dev_err(qcom_iommu->dev, "Unable to create device link between %s and %s\n",
+                       dev_name(qcom_iommu->dev), dev_name(dev));
+               return -ENODEV;
+       }
+
+       group = iommu_group_get_for_dev(dev);
+       if (IS_ERR_OR_NULL(group))
+               return PTR_ERR_OR_ZERO(group);
+
+       iommu_group_put(group);
+       iommu_device_link(&qcom_iommu->iommu, dev);
+
+       return 0;
+}
+
+static void qcom_iommu_remove_device(struct device *dev)
+{
+       struct qcom_iommu_dev *qcom_iommu = to_iommu(dev->iommu_fwspec);
+
+       if (!qcom_iommu)
+               return;
+
+       iommu_device_unlink(&qcom_iommu->iommu, dev);
+       iommu_group_remove_device(dev);
+       iommu_fwspec_free(dev);
+}
+
+static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
+{
+       struct qcom_iommu_dev *qcom_iommu;
+       struct platform_device *iommu_pdev;
+       unsigned asid = args->args[0];
+
+       if (args->args_count != 1) {
+               dev_err(dev, "incorrect number of iommu params found for %s "
+                       "(found %d, expected 1)\n",
+                       args->np->full_name, args->args_count);
+               return -EINVAL;
+       }
+
+       iommu_pdev = of_find_device_by_node(args->np);
+       if (WARN_ON(!iommu_pdev))
+               return -EINVAL;
+
+       qcom_iommu = platform_get_drvdata(iommu_pdev);
+
+       /* make sure the asid specified in dt is valid, so we don't have
+        * to sanity check this elsewhere, since 'asid - 1' is used to
+        * index into qcom_iommu->ctxs:
+        */
+       if (WARN_ON(asid < 1) ||
+           WARN_ON(asid > qcom_iommu->num_ctxs))
+               return -EINVAL;
+
+       if (!dev->iommu_fwspec->iommu_priv) {
+               dev->iommu_fwspec->iommu_priv = qcom_iommu;
+       } else {
+               /* make sure devices iommus dt node isn't referring to
+                * multiple different iommu devices.  Multiple context
+                * banks are ok, but multiple devices are not:
+                */
+               if (WARN_ON(qcom_iommu != dev->iommu_fwspec->iommu_priv))
+                       return -EINVAL;
+       }
+
+       return iommu_fwspec_add_ids(dev, &asid, 1);
+}
+
+static const struct iommu_ops qcom_iommu_ops = {
+       .capable        = qcom_iommu_capable,
+       .domain_alloc   = qcom_iommu_domain_alloc,
+       .domain_free    = qcom_iommu_domain_free,
+       .attach_dev     = qcom_iommu_attach_dev,
+       .detach_dev     = qcom_iommu_detach_dev,
+       .map            = qcom_iommu_map,
+       .unmap          = qcom_iommu_unmap,
+       .map_sg         = default_iommu_map_sg,
+       .iova_to_phys   = qcom_iommu_iova_to_phys,
+       .add_device     = qcom_iommu_add_device,
+       .remove_device  = qcom_iommu_remove_device,
+       .device_group   = generic_device_group,
+       .of_xlate       = qcom_iommu_of_xlate,
+       .pgsize_bitmap  = SZ_4K | SZ_64K | SZ_1M | SZ_16M,
+};
+
+static int qcom_iommu_enable_clocks(struct qcom_iommu_dev *qcom_iommu)
+{
+       int ret;
+
+       ret = clk_prepare_enable(qcom_iommu->iface_clk);
+       if (ret) {
+               dev_err(qcom_iommu->dev, "Couldn't enable iface_clk\n");
+               return ret;
+       }
+
+       ret = clk_prepare_enable(qcom_iommu->bus_clk);
+       if (ret) {
+               dev_err(qcom_iommu->dev, "Couldn't enable bus_clk\n");
+               clk_disable_unprepare(qcom_iommu->iface_clk);
+               return ret;
+       }
+
+       return 0;
+}
+
+static void qcom_iommu_disable_clocks(struct qcom_iommu_dev *qcom_iommu)
+{
+       clk_disable_unprepare(qcom_iommu->bus_clk);
+       clk_disable_unprepare(qcom_iommu->iface_clk);
+}
+
+static int qcom_iommu_sec_ptbl_init(struct device *dev)
+{
+       size_t psize = 0;
+       unsigned int spare = 0;
+       void *cpu_addr;
+       dma_addr_t paddr;
+       unsigned long attrs;
+       static bool allocated = false;
+       int ret;
+
+       if (allocated)
+               return 0;
+
+       ret = qcom_scm_iommu_secure_ptbl_size(spare, &psize);
+       if (ret) {
+               dev_err(dev, "failed to get iommu secure pgtable size (%d)\n",
+                       ret);
+               return ret;
+       }
+
+       dev_info(dev, "iommu sec: pgtable size: %zu\n", psize);
+
+       attrs = DMA_ATTR_NO_KERNEL_MAPPING;
+
+       cpu_addr = dma_alloc_attrs(dev, psize, &paddr, GFP_KERNEL, attrs);
+       if (!cpu_addr) {
+               dev_err(dev, "failed to allocate %zu bytes for pgtable\n",
+                       psize);
+               return -ENOMEM;
+       }
+
+       ret = qcom_scm_iommu_secure_ptbl_init(paddr, psize, spare);
+       if (ret) {
+               dev_err(dev, "failed to init iommu pgtable (%d)\n", ret);
+               goto free_mem;
+       }
+
+       allocated = true;
+       return 0;
+
+free_mem:
+       dma_free_attrs(dev, psize, cpu_addr, paddr, attrs);
+       return ret;
+}
+
+static int get_asid(const struct device_node *np)
+{
+       u32 reg;
+
+       /* read the "reg" property directly to get the relative address
+        * of the context bank, and calculate the asid from that:
+        */
+       if (of_property_read_u32_index(np, "reg", 0, &reg))
+               return -ENODEV;
+
+       return reg / 0x1000;      /* context banks are 0x1000 apart */
+}
+
+static int qcom_iommu_ctx_probe(struct platform_device *pdev)
+{
+       struct qcom_iommu_ctx *ctx;
+       struct device *dev = &pdev->dev;
+       struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev->parent);
+       struct resource *res;
+       int ret, irq;
+
+       ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+       if (!ctx)
+               return -ENOMEM;
+
+       ctx->dev = dev;
+       platform_set_drvdata(pdev, ctx);
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       ctx->base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(ctx->base))
+               return PTR_ERR(ctx->base);
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0) {
+               dev_err(dev, "failed to get irq\n");
+               return -ENODEV;
+       }
+
+       /* clear IRQs before registering fault handler, just in case the
+        * boot-loader left us a surprise:
+        */
+       iommu_writel(ctx, ARM_SMMU_CB_FSR, iommu_readl(ctx, ARM_SMMU_CB_FSR));
+
+       ret = devm_request_irq(dev, irq,
+                              qcom_iommu_fault,
+                              IRQF_SHARED,
+                              "qcom-iommu-fault",
+                              ctx);
+       if (ret) {
+               dev_err(dev, "failed to request IRQ %u\n", irq);
+               return ret;
+       }
+
+       ret = get_asid(dev->of_node);
+       if (ret < 0) {
+               dev_err(dev, "missing reg property\n");
+               return ret;
+       }
+
+       ctx->asid = ret;
+
+       dev_dbg(dev, "found asid %u\n", ctx->asid);
+
+       qcom_iommu->ctxs[ctx->asid - 1] = ctx;
+
+       return 0;
+}
+
+static int qcom_iommu_ctx_remove(struct platform_device *pdev)
+{
+       struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(pdev->dev.parent);
+       struct qcom_iommu_ctx *ctx = platform_get_drvdata(pdev);
+
+       platform_set_drvdata(pdev, NULL);
+
+       qcom_iommu->ctxs[ctx->asid - 1] = NULL;
+
+       return 0;
+}
+
+static const struct of_device_id ctx_of_match[] = {
+       { .compatible = "qcom,msm-iommu-v1-ns" },
+       { .compatible = "qcom,msm-iommu-v1-sec" },
+       { /* sentinel */ }
+};
+
+static struct platform_driver qcom_iommu_ctx_driver = {
+       .driver = {
+               .name           = "qcom-iommu-ctx",
+               .of_match_table = of_match_ptr(ctx_of_match),
+       },
+       .probe  = qcom_iommu_ctx_probe,
+       .remove = qcom_iommu_ctx_remove,
+};
+
+static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu)
+{
+       struct device_node *child;
+
+       for_each_child_of_node(qcom_iommu->dev->of_node, child)
+               if (of_device_is_compatible(child, "qcom,msm-iommu-v1-sec"))
+                       return true;
+
+       return false;
+}
+
+static int qcom_iommu_device_probe(struct platform_device *pdev)
+{
+       struct device_node *child;
+       struct qcom_iommu_dev *qcom_iommu;
+       struct device *dev = &pdev->dev;
+       struct resource *res;
+       int ret, sz, max_asid = 0;
+
+       /* find the max asid (which is 1:1 to ctx bank idx), so we know how
+        * many child ctx devices we have:
+        */
+       for_each_child_of_node(dev->of_node, child)
+               max_asid = max(max_asid, get_asid(child));
+
+       sz = sizeof(*qcom_iommu) + (max_asid * sizeof(qcom_iommu->ctxs[0]));
+
+       qcom_iommu = devm_kzalloc(dev, sz, GFP_KERNEL);
+       if (!qcom_iommu)
+               return -ENOMEM;
+       qcom_iommu->num_ctxs = max_asid;
+       qcom_iommu->dev = dev;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (res)
+               qcom_iommu->local_base = devm_ioremap_resource(dev, res);
+
+       qcom_iommu->iface_clk = devm_clk_get(dev, "iface");
+       if (IS_ERR(qcom_iommu->iface_clk)) {
+               dev_err(dev, "failed to get iface clock\n");
+               return PTR_ERR(qcom_iommu->iface_clk);
+       }
+
+       qcom_iommu->bus_clk = devm_clk_get(dev, "bus");
+       if (IS_ERR(qcom_iommu->bus_clk)) {
+               dev_err(dev, "failed to get bus clock\n");
+               return PTR_ERR(qcom_iommu->bus_clk);
+       }
+
+       if (of_property_read_u32(dev->of_node, "qcom,iommu-secure-id",
+                                &qcom_iommu->sec_id)) {
+               dev_err(dev, "missing qcom,iommu-secure-id property\n");
+               return -ENODEV;
+       }
+
+       if (qcom_iommu_has_secure_context(qcom_iommu)) {
+               ret = qcom_iommu_sec_ptbl_init(dev);
+               if (ret) {
+                       dev_err(dev, "cannot init secure pg table(%d)\n", ret);
+                       return ret;
+               }
+       }
+
+       platform_set_drvdata(pdev, qcom_iommu);
+
+       pm_runtime_enable(dev);
+
+       /* register context bank devices, which are child nodes: */
+       ret = devm_of_platform_populate(dev);
+       if (ret) {
+               dev_err(dev, "Failed to populate iommu contexts\n");
+               return ret;
+       }
+
+       ret = iommu_device_sysfs_add(&qcom_iommu->iommu, dev, NULL,
+                                    dev_name(dev));
+       if (ret) {
+               dev_err(dev, "Failed to register iommu in sysfs\n");
+               return ret;
+       }
+
+       iommu_device_set_ops(&qcom_iommu->iommu, &qcom_iommu_ops);
+       iommu_device_set_fwnode(&qcom_iommu->iommu, dev->fwnode);
+
+       ret = iommu_device_register(&qcom_iommu->iommu);
+       if (ret) {
+               dev_err(dev, "Failed to register iommu\n");
+               return ret;
+       }
+
+       bus_set_iommu(&platform_bus_type, &qcom_iommu_ops);
+
+       if (qcom_iommu->local_base) {
+               pm_runtime_get_sync(dev);
+               writel_relaxed(0xffffffff, qcom_iommu->local_base + SMMU_INTR_SEL_NS);
+               pm_runtime_put_sync(dev);
+       }
+
+       return 0;
+}
+
+static int qcom_iommu_device_remove(struct platform_device *pdev)
+{
+       struct qcom_iommu_dev *qcom_iommu = platform_get_drvdata(pdev);
+
+       bus_set_iommu(&platform_bus_type, NULL);
+
+       pm_runtime_force_suspend(&pdev->dev);
+       platform_set_drvdata(pdev, NULL);
+       iommu_device_sysfs_remove(&qcom_iommu->iommu);
+       iommu_device_unregister(&qcom_iommu->iommu);
+
+       return 0;
+}
+
+static int __maybe_unused qcom_iommu_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct qcom_iommu_dev *qcom_iommu = platform_get_drvdata(pdev);
+
+       return qcom_iommu_enable_clocks(qcom_iommu);
+}
+
+static int __maybe_unused qcom_iommu_suspend(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct qcom_iommu_dev *qcom_iommu = platform_get_drvdata(pdev);
+
+       qcom_iommu_disable_clocks(qcom_iommu);
+
+       return 0;
+}
+
+static const struct dev_pm_ops qcom_iommu_pm_ops = {
+       SET_RUNTIME_PM_OPS(qcom_iommu_suspend, qcom_iommu_resume, NULL)
+       SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+                               pm_runtime_force_resume)
+};
+
+static const struct of_device_id qcom_iommu_of_match[] = {
+       { .compatible = "qcom,msm-iommu-v1" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, qcom_iommu_of_match);
+
+static struct platform_driver qcom_iommu_driver = {
+       .driver = {
+               .name           = "qcom-iommu",
+               .of_match_table = of_match_ptr(qcom_iommu_of_match),
+               .pm             = &qcom_iommu_pm_ops,
+       },
+       .probe  = qcom_iommu_device_probe,
+       .remove = qcom_iommu_device_remove,
+};
+
+static int __init qcom_iommu_init(void)
+{
+       int ret;
+
+       ret = platform_driver_register(&qcom_iommu_ctx_driver);
+       if (ret)
+               return ret;
+
+       ret = platform_driver_register(&qcom_iommu_driver);
+       if (ret)
+               platform_driver_unregister(&qcom_iommu_ctx_driver);
+
+       return ret;
+}
+
+static void __exit qcom_iommu_exit(void)
+{
+       platform_driver_unregister(&qcom_iommu_driver);
+       platform_driver_unregister(&qcom_iommu_ctx_driver);
+}
+
+module_init(qcom_iommu_init);
+module_exit(qcom_iommu_exit);
+
+IOMMU_OF_DECLARE(qcom_iommu_dev, "qcom,msm-iommu-v1", NULL);
+
+MODULE_DESCRIPTION("IOMMU API for QCOM IOMMU v1 implementations");
+MODULE_LICENSE("GPL v2");
index 4ba48a26b389406af5a0d6636ecb7d1fa4e03346..9d991c2d87674c1dc19d3dd1d64f4c287041f4db 100644 (file)
@@ -90,7 +90,9 @@ struct rk_iommu {
        struct device *dev;
        void __iomem **bases;
        int num_mmu;
-       int irq;
+       int *irq;
+       int num_irq;
+       bool reset_disabled;
        struct iommu_device iommu;
        struct list_head node; /* entry in rk_iommu_domain.iommus */
        struct iommu_domain *domain; /* domain to which iommu is attached */
@@ -414,6 +416,9 @@ static int rk_iommu_force_reset(struct rk_iommu *iommu)
        int ret, i;
        u32 dte_addr;
 
+       if (iommu->reset_disabled)
+               return 0;
+
        /*
         * Check if register DTE_ADDR is working by writing DTE_ADDR_DUMMY
         * and verifying that upper 5 nybbles are read back.
@@ -825,10 +830,12 @@ static int rk_iommu_attach_device(struct iommu_domain *domain,
 
        iommu->domain = domain;
 
-       ret = devm_request_irq(iommu->dev, iommu->irq, rk_iommu_irq,
-                              IRQF_SHARED, dev_name(dev), iommu);
-       if (ret)
-               return ret;
+       for (i = 0; i < iommu->num_irq; i++) {
+               ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq,
+                                      IRQF_SHARED, dev_name(dev), iommu);
+               if (ret)
+                       return ret;
+       }
 
        for (i = 0; i < iommu->num_mmu; i++) {
                rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR,
@@ -878,7 +885,8 @@ static void rk_iommu_detach_device(struct iommu_domain *domain,
        }
        rk_iommu_disable_stall(iommu);
 
-       devm_free_irq(iommu->dev, iommu->irq, iommu);
+       for (i = 0; i < iommu->num_irq; i++)
+               devm_free_irq(iommu->dev, iommu->irq[i], iommu);
 
        iommu->domain = NULL;
 
@@ -1008,20 +1016,20 @@ static int rk_iommu_group_set_iommudata(struct iommu_group *group,
        ret = of_parse_phandle_with_args(np, "iommus", "#iommu-cells", 0,
                                         &args);
        if (ret) {
-               dev_err(dev, "of_parse_phandle_with_args(%s) => %d\n",
-                       np->full_name, ret);
+               dev_err(dev, "of_parse_phandle_with_args(%pOF) => %d\n",
+                       np, ret);
                return ret;
        }
        if (args.args_count != 0) {
-               dev_err(dev, "incorrect number of iommu params found for %s (found %d, expected 0)\n",
-                       args.np->full_name, args.args_count);
+               dev_err(dev, "incorrect number of iommu params found for %pOF (found %d, expected 0)\n",
+                       args.np, args.args_count);
                return -EINVAL;
        }
 
        pd = of_find_device_by_node(args.np);
        of_node_put(args.np);
        if (!pd) {
-               dev_err(dev, "iommu %s not found\n", args.np->full_name);
+               dev_err(dev, "iommu %pOF not found\n", args.np);
                return -EPROBE_DEFER;
        }
 
@@ -1157,12 +1165,28 @@ static int rk_iommu_probe(struct platform_device *pdev)
        if (iommu->num_mmu == 0)
                return PTR_ERR(iommu->bases[0]);
 
-       iommu->irq = platform_get_irq(pdev, 0);
-       if (iommu->irq < 0) {
-               dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq);
+       iommu->num_irq = platform_irq_count(pdev);
+       if (iommu->num_irq < 0)
+               return iommu->num_irq;
+       if (iommu->num_irq == 0)
                return -ENXIO;
+
+       iommu->irq = devm_kcalloc(dev, iommu->num_irq, sizeof(*iommu->irq),
+                                 GFP_KERNEL);
+       if (!iommu->irq)
+               return -ENOMEM;
+
+       for (i = 0; i < iommu->num_irq; i++) {
+               iommu->irq[i] = platform_get_irq(pdev, i);
+               if (iommu->irq[i] < 0) {
+                       dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq[i]);
+                       return -ENXIO;
+               }
        }
 
+       iommu->reset_disabled = device_property_read_bool(dev,
+                                       "rockchip,disable-mmu-reset");
+
        err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
        if (err)
                return err;
index 8788640756a7361ccb656269efd2b8bbb9ac68f7..0e2f31f9032bc922c80c4a9b0b9417883195caeb 100644 (file)
@@ -18,6 +18,8 @@
  */
 #define S390_IOMMU_PGSIZES     (~0xFFFUL)
 
+static const struct iommu_ops s390_iommu_ops;
+
 struct s390_domain {
        struct iommu_domain     domain;
        struct list_head        devices;
@@ -166,11 +168,13 @@ static void s390_iommu_detach_device(struct iommu_domain *domain,
 static int s390_iommu_add_device(struct device *dev)
 {
        struct iommu_group *group = iommu_group_get_for_dev(dev);
+       struct zpci_dev *zdev = to_pci_dev(dev)->sysdata;
 
        if (IS_ERR(group))
                return PTR_ERR(group);
 
        iommu_group_put(group);
+       iommu_device_link(&zdev->iommu_dev, dev);
 
        return 0;
 }
@@ -197,6 +201,7 @@ static void s390_iommu_remove_device(struct device *dev)
                        s390_iommu_detach_device(domain, dev);
        }
 
+       iommu_device_unlink(&zdev->iommu_dev, dev);
        iommu_group_remove_device(dev);
 }
 
@@ -327,7 +332,37 @@ static size_t s390_iommu_unmap(struct iommu_domain *domain,
        return size;
 }
 
-static struct iommu_ops s390_iommu_ops = {
+int zpci_init_iommu(struct zpci_dev *zdev)
+{
+       int rc = 0;
+
+       rc = iommu_device_sysfs_add(&zdev->iommu_dev, NULL, NULL,
+                                   "s390-iommu.%08x", zdev->fid);
+       if (rc)
+               goto out_err;
+
+       iommu_device_set_ops(&zdev->iommu_dev, &s390_iommu_ops);
+
+       rc = iommu_device_register(&zdev->iommu_dev);
+       if (rc)
+               goto out_sysfs;
+
+       return 0;
+
+out_sysfs:
+       iommu_device_sysfs_remove(&zdev->iommu_dev);
+
+out_err:
+       return rc;
+}
+
+void zpci_destroy_iommu(struct zpci_dev *zdev)
+{
+       iommu_device_unregister(&zdev->iommu_dev);
+       iommu_device_sysfs_remove(&zdev->iommu_dev);
+}
+
+static const struct iommu_ops s390_iommu_ops = {
        .capable = s390_iommu_capable,
        .domain_alloc = s390_domain_alloc,
        .domain_free = s390_domain_free,
index 37e708fdbb5aac0bb66ac0cf17db030aa30a3a1e..b62f790ad1bab5e607d6c8dd95d8172a7b03d075 100644 (file)
@@ -61,6 +61,8 @@ struct gart_device {
        struct list_head        client;
        spinlock_t              client_lock;    /* for client list */
        struct device           *dev;
+
+       struct iommu_device     iommu;          /* IOMMU Core handle */
 };
 
 struct gart_domain {
@@ -334,12 +336,35 @@ static bool gart_iommu_capable(enum iommu_cap cap)
        return false;
 }
 
+static int gart_iommu_add_device(struct device *dev)
+{
+       struct iommu_group *group = iommu_group_get_for_dev(dev);
+
+       if (IS_ERR(group))
+               return PTR_ERR(group);
+
+       iommu_group_put(group);
+
+       iommu_device_link(&gart_handle->iommu, dev);
+
+       return 0;
+}
+
+static void gart_iommu_remove_device(struct device *dev)
+{
+       iommu_group_remove_device(dev);
+       iommu_device_unlink(&gart_handle->iommu, dev);
+}
+
 static const struct iommu_ops gart_iommu_ops = {
        .capable        = gart_iommu_capable,
        .domain_alloc   = gart_iommu_domain_alloc,
        .domain_free    = gart_iommu_domain_free,
        .attach_dev     = gart_iommu_attach_dev,
        .detach_dev     = gart_iommu_detach_dev,
+       .add_device     = gart_iommu_add_device,
+       .remove_device  = gart_iommu_remove_device,
+       .device_group   = generic_device_group,
        .map            = gart_iommu_map,
        .map_sg         = default_iommu_map_sg,
        .unmap          = gart_iommu_unmap,
@@ -378,6 +403,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
        struct resource *res, *res_remap;
        void __iomem *gart_regs;
        struct device *dev = &pdev->dev;
+       int ret;
 
        if (gart_handle)
                return -EIO;
@@ -404,6 +430,22 @@ static int tegra_gart_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
+       ret = iommu_device_sysfs_add(&gart->iommu, &pdev->dev, NULL,
+                                    dev_name(&pdev->dev));
+       if (ret) {
+               dev_err(dev, "Failed to register IOMMU in sysfs\n");
+               return ret;
+       }
+
+       iommu_device_set_ops(&gart->iommu, &gart_iommu_ops);
+
+       ret = iommu_device_register(&gart->iommu);
+       if (ret) {
+               dev_err(dev, "Failed to register IOMMU\n");
+               iommu_device_sysfs_remove(&gart->iommu);
+               return ret;
+       }
+
        gart->dev = &pdev->dev;
        spin_lock_init(&gart->pte_lock);
        spin_lock_init(&gart->client_lock);
@@ -430,6 +472,9 @@ static int tegra_gart_remove(struct platform_device *pdev)
 {
        struct gart_device *gart = platform_get_drvdata(pdev);
 
+       iommu_device_unregister(&gart->iommu);
+       iommu_device_sysfs_remove(&gart->iommu);
+
        writel(0, gart->regs + GART_CONFIG);
        if (gart->savedata)
                vfree(gart->savedata);
index eeb19f560a05ee54d87da40859e206626f1418a6..3b6449e2cbf1c47d6d923f28d598d90e7382b043 100644 (file)
@@ -36,6 +36,8 @@ struct tegra_smmu {
        struct list_head list;
 
        struct dentry *debugfs;
+
+       struct iommu_device iommu;      /* IOMMU Core code handle */
 };
 
 struct tegra_smmu_as {
@@ -704,6 +706,7 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
 static int tegra_smmu_add_device(struct device *dev)
 {
        struct device_node *np = dev->of_node;
+       struct iommu_group *group;
        struct of_phandle_args args;
        unsigned int index = 0;
 
@@ -719,18 +722,33 @@ static int tegra_smmu_add_device(struct device *dev)
                         * first match.
                         */
                        dev->archdata.iommu = smmu;
+
+                       iommu_device_link(&smmu->iommu, dev);
+
                        break;
                }
 
                index++;
        }
 
+       group = iommu_group_get_for_dev(dev);
+       if (IS_ERR(group))
+               return PTR_ERR(group);
+
+       iommu_group_put(group);
+
        return 0;
 }
 
 static void tegra_smmu_remove_device(struct device *dev)
 {
+       struct tegra_smmu *smmu = dev->archdata.iommu;
+
+       if (smmu)
+               iommu_device_unlink(&smmu->iommu, dev);
+
        dev->archdata.iommu = NULL;
+       iommu_group_remove_device(dev);
 }
 
 static const struct iommu_ops tegra_smmu_ops = {
@@ -741,6 +759,7 @@ static const struct iommu_ops tegra_smmu_ops = {
        .detach_dev = tegra_smmu_detach_dev,
        .add_device = tegra_smmu_add_device,
        .remove_device = tegra_smmu_remove_device,
+       .device_group = generic_device_group,
        .map = tegra_smmu_map,
        .unmap = tegra_smmu_unmap,
        .map_sg = default_iommu_map_sg,
@@ -930,9 +949,24 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
 
        tegra_smmu_ahb_enable();
 
+       err = iommu_device_sysfs_add(&smmu->iommu, dev, NULL, dev_name(dev));
+       if (err)
+               return ERR_PTR(err);
+
+       iommu_device_set_ops(&smmu->iommu, &tegra_smmu_ops);
+
+       err = iommu_device_register(&smmu->iommu);
+       if (err) {
+               iommu_device_sysfs_remove(&smmu->iommu);
+               return ERR_PTR(err);
+       }
+
        err = bus_set_iommu(&platform_bus_type, &tegra_smmu_ops);
-       if (err < 0)
+       if (err < 0) {
+               iommu_device_unregister(&smmu->iommu);
+               iommu_device_sysfs_remove(&smmu->iommu);
                return ERR_PTR(err);
+       }
 
        if (IS_ENABLED(CONFIG_DEBUG_FS))
                tegra_smmu_debugfs_init(smmu);
@@ -942,6 +976,9 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
 
 void tegra_smmu_remove(struct tegra_smmu *smmu)
 {
+       iommu_device_unregister(&smmu->iommu);
+       iommu_device_sysfs_remove(&smmu->iommu);
+
        if (IS_ENABLED(CONFIG_DEBUG_FS))
                tegra_smmu_debugfs_exit(smmu);
 }
index 28b26c80f4cf937b8547328b5d724a69e51b7d05..072bd227b6c677b40fee80f99e1364d733e681a3 100644 (file)
@@ -137,14 +137,14 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
 #define AT91_RTC_IMR           0x28
 #define AT91_RTC_IRQ_MASK      0x1f
 
-void __init aic_common_rtc_irq_fixup(struct device_node *root)
+void __init aic_common_rtc_irq_fixup(void)
 {
        struct device_node *np;
        void __iomem *regs;
 
-       np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc");
+       np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-rtc");
        if (!np)
-               np = of_find_compatible_node(root, NULL,
+               np = of_find_compatible_node(NULL, NULL,
                                             "atmel,at91sam9x5-rtc");
 
        if (!np)
@@ -165,7 +165,7 @@ void __init aic_common_rtc_irq_fixup(struct device_node *root)
 #define AT91_RTT_ALMIEN                (1 << 16)               /* Alarm Interrupt Enable */
 #define AT91_RTT_RTTINCIEN     (1 << 17)               /* Real Time Timer Increment Interrupt Enable */
 
-void __init aic_common_rtt_irq_fixup(struct device_node *root)
+void __init aic_common_rtt_irq_fixup(void)
 {
        struct device_node *np;
        void __iomem *regs;
@@ -196,11 +196,10 @@ static void __init aic_common_irq_fixup(const struct of_device_id *matches)
                return;
 
        match = of_match_node(matches, root);
-       of_node_put(root);
 
        if (match) {
-               void (*fixup)(struct device_node *) = match->data;
-               fixup(root);
+               void (*fixup)(void) = match->data;
+               fixup();
        }
 
        of_node_put(root);
index af60376d50debe30132acd00c58254c4d1a7ab9a..242e62c1851ead9744442e0236fa84198f745d7f 100644 (file)
@@ -33,8 +33,8 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
                                             const char *name, int nirqs,
                                             const struct of_device_id *matches);
 
-void __init aic_common_rtc_irq_fixup(struct device_node *root);
+void __init aic_common_rtc_irq_fixup(void);
 
-void __init aic_common_rtt_irq_fixup(struct device_node *root);
+void __init aic_common_rtt_irq_fixup(void);
 
 #endif /* __IRQ_ATMEL_AIC_COMMON_H */
index 37f952dd9fc94bdc5faa6c2721822b8780dd46e1..bb1ad451392fd8b7a315a6b2c5bea523af04a62a 100644 (file)
@@ -209,20 +209,20 @@ static const struct irq_domain_ops aic_irq_ops = {
        .xlate  = aic_irq_domain_xlate,
 };
 
-static void __init at91rm9200_aic_irq_fixup(struct device_node *root)
+static void __init at91rm9200_aic_irq_fixup(void)
 {
-       aic_common_rtc_irq_fixup(root);
+       aic_common_rtc_irq_fixup();
 }
 
-static void __init at91sam9260_aic_irq_fixup(struct device_node *root)
+static void __init at91sam9260_aic_irq_fixup(void)
 {
-       aic_common_rtt_irq_fixup(root);
+       aic_common_rtt_irq_fixup();
 }
 
-static void __init at91sam9g45_aic_irq_fixup(struct device_node *root)
+static void __init at91sam9g45_aic_irq_fixup(void)
 {
-       aic_common_rtc_irq_fixup(root);
-       aic_common_rtt_irq_fixup(root);
+       aic_common_rtc_irq_fixup();
+       aic_common_rtt_irq_fixup();
 }
 
 static const struct of_device_id aic_irq_fixups[] __initconst = {
index c04ee9a23d094f9d6a9e0c95a7451cf73626727a..6acad2ea0fb3565a2604ecbb3fb5235395d62fad 100644 (file)
@@ -305,9 +305,9 @@ static const struct irq_domain_ops aic5_irq_ops = {
        .xlate  = aic5_irq_domain_xlate,
 };
 
-static void __init sama5d3_aic_irq_fixup(struct device_node *root)
+static void __init sama5d3_aic_irq_fixup(void)
 {
-       aic_common_rtc_irq_fixup(root);
+       aic_common_rtc_irq_fixup();
 }
 
 static const struct of_device_id aic5_irq_fixups[] __initconst = {
index bddf169c4b37b7c9d2a91518aa233480dbb52f5d..b009b916a2923504414aafe6961b404614770da5 100644 (file)
@@ -189,6 +189,7 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np,
 
        ct->chip.irq_suspend = brcmstb_l2_intc_suspend;
        ct->chip.irq_resume = brcmstb_l2_intc_resume;
+       ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend;
 
        if (data->can_wake) {
                /* This IRQ chip can wake the system, set all child interrupts
index 249240d9a4259eb72b7afb68c2e2723a72e7c9c5..833a90fe33aed839a81b781831027e677eef5581 100644 (file)
@@ -43,6 +43,7 @@ static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev,
                        *dev_id = args.args[0];
                        break;
                }
+               index++;
        } while (!ret);
 
        return ret;
index 68932873eebc0c3d14caa00b048d0c961e765a98..284738add89b3b94f77ad257fd314bc89a423cae 100644 (file)
@@ -1835,7 +1835,7 @@ static int __init its_of_probe(struct device_node *node)
 
 #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
 
-#if defined(CONFIG_ACPI_NUMA) && (ACPI_CA_VERSION >= 0x20170531)
+#ifdef CONFIG_ACPI_NUMA
 struct its_srat_map {
        /* numa node id */
        u32     numa_node;
@@ -1843,7 +1843,7 @@ struct its_srat_map {
        u32     its_id;
 };
 
-static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata;
+static struct its_srat_map *its_srat_maps __initdata;
 static int its_in_srat __initdata;
 
 static int __init acpi_get_its_numa_node(u32 its_id)
@@ -1857,6 +1857,12 @@ static int __init acpi_get_its_numa_node(u32 its_id)
        return NUMA_NO_NODE;
 }
 
+static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header,
+                                         const unsigned long end)
+{
+       return 0;
+}
+
 static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
                         const unsigned long end)
 {
@@ -1873,12 +1879,6 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
                return -EINVAL;
        }
 
-       if (its_in_srat >= MAX_NUMNODES) {
-               pr_err("SRAT: ITS affinity exceeding max count[%d]\n",
-                               MAX_NUMNODES);
-               return -EINVAL;
-       }
-
        node = acpi_map_pxm_to_node(its_affinity->proximity_domain);
 
        if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
@@ -1897,14 +1897,37 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
 
 static void __init acpi_table_parse_srat_its(void)
 {
+       int count;
+
+       count = acpi_table_parse_entries(ACPI_SIG_SRAT,
+                       sizeof(struct acpi_table_srat),
+                       ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
+                       gic_acpi_match_srat_its, 0);
+       if (count <= 0)
+               return;
+
+       its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
+                               GFP_KERNEL);
+       if (!its_srat_maps) {
+               pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
+               return;
+       }
+
        acpi_table_parse_entries(ACPI_SIG_SRAT,
                        sizeof(struct acpi_table_srat),
                        ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
                        gic_acpi_parse_srat_its, 0);
 }
+
+/* free the its_srat_maps after ITS probing */
+static void __init acpi_its_srat_maps_free(void)
+{
+       kfree(its_srat_maps);
+}
 #else
 static void __init acpi_table_parse_srat_its(void)     { }
 static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; }
+static void __init acpi_its_srat_maps_free(void) { }
 #endif
 
 static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
@@ -1951,6 +1974,7 @@ static void __init its_acpi_probe(void)
        acpi_table_parse_srat_its();
        acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
                              gic_acpi_parse_madt_its, 0);
+       acpi_its_srat_maps_free();
 }
 #else
 static void __init its_acpi_probe(void) { }
index dbffb7ab62033b346ca7fc3b3468d6bcb3a19a63..984c3ecfd22c21aff59b3cad177c676348d86dd4 100644 (file)
@@ -353,6 +353,8 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
 
                        if (static_key_true(&supports_deactivate))
                                gic_write_eoir(irqnr);
+                       else
+                               isb();
 
                        err = handle_domain_irq(gic_data.domain, irqnr, regs);
                        if (err) {
@@ -640,11 +642,16 @@ static void gic_smp_init(void)
 static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
                            bool force)
 {
-       unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
+       unsigned int cpu;
        void __iomem *reg;
        int enabled;
        u64 val;
 
+       if (force)
+               cpu = cpumask_first(mask_val);
+       else
+               cpu = cpumask_any_and(mask_val, cpu_online_mask);
+
        if (cpu >= nr_cpu_ids)
                return -EINVAL;
 
@@ -831,8 +838,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
        if (ret)
                return ret;
 
-       for (i = 0; i < nr_irqs; i++)
-               gic_irq_domain_map(domain, virq + i, hwirq + i);
+       for (i = 0; i < nr_irqs; i++) {
+               ret = gic_irq_domain_map(domain, virq + i, hwirq + i);
+               if (ret)
+                       return ret;
+       }
 
        return 0;
 }
index 1b1df4f770bdefe0a16e0109624801f8af90f1f7..d3e7c43718b82b9e7fb2191dedadab1950c3ac7d 100644 (file)
@@ -361,6 +361,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
                if (likely(irqnr > 15 && irqnr < 1020)) {
                        if (static_key_true(&supports_deactivate))
                                writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
+                       isb();
                        handle_domain_irq(gic->domain, irqnr, regs);
                        continue;
                }
@@ -401,10 +402,12 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
                goto out;
 
        cascade_irq = irq_find_mapping(chip_data->domain, gic_irq);
-       if (unlikely(gic_irq < 32 || gic_irq > 1020))
+       if (unlikely(gic_irq < 32 || gic_irq > 1020)) {
                handle_bad_irq(desc);
-       else
+       } else {
+               isb();
                generic_handle_irq(cascade_irq);
+       }
 
  out:
        chained_irq_exit(chip, desc);
@@ -1027,8 +1030,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
        if (ret)
                return ret;
 
-       for (i = 0; i < nr_irqs; i++)
-               gic_irq_domain_map(domain, virq + i, hwirq + i);
+       for (i = 0; i < nr_irqs; i++) {
+               ret = gic_irq_domain_map(domain, virq + i, hwirq + i);
+               if (ret)
+                       return ret;
+       }
 
        return 0;
 }
index 78fc5d5e90514353b258658da350a85c408b89db..92e6570b11435e7e4dade7aa433231008c82b294 100644 (file)
@@ -26,7 +26,7 @@
 
 #define FSM_TIMER_DEBUG 0
 
-void
+int
 mISDN_FsmNew(struct Fsm *fsm,
             struct FsmNode *fnlist, int fncount)
 {
@@ -34,6 +34,8 @@ mISDN_FsmNew(struct Fsm *fsm,
 
        fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count *
                                  fsm->event_count, GFP_KERNEL);
+       if (fsm->jumpmatrix == NULL)
+               return -ENOMEM;
 
        for (i = 0; i < fncount; i++)
                if ((fnlist[i].state >= fsm->state_count) ||
@@ -45,6 +47,7 @@ mISDN_FsmNew(struct Fsm *fsm,
                } else
                        fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
                                        fnlist[i].state] = (FSMFNPTR) fnlist[i].routine;
+       return 0;
 }
 EXPORT_SYMBOL(mISDN_FsmNew);
 
index 928f5be192c1fd4a5c8197160efb9dad21e1141d..e1def84902212e1637cf96f0c9cefb8c3950edbd 100644 (file)
@@ -55,7 +55,7 @@ struct FsmTimer {
        void *arg;
 };
 
-extern void mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
+extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
 extern void mISDN_FsmFree(struct Fsm *);
 extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
 extern void mISDN_FsmChangeState(struct FsmInst *, int);
index bebc57b72138e721aa5a290482ae46e748aac2d2..3192b0eb39445435d7b38c0f914bded7c93b2fac 100644 (file)
@@ -414,8 +414,7 @@ l1_init(u_int *deb)
        l1fsm_s.event_count = L1_EVENT_COUNT;
        l1fsm_s.strEvent = strL1Event;
        l1fsm_s.strState = strL1SState;
-       mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
-       return 0;
+       return mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
 }
 
 void
index 7243a6746f8b099d79d3221def6dcfcf138a6f51..9ff0903a0e89fb2f4f7373e1ef4d1d1663934b36 100644 (file)
@@ -2247,15 +2247,26 @@ static struct Bprotocol X75SLP = {
 int
 Isdnl2_Init(u_int *deb)
 {
+       int res;
        debug = deb;
        mISDN_register_Bprotocol(&X75SLP);
        l2fsm.state_count = L2_STATE_COUNT;
        l2fsm.event_count = L2_EVENT_COUNT;
        l2fsm.strEvent = strL2Event;
        l2fsm.strState = strL2State;
-       mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList));
-       TEIInit(deb);
+       res = mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList));
+       if (res)
+               goto error;
+       res = TEIInit(deb);
+       if (res)
+               goto error_fsm;
        return 0;
+
+error_fsm:
+       mISDN_FsmFree(&l2fsm);
+error:
+       mISDN_unregister_Bprotocol(&X75SLP);
+       return res;
 }
 
 void
index 908127efccf8ceb94ef2ab1ed7df4b17b26ce5b9..12d9e5f4beb1f81c5aa5e5af81bc9aca61c21668 100644 (file)
@@ -1387,23 +1387,37 @@ create_teimanager(struct mISDNdevice *dev)
 
 int TEIInit(u_int *deb)
 {
+       int res;
        debug = deb;
        teifsmu.state_count = TEI_STATE_COUNT;
        teifsmu.event_count = TEI_EVENT_COUNT;
        teifsmu.strEvent = strTeiEvent;
        teifsmu.strState = strTeiState;
-       mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser));
+       res = mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser));
+       if (res)
+               goto error;
        teifsmn.state_count = TEI_STATE_COUNT;
        teifsmn.event_count = TEI_EVENT_COUNT;
        teifsmn.strEvent = strTeiEvent;
        teifsmn.strState = strTeiState;
-       mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet));
+       res = mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet));
+       if (res)
+               goto error_smn;
        deactfsm.state_count =  DEACT_STATE_COUNT;
        deactfsm.event_count = DEACT_EVENT_COUNT;
        deactfsm.strEvent = strDeactEvent;
        deactfsm.strState = strDeactState;
-       mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList));
+       res = mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList));
+       if (res)
+               goto error_deact;
        return 0;
+
+error_deact:
+       mISDN_FsmFree(&teifsmn);
+error_smn:
+       mISDN_FsmFree(&teifsmu);
+error:
+       return res;
 }
 
 void TEIFree(void)
index c99634612fc408fbc97df9c7c8ef8e028efe2fad..b01e458d31e94ce9eba98b9300366121de550619 100644 (file)
@@ -7996,7 +7996,7 @@ bool md_write_start(struct mddev *mddev, struct bio *bi)
        if (mddev->safemode == 1)
                mddev->safemode = 0;
        /* sync_checkers is always 0 when writes_pending is in per-cpu mode */
-       if (mddev->in_sync || !mddev->sync_checkers) {
+       if (mddev->in_sync || mddev->sync_checkers) {
                spin_lock(&mddev->lock);
                if (mddev->in_sync) {
                        mddev->in_sync = 0;
@@ -8656,6 +8656,9 @@ void md_check_recovery(struct mddev *mddev)
        if (mddev_trylock(mddev)) {
                int spares = 0;
 
+               if (!mddev->external && mddev->safemode == 1)
+                       mddev->safemode = 0;
+
                if (mddev->ro) {
                        struct md_rdev *rdev;
                        if (!mddev->external && mddev->in_sync)
index bfa1e907c472e49855f9e0abb4c307cd45514d4d..2dcbafa8e66ca7f5418fce8434fe9674977f0832 100644 (file)
@@ -236,9 +236,10 @@ struct r5l_io_unit {
        bool need_split_bio;
        struct bio *split_bio;
 
-       unsigned int has_flush:1;      /* include flush request */
-       unsigned int has_fua:1;        /* include fua request */
-       unsigned int has_null_flush:1; /* include empty flush request */
+       unsigned int has_flush:1;               /* include flush request */
+       unsigned int has_fua:1;                 /* include fua request */
+       unsigned int has_null_flush:1;          /* include null flush request */
+       unsigned int has_flush_payload:1;       /* include flush payload  */
        /*
         * io isn't sent yet, flush/fua request can only be submitted till it's
         * the first IO in running_ios list
@@ -571,6 +572,8 @@ static void r5l_log_endio(struct bio *bio)
        struct r5l_io_unit *io_deferred;
        struct r5l_log *log = io->log;
        unsigned long flags;
+       bool has_null_flush;
+       bool has_flush_payload;
 
        if (bio->bi_status)
                md_error(log->rdev->mddev, log->rdev);
@@ -580,6 +583,16 @@ static void r5l_log_endio(struct bio *bio)
 
        spin_lock_irqsave(&log->io_list_lock, flags);
        __r5l_set_io_unit_state(io, IO_UNIT_IO_END);
+
+       /*
+        * if the io doesn't not have null_flush or flush payload,
+        * it is not safe to access it after releasing io_list_lock.
+        * Therefore, it is necessary to check the condition with
+        * the lock held.
+        */
+       has_null_flush = io->has_null_flush;
+       has_flush_payload = io->has_flush_payload;
+
        if (log->need_cache_flush && !list_empty(&io->stripe_list))
                r5l_move_to_end_ios(log);
        else
@@ -600,19 +613,23 @@ static void r5l_log_endio(struct bio *bio)
        if (log->need_cache_flush)
                md_wakeup_thread(log->rdev->mddev->thread);
 
-       if (io->has_null_flush) {
+       /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */
+       if (has_null_flush) {
                struct bio *bi;
 
                WARN_ON(bio_list_empty(&io->flush_barriers));
                while ((bi = bio_list_pop(&io->flush_barriers)) != NULL) {
                        bio_endio(bi);
-                       atomic_dec(&io->pending_stripe);
+                       if (atomic_dec_and_test(&io->pending_stripe)) {
+                               __r5l_stripe_write_finished(io);
+                               return;
+                       }
                }
        }
-
-       /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */
-       if (atomic_read(&io->pending_stripe) == 0)
-               __r5l_stripe_write_finished(io);
+       /* decrease pending_stripe for flush payload */
+       if (has_flush_payload)
+               if (atomic_dec_and_test(&io->pending_stripe))
+                       __r5l_stripe_write_finished(io);
 }
 
 static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io)
@@ -881,6 +898,11 @@ static void r5l_append_flush_payload(struct r5l_log *log, sector_t sect)
        payload->size = cpu_to_le32(sizeof(__le64));
        payload->flush_stripes[0] = cpu_to_le64(sect);
        io->meta_offset += meta_size;
+       /* multiple flush payloads count as one pending_stripe */
+       if (!io->has_flush_payload) {
+               io->has_flush_payload = 1;
+               atomic_inc(&io->pending_stripe);
+       }
        mutex_unlock(&log->io_mutex);
 }
 
@@ -2540,23 +2562,32 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
  */
 int r5c_journal_mode_set(struct mddev *mddev, int mode)
 {
-       struct r5conf *conf = mddev->private;
-       struct r5l_log *log = conf->log;
-
-       if (!log)
-               return -ENODEV;
+       struct r5conf *conf;
+       int err;
 
        if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH ||
            mode > R5C_JOURNAL_MODE_WRITE_BACK)
                return -EINVAL;
 
+       err = mddev_lock(mddev);
+       if (err)
+               return err;
+       conf = mddev->private;
+       if (!conf || !conf->log) {
+               mddev_unlock(mddev);
+               return -ENODEV;
+       }
+
        if (raid5_calc_degraded(conf) > 0 &&
-           mode == R5C_JOURNAL_MODE_WRITE_BACK)
+           mode == R5C_JOURNAL_MODE_WRITE_BACK) {
+               mddev_unlock(mddev);
                return -EINVAL;
+       }
 
        mddev_suspend(mddev);
        conf->log->r5c_journal_mode = mode;
        mddev_resume(mddev);
+       mddev_unlock(mddev);
 
        pr_debug("md/raid:%s: setting r5c cache mode to %d: %s\n",
                 mdname(mddev), mode, r5c_journal_mode_str[mode]);
index 99e644cda4d13db301b713a5752788c0f646dfa1..ebf69ff48ae2656594b0840fb7bd8a917e159406 100644 (file)
@@ -72,7 +72,7 @@ struct atmel_smc_timing_xlate {
        { .name = nm, .converter = atmel_smc_cs_conf_set_pulse, .shift = pos}
 
 #define ATMEL_SMC_CYCLE_XLATE(nm, pos) \
-       { .name = nm, .converter = atmel_smc_cs_conf_set_setup, .shift = pos}
+       { .name = nm, .converter = atmel_smc_cs_conf_set_cycle, .shift = pos}
 
 static void at91sam9_ebi_get_config(struct atmel_ebi_dev *ebid,
                                    struct atmel_ebi_dev_config *conf)
@@ -120,12 +120,14 @@ static int atmel_ebi_xslate_smc_timings(struct atmel_ebi_dev *ebid,
        if (!ret) {
                required = true;
                ncycles = DIV_ROUND_UP(val, clk_period_ns);
-               if (ncycles > ATMEL_SMC_MODE_TDF_MAX ||
-                   ncycles < ATMEL_SMC_MODE_TDF_MIN) {
+               if (ncycles > ATMEL_SMC_MODE_TDF_MAX) {
                        ret = -EINVAL;
                        goto out;
                }
 
+               if (ncycles < ATMEL_SMC_MODE_TDF_MIN)
+                       ncycles = ATMEL_SMC_MODE_TDF_MIN;
+
                smcconf->mode |= ATMEL_SMC_MODE_TDF(ncycles);
        }
 
@@ -263,7 +265,7 @@ static int atmel_ebi_xslate_smc_config(struct atmel_ebi_dev *ebid,
        }
 
        ret = atmel_ebi_xslate_smc_timings(ebid, np, &conf->smcconf);
-       if (ret)
+       if (ret < 0)
                return -EINVAL;
 
        if ((ret > 0 && !required) || (!ret && required)) {
index 4afbc412f95933173f04fbb02e1c1b590cb495ec..8f2d152a78b8a05be318d3433097976ea96dade6 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <soc/mediatek/smi.h>
 #include <dt-bindings/memory/mt2701-larb-port.h>
 
+/* mt8173 */
 #define SMI_LARB_MMU_EN                0xf00
+
+/* mt2701 */
 #define REG_SMI_SECUR_CON_BASE         0x5c0
 
 /* every register control 8 port, register offset 0x4 */
 /* mt2701 domain should be set to 3 */
 #define SMI_SECUR_CON_VAL_DOMAIN(id)   (0x3 << ((((id) & 0x7) << 2) + 1))
 
+/* mt2712 */
+#define SMI_LARB_NONSEC_CON(id)        (0x380 + ((id) * 4))
+#define F_MMU_EN               BIT(0)
+
 struct mtk_smi_larb_gen {
+       bool need_larbid;
        int port_in_larb[MTK_LARB_NR_MAX + 1];
        void (*config_port)(struct device *);
 };
@@ -148,6 +157,15 @@ mtk_smi_larb_bind(struct device *dev, struct device *master, void *data)
        struct mtk_smi_iommu *smi_iommu = data;
        unsigned int         i;
 
+       if (larb->larb_gen->need_larbid) {
+               larb->mmu = &smi_iommu->larb_imu[larb->larbid].mmu;
+               return 0;
+       }
+
+       /*
+        * If there is no larbid property, Loop to find the corresponding
+        * iommu information.
+        */
        for (i = 0; i < smi_iommu->larb_nr; i++) {
                if (dev == smi_iommu->larb_imu[i].dev) {
                        /* The 'mmu' may be updated in iommu-attach/detach. */
@@ -158,13 +176,32 @@ mtk_smi_larb_bind(struct device *dev, struct device *master, void *data)
        return -ENODEV;
 }
 
-static void mtk_smi_larb_config_port(struct device *dev)
+static void mtk_smi_larb_config_port_mt2712(struct device *dev)
 {
        struct mtk_smi_larb *larb = dev_get_drvdata(dev);
+       u32 reg;
+       int i;
 
-       writel(*larb->mmu, larb->base + SMI_LARB_MMU_EN);
+       /*
+        * larb 8/9 is the bdpsys larb, the iommu_en is enabled defaultly.
+        * Don't need to set it again.
+        */
+       if (larb->larbid == 8 || larb->larbid == 9)
+               return;
+
+       for_each_set_bit(i, (unsigned long *)larb->mmu, 32) {
+               reg = readl_relaxed(larb->base + SMI_LARB_NONSEC_CON(i));
+               reg |= F_MMU_EN;
+               writel(reg, larb->base + SMI_LARB_NONSEC_CON(i));
+       }
 }
 
+static void mtk_smi_larb_config_port_mt8173(struct device *dev)
+{
+       struct mtk_smi_larb *larb = dev_get_drvdata(dev);
+
+       writel(*larb->mmu, larb->base + SMI_LARB_MMU_EN);
+}
 
 static void mtk_smi_larb_config_port_gen1(struct device *dev)
 {
@@ -210,10 +247,11 @@ static const struct component_ops mtk_smi_larb_component_ops = {
 
 static const struct mtk_smi_larb_gen mtk_smi_larb_mt8173 = {
        /* mt8173 do not need the port in larb */
-       .config_port = mtk_smi_larb_config_port,
+       .config_port = mtk_smi_larb_config_port_mt8173,
 };
 
 static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = {
+       .need_larbid = true,
        .port_in_larb = {
                LARB0_PORT_OFFSET, LARB1_PORT_OFFSET,
                LARB2_PORT_OFFSET, LARB3_PORT_OFFSET
@@ -221,6 +259,11 @@ static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = {
        .config_port = mtk_smi_larb_config_port_gen1,
 };
 
+static const struct mtk_smi_larb_gen mtk_smi_larb_mt2712 = {
+       .need_larbid = true,
+       .config_port = mtk_smi_larb_config_port_mt2712,
+};
+
 static const struct of_device_id mtk_smi_larb_of_ids[] = {
        {
                .compatible = "mediatek,mt8173-smi-larb",
@@ -230,6 +273,10 @@ static const struct of_device_id mtk_smi_larb_of_ids[] = {
                .compatible = "mediatek,mt2701-smi-larb",
                .data = &mtk_smi_larb_mt2701
        },
+       {
+               .compatible = "mediatek,mt2712-smi-larb",
+               .data = &mtk_smi_larb_mt2712
+       },
        {}
 };
 
@@ -240,20 +287,13 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct device_node *smi_node;
        struct platform_device *smi_pdev;
-       const struct of_device_id *of_id;
-
-       if (!dev->pm_domain)
-               return -EPROBE_DEFER;
-
-       of_id = of_match_node(mtk_smi_larb_of_ids, pdev->dev.of_node);
-       if (!of_id)
-               return -EINVAL;
+       int err;
 
        larb = devm_kzalloc(dev, sizeof(*larb), GFP_KERNEL);
        if (!larb)
                return -ENOMEM;
 
-       larb->larb_gen = of_id->data;
+       larb->larb_gen = of_device_get_match_data(dev);
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        larb->base = devm_ioremap_resource(dev, res);
        if (IS_ERR(larb->base))
@@ -268,6 +308,15 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
                return PTR_ERR(larb->smi.clk_smi);
        larb->smi.dev = dev;
 
+       if (larb->larb_gen->need_larbid) {
+               err = of_property_read_u32(dev->of_node, "mediatek,larb-id",
+                                          &larb->larbid);
+               if (err) {
+                       dev_err(dev, "missing larbid property\n");
+                       return err;
+               }
+       }
+
        smi_node = of_parse_phandle(dev->of_node, "mediatek,smi", 0);
        if (!smi_node)
                return -EINVAL;
@@ -275,6 +324,8 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
        smi_pdev = of_find_device_by_node(smi_node);
        of_node_put(smi_node);
        if (smi_pdev) {
+               if (!platform_get_drvdata(smi_pdev))
+                       return -EPROBE_DEFER;
                larb->smi_common_dev = &smi_pdev->dev;
        } else {
                dev_err(dev, "Failed to get the smi_common device\n");
@@ -311,6 +362,10 @@ static const struct of_device_id mtk_smi_common_of_ids[] = {
                .compatible = "mediatek,mt2701-smi-common",
                .data = (void *)MTK_SMI_GEN1
        },
+       {
+               .compatible = "mediatek,mt2712-smi-common",
+               .data = (void *)MTK_SMI_GEN2
+       },
        {}
 };
 
@@ -319,11 +374,8 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct mtk_smi *common;
        struct resource *res;
-       const struct of_device_id *of_id;
        enum mtk_smi_gen smi_gen;
-
-       if (!dev->pm_domain)
-               return -EPROBE_DEFER;
+       int ret;
 
        common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL);
        if (!common)
@@ -338,17 +390,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
        if (IS_ERR(common->clk_smi))
                return PTR_ERR(common->clk_smi);
 
-       of_id = of_match_node(mtk_smi_common_of_ids, pdev->dev.of_node);
-       if (!of_id)
-               return -EINVAL;
-
        /*
         * for mtk smi gen 1, we need to get the ao(always on) base to config
         * m4u port, and we need to enable the aync clock for transform the smi
         * clock into emi clock domain, but for mtk smi gen2, there's no smi ao
         * base.
         */
-       smi_gen = (enum mtk_smi_gen)of_id->data;
+       smi_gen = (enum mtk_smi_gen)of_device_get_match_data(dev);
        if (smi_gen == MTK_SMI_GEN1) {
                res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                common->smi_ao_base = devm_ioremap_resource(dev, res);
@@ -359,7 +407,9 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
                if (IS_ERR(common->clk_async))
                        return PTR_ERR(common->clk_async);
 
-               clk_prepare_enable(common->clk_async);
+               ret = clk_prepare_enable(common->clk_async);
+               if (ret)
+                       return ret;
        }
        pm_runtime_enable(dev);
        platform_set_drvdata(pdev, common);
@@ -403,4 +453,4 @@ err_unreg_smi:
        return ret;
 }
 
-subsys_initcall(mtk_smi_init);
+module_init(mtk_smi_init);
index 954cf0f66a31fa87b5be4e8cf4c4f81691980c0a..20cc0ea470fae22053584554e096ce31fad06275 100644 (file)
@@ -206,7 +206,7 @@ EXPORT_SYMBOL_GPL(atmel_smc_cs_conf_set_pulse);
  *          parameter
  *
  * This function encodes the @ncycles value as described in the datasheet
- * (section "SMC Pulse Register"), and then stores the result in the
+ * (section "SMC Cycle Register"), and then stores the result in the
  * @conf->setup field at @shift position.
  *
  * Returns -EINVAL if @shift is invalid, -ERANGE if @ncycles does not fit in
index fbe0f245ce8ee50943340de1c05d6490a3a13ced..fe1811523e4a7aac70e0498e7cd70fac55e2046b 100644 (file)
@@ -644,6 +644,9 @@ static const struct regmap_range da9062_aa_readable_ranges[] = {
        }, {
                .range_min = DA9062AA_VLDO1_B,
                .range_max = DA9062AA_VLDO4_B,
+       }, {
+               .range_min = DA9062AA_BBAT_CONT,
+               .range_max = DA9062AA_BBAT_CONT,
        }, {
                .range_min = DA9062AA_INTERFACE,
                .range_max = DA9062AA_CONFIG_E,
@@ -720,6 +723,9 @@ static const struct regmap_range da9062_aa_writeable_ranges[] = {
        }, {
                .range_min = DA9062AA_VLDO1_B,
                .range_max = DA9062AA_VLDO4_B,
+       }, {
+               .range_min = DA9062AA_BBAT_CONT,
+               .range_max = DA9062AA_BBAT_CONT,
        }, {
                .range_min = DA9062AA_GP_ID_0,
                .range_max = DA9062AA_GP_ID_19,
index f1bbfd389367ff4530137be199c4063c65f97f5c..80d1ec693d2d7d798b1f3315b3c205b529f9a382 100644 (file)
@@ -1371,12 +1371,46 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
         R1_CC_ERROR |          /* Card controller error */             \
         R1_ERROR)              /* General/unknown error */
 
-static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
+static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq)
 {
-       if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
-               cmd->error = -EIO;
+       u32 val;
 
-       return cmd->error;
+       /*
+        * Per the SD specification(physical layer version 4.10)[1],
+        * section 4.3.3, it explicitly states that "When the last
+        * block of user area is read using CMD18, the host should
+        * ignore OUT_OF_RANGE error that may occur even the sequence
+        * is correct". And JESD84-B51 for eMMC also has a similar
+        * statement on section 6.8.3.
+        *
+        * Multiple block read/write could be done by either predefined
+        * method, namely CMD23, or open-ending mode. For open-ending mode,
+        * we should ignore the OUT_OF_RANGE error as it's normal behaviour.
+        *
+        * However the spec[1] doesn't tell us whether we should also
+        * ignore that for predefined method. But per the spec[1], section
+        * 4.15 Set Block Count Command, it says"If illegal block count
+        * is set, out of range error will be indicated during read/write
+        * operation (For example, data transfer is stopped at user area
+        * boundary)." In another word, we could expect a out of range error
+        * in the response for the following CMD18/25. And if argument of
+        * CMD23 + the argument of CMD18/25 exceed the max number of blocks,
+        * we could also expect to get a -ETIMEDOUT or any error number from
+        * the host drivers due to missing data response(for write)/data(for
+        * read), as the cards will stop the data transfer by itself per the
+        * spec. So we only need to check R1_OUT_OF_RANGE for open-ending mode.
+        */
+
+       if (!brq->stop.error) {
+               bool oor_with_open_end;
+               /* If there is no error yet, check R1 response */
+
+               val = brq->stop.resp[0] & CMD_ERRORS;
+               oor_with_open_end = val & R1_OUT_OF_RANGE && !brq->mrq.sbc;
+
+               if (val && !oor_with_open_end)
+                       brq->stop.error = -EIO;
+       }
 }
 
 static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
@@ -1400,8 +1434,11 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
         * stop.error indicates a problem with the stop command.  Data
         * may have been transferred, or may still be transferring.
         */
-       if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) ||
-           brq->data.error) {
+
+       mmc_blk_eval_resp_error(brq);
+
+       if (brq->sbc.error || brq->cmd.error ||
+           brq->stop.error || brq->data.error) {
                switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
                case ERR_RETRY:
                        return MMC_BLK_RETRY;
index 2c8baa0c2c4e11f2b5d1c39d4c3ad795d634135a..ceec21bd30c4fc5c49ad4c4bdbfe9bd031005809 100644 (file)
@@ -1364,7 +1364,18 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
        ret = atmel_smc_cs_conf_set_timing(smcconf,
                                           ATMEL_HSMC_TIMINGS_TADL_SHIFT,
                                           ncycles);
-       if (ret)
+       /*
+        * Version 4 of the ONFI spec mandates that tADL be at least 400
+        * nanoseconds, but, depending on the master clock rate, 400 ns may not
+        * fit in the tADL field of the SMC reg. We need to relax the check and
+        * accept the -ERANGE return code.
+        *
+        * Note that previous versions of the ONFI spec had a lower tADL_min
+        * (100 or 200 ns). It's not clear why this timing constraint got
+        * increased but it seems most NANDs are fine with values lower than
+        * 400ns, so we should be safe.
+        */
+       if (ret && ret != -ERANGE)
                return ret;
 
        ncycles = DIV_ROUND_UP(conf->timings.sdr.tAR_min, mckperiodps);
index 03a0d057bf2f80b3ea4c3f397eb1f607697aad3c..e4211c3cc49b2ac054a080fd34d83db56f9556da 100644 (file)
@@ -2373,6 +2373,7 @@ static int __init ns_init_module(void)
         return 0;
 
 err_exit:
+       nandsim_debugfs_remove(nand);
        free_nandsim(nand);
        nand_release(nsmtd);
        for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)
index 9bee6c1c70cca33941ae8db8002d69e760693bac..fc63992ab0e0ad3300aa9a8d991fc107788ae780 100644 (file)
@@ -1569,7 +1569,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        new_slave->delay = 0;
        new_slave->link_failure_count = 0;
 
-       if (bond_update_speed_duplex(new_slave))
+       if (bond_update_speed_duplex(new_slave) &&
+           bond_needs_speed_duplex(bond))
                new_slave->link = BOND_LINK_DOWN;
 
        new_slave->last_rx = jiffies -
@@ -2140,11 +2141,13 @@ static void bond_miimon_commit(struct bonding *bond)
                        continue;
 
                case BOND_LINK_UP:
-                       if (bond_update_speed_duplex(slave)) {
+                       if (bond_update_speed_duplex(slave) &&
+                           bond_needs_speed_duplex(bond)) {
                                slave->link = BOND_LINK_DOWN;
-                               netdev_warn(bond->dev,
-                                           "failed to get link speed/duplex for %s\n",
-                                           slave->dev->name);
+                               if (net_ratelimit())
+                                       netdev_warn(bond->dev,
+                                                   "failed to get link speed/duplex for %s\n",
+                                                   slave->dev->name);
                                continue;
                        }
                        bond_set_slave_link_state(slave, BOND_LINK_UP,
index ef4be781fd054696edac7c494cf713f0dd5f3d4e..09ea62ee96d38b3d99bb48cbd0f72dcc715f8315 100644 (file)
@@ -529,6 +529,7 @@ enum {                                 /* adapter flags */
        USING_SOFT_PARAMS  = (1 << 6),
        MASTER_PF          = (1 << 7),
        FW_OFLD_CONN       = (1 << 9),
+       ROOT_NO_RELAXED_ORDERING = (1 << 10),
 };
 
 enum {
index e403fa18f1b15e570748b2136ae1bf8b54d14afb..33bb8678833adc6f83551d992f201f6314e68762 100644 (file)
@@ -4654,11 +4654,6 @@ static void print_port_info(const struct net_device *dev)
                    dev->name, adap->params.vpd.id, adap->name, buf);
 }
 
-static void enable_pcie_relaxed_ordering(struct pci_dev *dev)
-{
-       pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN);
-}
-
 /*
  * Free the following resources:
  * - memory used for tables
@@ -4908,7 +4903,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        pci_enable_pcie_error_reporting(pdev);
-       enable_pcie_relaxed_ordering(pdev);
        pci_set_master(pdev);
        pci_save_state(pdev);
 
@@ -4947,6 +4941,23 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        adapter->msg_enable = DFLT_MSG_ENABLE;
        memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
 
+       /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
+        * Ingress Packet Data to Free List Buffers in order to allow for
+        * chipset performance optimizations between the Root Complex and
+        * Memory Controllers.  (Messages to the associated Ingress Queue
+        * notifying new Packet Placement in the Free Lists Buffers will be
+        * send without the Relaxed Ordering Attribute thus guaranteeing that
+        * all preceding PCIe Transaction Layer Packets will be processed
+        * first.)  But some Root Complexes have various issues with Upstream
+        * Transaction Layer Packets with the Relaxed Ordering Attribute set.
+        * The PCIe devices which under the Root Complexes will be cleared the
+        * Relaxed Ordering bit in the configuration space, So we check our
+        * PCIe configuration space to see if it's flagged with advice against
+        * using Relaxed Ordering.
+        */
+       if (!pcie_relaxed_ordering_enabled(pdev))
+               adapter->flags |= ROOT_NO_RELAXED_ORDERING;
+
        spin_lock_init(&adapter->stats_lock);
        spin_lock_init(&adapter->tid_release_lock);
        spin_lock_init(&adapter->win0_lock);
index ede12209f20be4573a5464de9e7f7a0da0088c31..4ef68f69b58c45322d65f414e06d068ade4ab22d 100644 (file)
@@ -2719,6 +2719,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
        struct fw_iq_cmd c;
        struct sge *s = &adap->sge;
        struct port_info *pi = netdev_priv(dev);
+       int relaxed = !(adap->flags & ROOT_NO_RELAXED_ORDERING);
 
        /* Size needs to be multiple of 16, including status entry. */
        iq->size = roundup(iq->size, 16);
@@ -2772,8 +2773,8 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 
                flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc);
                c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F |
-                                            FW_IQ_CMD_FL0FETCHRO_F |
-                                            FW_IQ_CMD_FL0DATARO_F |
+                                            FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
+                                            FW_IQ_CMD_FL0DATARO_V(relaxed) |
                                             FW_IQ_CMD_FL0PADEN_F);
                if (cong >= 0)
                        c.iqns_to_fl0congen |=
index 109bc630408b65b1dc67cedbaab00ce0601d2574..08c6ddb84a049ecc75f414a968dba78974d5837f 100644 (file)
@@ -408,6 +408,7 @@ enum { /* adapter flags */
        USING_MSI          = (1UL << 1),
        USING_MSIX         = (1UL << 2),
        QUEUES_BOUND       = (1UL << 3),
+       ROOT_NO_RELAXED_ORDERING = (1UL << 4),
 };
 
 /*
index ac7a150c54e9b4e93b751821eb09d80669eecc69..2b85b874fd0d2c96fadb4888b0bd4695628bf611 100644 (file)
@@ -2888,6 +2888,24 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
         */
        adapter->name = pci_name(pdev);
        adapter->msg_enable = DFLT_MSG_ENABLE;
+
+       /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
+        * Ingress Packet Data to Free List Buffers in order to allow for
+        * chipset performance optimizations between the Root Complex and
+        * Memory Controllers.  (Messages to the associated Ingress Queue
+        * notifying new Packet Placement in the Free Lists Buffers will be
+        * send without the Relaxed Ordering Attribute thus guaranteeing that
+        * all preceding PCIe Transaction Layer Packets will be processed
+        * first.)  But some Root Complexes have various issues with Upstream
+        * Transaction Layer Packets with the Relaxed Ordering Attribute set.
+        * The PCIe devices which under the Root Complexes will be cleared the
+        * Relaxed Ordering bit in the configuration space, So we check our
+        * PCIe configuration space to see if it's flagged with advice against
+        * using Relaxed Ordering.
+        */
+       if (!pcie_relaxed_ordering_enabled(pdev))
+               adapter->flags |= ROOT_NO_RELAXED_ORDERING;
+
        err = adap_init0(adapter);
        if (err)
                goto err_unmap_bar;
index e37dde2ba97f6d529177d475be2a6d001071de0b..05498e7f284034d86a8f8531de95cf7f59ec4890 100644 (file)
@@ -2205,6 +2205,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
        struct port_info *pi = netdev_priv(dev);
        struct fw_iq_cmd cmd, rpl;
        int ret, iqandst, flsz = 0;
+       int relaxed = !(adapter->flags & ROOT_NO_RELAXED_ORDERING);
 
        /*
         * If we're using MSI interrupts and we're not initializing the
@@ -2300,6 +2301,8 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
                        cpu_to_be32(
                                FW_IQ_CMD_FL0HOSTFCMODE_V(SGE_HOSTFCMODE_NONE) |
                                FW_IQ_CMD_FL0PACKEN_F |
+                               FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
+                               FW_IQ_CMD_FL0DATARO_V(relaxed) |
                                FW_IQ_CMD_FL0PADEN_F);
 
                /* In T6, for egress queue type FL there is internal overhead
index 09b9bc17bce998a99f360577a92a0211b552bf38..5fe5cdc5135776abb8fd4df748b0948520504b48 100644 (file)
@@ -432,7 +432,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
                /* Virtual PCI function needs to determine UAR page size from
                 * firmware. Only master PCI function can set the uar page size
                 */
-               if (enable_4k_uar)
+               if (enable_4k_uar || !dev->persist->num_vfs)
                        dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT;
                else
                        dev->uar_page_shift = PAGE_SHIFT;
@@ -2277,7 +2277,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
 
                dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1;
 
-               if (enable_4k_uar) {
+               if (enable_4k_uar || !dev->persist->num_vfs) {
                        init_hca.log_uar_sz = ilog2(dev->caps.num_uars) +
                                                    PAGE_SHIFT - DEFAULT_UAR_PAGE_SHIFT;
                        init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12;
index dd7fa9cf225ff3c9e60d6f62e3f7f17317f2ea52..b0837b58c3a1084e8261ff3bf6d6057c4d8e7f54 100644 (file)
@@ -115,14 +115,10 @@ nfp_flower_cmsg_portmod_rx(struct nfp_app *app, struct sk_buff *skb)
                return;
        }
 
-       if (link) {
+       if (link)
                netif_carrier_on(netdev);
-               rtnl_lock();
-               dev_set_mtu(netdev, be16_to_cpu(msg->mtu));
-               rtnl_unlock();
-       } else {
+       else
                netif_carrier_off(netdev);
-       }
        rcu_read_unlock();
 }
 
index 4631ca8b8eb2780865bc2eefae51ce5c5a61f5cf..9f77ce038a4a339260e0118bb6a9f61e60547870 100644 (file)
@@ -908,8 +908,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
        return NETDEV_TX_OK;
 
 err_unmap:
-       --f;
-       while (f >= 0) {
+       while (--f >= 0) {
                frag = &skb_shinfo(skb)->frags[f];
                dma_unmap_page(dp->dev, tx_ring->txbufs[wr_idx].dma_addr,
                               skb_frag_size(frag), DMA_TO_DEVICE);
index 66ff15d08bad4eb0a12e30e69547905789d15336..0a66389c06c2522a95ed8d6d8fdd04ce1762cf4d 100644 (file)
@@ -2311,7 +2311,7 @@ netxen_md_rdqueue(struct netxen_adapter *adapter,
                                 loop_cnt++) {
                NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id);
                read_addr = queueEntry->read_addr;
-               for (k = 0; k < read_cnt; k--) {
+               for (k = 0; k < read_cnt; k++) {
                        NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0,
                                                        &read_value);
                        *data_buff++ = read_value;
index c905971c5f3a2849262dcf3ce220de93e32e4bd2..990a63d7fcb7213fa5c5d6e40a10ec5102af892a 100644 (file)
@@ -938,7 +938,6 @@ enum efx_stats_action {
 static int efx_mcdi_mac_stats(struct efx_nic *efx,
                              enum efx_stats_action action, int clear)
 {
-       struct efx_ef10_nic_data *nic_data = efx->nic_data;
        MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
        int rc;
        int change = action == EFX_STATS_PULL ? 0 : 1;
@@ -960,7 +959,12 @@ static int efx_mcdi_mac_stats(struct efx_nic *efx,
                              MAC_STATS_IN_PERIODIC_NOEVENT, 1,
                              MAC_STATS_IN_PERIOD_MS, period);
        MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
-       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id);
+
+       if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) {
+               struct efx_ef10_nic_data *nic_data = efx->nic_data;
+
+               MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id);
+       }
 
        rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
                                NULL, 0, NULL);
index db157a47000c65fb588d3f1c5dfe21bbd20983fb..72ec711fcba242775feea3064bdcb69de6c1812e 100644 (file)
@@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev)
        struct stmmac_priv *priv = netdev_priv(ndev);
        struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
        struct device_node *mdio_node = priv->plat->mdio_node;
+       struct device *dev = ndev->dev.parent;
        int addr, found;
 
        if (!mdio_bus_data)
@@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev)
        else
                err = mdiobus_register(new_bus);
        if (err != 0) {
-               netdev_err(ndev, "Cannot register the MDIO bus\n");
+               dev_err(dev, "Cannot register the MDIO bus\n");
                goto bus_register_fail;
        }
 
@@ -285,14 +286,12 @@ int stmmac_mdio_register(struct net_device *ndev)
                        irq_str = irq_num;
                        break;
                }
-               netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n",
-                           phydev->phy_id, addr, irq_str, phydev_name(phydev),
-                           act ? " active" : "");
+               phy_attached_info(phydev);
                found = 1;
        }
 
        if (!found && !mdio_node) {
-               netdev_warn(ndev, "No PHY found\n");
+               dev_warn(dev, "No PHY found\n");
                mdiobus_unregister(new_bus);
                mdiobus_free(new_bus);
                return -ENODEV;
index 32ad87345f5798498584d8dcfbda2f9ac993e619..0a2c0a42283f780b947fcf52fcb4220e73f0fa2f 100644 (file)
@@ -1879,6 +1879,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 
 err_detach:
        tun_detach_all(dev);
+       /* register_netdevice() already called tun_free_netdev() */
+       goto err_free_dev;
+
 err_free_flow:
        tun_flow_uninit(tun);
        security_tun_dev_free_security(tun->security);
index d21258d277ce4bca965e588e537df507d4e23892..f1b60740e02080261d998686a28e27c9ee4ea8a2 100644 (file)
@@ -159,8 +159,10 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
 
        brcmf_feat_firmware_capabilities(ifp);
        memset(&gscan_cfg, 0, sizeof(gscan_cfg));
-       brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, "pfn_gscan_cfg",
-                                 &gscan_cfg, sizeof(gscan_cfg));
+       if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID)
+               brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN,
+                                         "pfn_gscan_cfg",
+                                         &gscan_cfg, sizeof(gscan_cfg));
        brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn");
        if (drvr->bus_if->wowl_supported)
                brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl");
index b4ecd1fe137489617ab477608e0152712db0f784..97208ce19f927685ce79b2b2321ee5b3086f7a3c 100644 (file)
@@ -154,7 +154,7 @@ static const struct iwl_tt_params iwl9000_tt_params = {
 const struct iwl_cfg iwl9160_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9160",
        .fw_name_pre = IWL9260A_FW_PRE,
-       .fw_name_pre_next_step = IWL9260B_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -165,7 +165,7 @@ const struct iwl_cfg iwl9160_2ac_cfg = {
 const struct iwl_cfg iwl9260_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9260",
        .fw_name_pre = IWL9260A_FW_PRE,
-       .fw_name_pre_next_step = IWL9260B_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -176,7 +176,7 @@ const struct iwl_cfg iwl9260_2ac_cfg = {
 const struct iwl_cfg iwl9270_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9270",
        .fw_name_pre = IWL9260A_FW_PRE,
-       .fw_name_pre_next_step = IWL9260B_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -186,8 +186,8 @@ const struct iwl_cfg iwl9270_2ac_cfg = {
 
 const struct iwl_cfg iwl9460_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9460",
-       .fw_name_pre = IWL9000_FW_PRE,
-       .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
+       .fw_name_pre = IWL9260A_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -198,8 +198,8 @@ const struct iwl_cfg iwl9460_2ac_cfg = {
 
 const struct iwl_cfg iwl9560_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9560",
-       .fw_name_pre = IWL9000_FW_PRE,
-       .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
+       .fw_name_pre = IWL9260A_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
index 0fa8c473f1e2738b8490e2555af1ae95319d96dd..c73a6438ce8fbcd12a8e12e359c5f7d25e66a76f 100644 (file)
@@ -328,6 +328,7 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
  * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger
  *     command size (command version 4) that supports toggling ACK TX
  *     power reduction.
+ * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload
  *
  * @NUM_IWL_UCODE_TLV_CAPA: number of bits used
  */
@@ -373,6 +374,7 @@ enum iwl_ucode_tlv_capa {
        IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG        = (__force iwl_ucode_tlv_capa_t)80,
        IWL_UCODE_TLV_CAPA_LQM_SUPPORT                  = (__force iwl_ucode_tlv_capa_t)81,
        IWL_UCODE_TLV_CAPA_TX_POWER_ACK                 = (__force iwl_ucode_tlv_capa_t)84,
+       IWL_UCODE_TLV_CAPA_MLME_OFFLOAD                 = (__force iwl_ucode_tlv_capa_t)96,
 
        NUM_IWL_UCODE_TLV_CAPA
 #ifdef __CHECKER__
index c52623cb7c2a1bc89d635f4406df70bc3101f340..d19c74827fbb6094147ab48fc266cd6dbbb15e28 100644 (file)
@@ -276,10 +276,10 @@ struct iwl_pwr_tx_backoff {
  * @fw_name_pre: Firmware filename prefix. The api version and extension
  *     (.ucode) will be added to filename before loading from disk. The
  *     filename is constructed as fw_name_pre<api>.ucode.
- * @fw_name_pre_next_step: same as @fw_name_pre, only for next step
+ * @fw_name_pre_b_or_c_step: same as @fw_name_pre, only for b or c steps
  *     (if supported)
- * @fw_name_pre_rf_next_step: same as @fw_name_pre_next_step, only for rf next
- *     step. Supported only in integrated solutions.
+ * @fw_name_pre_rf_next_step: same as @fw_name_pre_b_or_c_step, only for rf
+ *     next step. Supported only in integrated solutions.
  * @ucode_api_max: Highest version of uCode API supported by driver.
  * @ucode_api_min: Lowest version of uCode API supported by driver.
  * @max_inst_size: The maximal length of the fw inst section
@@ -330,7 +330,7 @@ struct iwl_cfg {
        /* params specific to an individual device within a device family */
        const char *name;
        const char *fw_name_pre;
-       const char *fw_name_pre_next_step;
+       const char *fw_name_pre_b_or_c_step;
        const char *fw_name_pre_rf_next_step;
        /* params not likely to change within a device family */
        const struct iwl_base_params *base_params;
index 6fdb5921e17f41846db6a4c7302d9248247d1c03..4e0f86fe0a6f0874a96d41ae257c9621a2f035ee 100644 (file)
@@ -216,8 +216,9 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
        const char *fw_pre_name;
 
        if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
-           CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP)
-               fw_pre_name = cfg->fw_name_pre_next_step;
+           (CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP ||
+            CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_C_STEP))
+               fw_pre_name = cfg->fw_name_pre_b_or_c_step;
        else if (drv->trans->cfg->integrated &&
                 CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP &&
                 cfg->fw_name_pre_rf_next_step)
index 5c08f4d40f6ac78fbdeb575e152742c9c0a3cef5..3ee6767392b61151efc774610223e2f6216d22f3 100644 (file)
@@ -785,7 +785,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                       int num_of_ch, __le32 *channels, u16 fw_mcc)
 {
        int ch_idx;
-       u16 ch_flags, prev_ch_flags = 0;
+       u16 ch_flags;
+       u32 reg_rule_flags, prev_reg_rule_flags = 0;
        const u8 *nvm_chan = cfg->ext_nvm ?
                             iwl_ext_nvm_channels : iwl_nvm_channels;
        struct ieee80211_regdomain *regd;
@@ -834,8 +835,11 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                        continue;
                }
 
+               reg_rule_flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx,
+                                                            ch_flags, cfg);
+
                /* we can't continue the same rule */
-               if (ch_idx == 0 || prev_ch_flags != ch_flags ||
+               if (ch_idx == 0 || prev_reg_rule_flags != reg_rule_flags ||
                    center_freq - prev_center_freq > 20) {
                        valid_rules++;
                        new_rule = true;
@@ -854,18 +858,17 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                rule->power_rule.max_eirp =
                        DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER);
 
-               rule->flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx,
-                                                         ch_flags, cfg);
+               rule->flags = reg_rule_flags;
 
                /* rely on auto-calculation to merge BW of contiguous chans */
                rule->flags |= NL80211_RRF_AUTO_BW;
                rule->freq_range.max_bandwidth_khz = 0;
 
-               prev_ch_flags = ch_flags;
                prev_center_freq = center_freq;
+               prev_reg_rule_flags = reg_rule_flags;
 
                IWL_DEBUG_DEV(dev, IWL_DL_LAR,
-                             "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x): Ad-Hoc %ssupported\n",
+                             "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x) reg_flags 0x%x: %s\n",
                              center_freq,
                              band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
                              CHECK_AND_PRINT_I(VALID),
@@ -877,10 +880,10 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                              CHECK_AND_PRINT_I(160MHZ),
                              CHECK_AND_PRINT_I(INDOOR_ONLY),
                              CHECK_AND_PRINT_I(GO_CONCURRENT),
-                             ch_flags,
+                             ch_flags, reg_rule_flags,
                              ((ch_flags & NVM_CHANNEL_ACTIVE) &&
                               !(ch_flags & NVM_CHANNEL_RADAR))
-                                        ? "" : "not ");
+                                        ? "Ad-Hoc" : "");
        }
 
        regd->n_reg_rules = valid_rules;
index 79e7a7a285dc960597e945ce7b80f96e729a86ad..82863e9273eb66ce9058a5974d2f35988290e1dc 100644 (file)
@@ -1275,8 +1275,10 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
 
                        entry = &wifi_pkg->package.elements[idx++];
                        if ((entry->type != ACPI_TYPE_INTEGER) ||
-                           (entry->integer.value > U8_MAX))
-                               return -EINVAL;
+                           (entry->integer.value > U8_MAX)) {
+                               ret = -EINVAL;
+                               goto out_free;
+                       }
 
                        mvm->geo_profiles[i].values[j] = entry->integer.value;
                }
index c7b1e58e33847a8250ab708695373a0817f85874..ce901be5fba87e3674f06b030cfae8759e063c3b 100644 (file)
@@ -2597,8 +2597,18 @@ static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm *mvm,
        spin_lock_bh(&mvm_sta->lock);
        for (i = 0; i <= IWL_MAX_TID_COUNT; i++) {
                tid_data = &mvm_sta->tid_data[i];
-               while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames)))
+
+               while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) {
+                       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+
+                       /*
+                        * The first deferred frame should've stopped the MAC
+                        * queues, so we should never get a second deferred
+                        * frame for the RA/TID.
+                        */
+                       iwl_mvm_start_mac_queues(mvm, info->hw_queue);
                        ieee80211_free_txskb(mvm->hw, skb);
+               }
        }
        spin_unlock_bh(&mvm_sta->lock);
 }
index 65beca3a457a19d2dcd804d01a590f7404e04f65..8999a1199d60d27bdec88d6c638feb85403c3ced 100644 (file)
@@ -1291,7 +1291,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
         * first index into rate scale table.
         */
        if (info->flags & IEEE80211_TX_STAT_AMPDU) {
-               rs_collect_tpc_data(mvm, lq_sta, curr_tbl, lq_rate.index,
+               rs_collect_tpc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index,
                                    info->status.ampdu_len,
                                    info->status.ampdu_ack_len,
                                    reduced_txp);
@@ -1312,7 +1312,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
                if (info->status.ampdu_ack_len == 0)
                        info->status.ampdu_len = 1;
 
-               rs_collect_tlc_data(mvm, lq_sta, curr_tbl, lq_rate.index,
+               rs_collect_tlc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index,
                                    info->status.ampdu_len,
                                    info->status.ampdu_ack_len);
 
@@ -1348,11 +1348,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
                                continue;
 
                        rs_collect_tpc_data(mvm, lq_sta, tmp_tbl,
-                                           lq_rate.index, 1,
+                                           tx_resp_rate.index, 1,
                                            i < retries ? 0 : legacy_success,
                                            reduced_txp);
                        rs_collect_tlc_data(mvm, lq_sta, tmp_tbl,
-                                           lq_rate.index, 1,
+                                           tx_resp_rate.index, 1,
                                            i < retries ? 0 : legacy_success);
                }
 
index f3e608196369a3885804b42331f442a16623e388..71c8b800ffa99874bd4120e59e2aa7f51212d2da 100644 (file)
@@ -636,9 +636,9 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
 
        baid_data = rcu_dereference(mvm->baid_map[baid]);
        if (!baid_data) {
-               WARN(!(reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN),
-                    "Received baid %d, but no data exists for this BAID\n",
-                    baid);
+               IWL_DEBUG_RX(mvm,
+                            "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
+                             baid, reorder);
                return false;
        }
 
@@ -759,7 +759,9 @@ static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm,
 
        data = rcu_dereference(mvm->baid_map[baid]);
        if (!data) {
-               WARN_ON(!(reorder_data & IWL_RX_MPDU_REORDER_BA_OLD_SN));
+               IWL_DEBUG_RX(mvm,
+                            "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
+                             baid, reorder_data);
                goto out;
        }
 
index ab66b4394dfc8ca2afc0cf1321f93f28f186d1cb..027ee5e72172c85f9eaa98f1fd1a26489ab74820 100644 (file)
@@ -121,7 +121,8 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
                .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color),
                .add_modify = update ? 1 : 0,
                .station_flags_msk = cpu_to_le32(STA_FLG_FAT_EN_MSK |
-                                                STA_FLG_MIMO_EN_MSK),
+                                                STA_FLG_MIMO_EN_MSK |
+                                                STA_FLG_RTS_MIMO_PROT),
                .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg),
        };
        int ret;
@@ -290,8 +291,8 @@ static void iwl_mvm_rx_agg_session_expired(unsigned long data)
                goto unlock;
 
        mvm_sta = iwl_mvm_sta_from_mac80211(sta);
-       ieee80211_stop_rx_ba_session_offl(mvm_sta->vif,
-                                         sta->addr, ba_data->tid);
+       ieee80211_rx_ba_timer_expired(mvm_sta->vif,
+                                     sta->addr, ba_data->tid);
 unlock:
        rcu_read_unlock();
 }
index 60360ed73f26165c890d0af3bac742b5669fb8d9..5fcc9dd6be56de52fa0a063969cf58011b8eb3d8 100644 (file)
@@ -185,8 +185,14 @@ static u16 iwl_mvm_tx_csum(struct iwl_mvm *mvm, struct sk_buff *skb,
        else
                udp_hdr(skb)->check = 0;
 
-       /* mac header len should include IV, size is in words */
-       if (info->control.hw_key)
+       /*
+        * mac header len should include IV, size is in words unless
+        * the IV is added by the firmware like in WEP.
+        * In new Tx API, the IV is always added by the firmware.
+        */
+       if (!iwl_mvm_has_new_tx_api(mvm) && info->control.hw_key &&
+           info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP40 &&
+           info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP104)
                mh_len += info->control.hw_key->iv_len;
        mh_len /= 2;
        offload_assist |= mh_len << TX_CMD_OFFLD_MH_SIZE;
@@ -1815,6 +1821,8 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
        struct iwl_mvm_tid_data *tid_data;
        struct iwl_mvm_sta *mvmsta;
 
+       ba_info.flags = IEEE80211_TX_STAT_AMPDU;
+
        if (iwl_mvm_has_new_tx_api(mvm)) {
                struct iwl_mvm_compressed_ba_notif *ba_res =
                        (void *)pkt->data;
index f16c1bb9bf94b6bef6bfb6ce2ff36c3faf771c00..84f4ba01e14fa2e84878dc75fda5d050e3500880 100644 (file)
@@ -510,9 +510,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
 
 /* 9000 Series */
        {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9460_2ac_cfg)},
@@ -527,10 +535,22 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
        {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)},
        {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)},
        {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)},
index 9a03c5871efe675015418e6f5e1ebd1745faaac0..f58d8e3053236ad4608e5552052214b0694a3a95 100644 (file)
@@ -924,10 +924,8 @@ out1:
                ntb_free_mw(nt, i);
 
        /* if there's an actual failure, we should just bail */
-       if (rc < 0) {
-               ntb_link_disable(ndev);
+       if (rc < 0)
                return;
-       }
 
 out:
        if (ntb_link_is_up(ndev, NULL, NULL) == 1)
@@ -1059,7 +1057,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
        int node;
        int rc, i;
 
-       mw_count = ntb_mw_count(ndev, PIDX);
+       mw_count = ntb_peer_mw_count(ndev);
 
        if (!ndev->ops->mw_set_trans) {
                dev_err(&ndev->dev, "Inbound MW based NTB API is required\n");
index f002bf48a08dbefd0602532bc6d2f1dbf4f68a3a..a69815c45ce6f2137d9f409bad0b8742fa530df4 100644 (file)
@@ -959,7 +959,7 @@ static int tool_probe(struct ntb_client *self, struct ntb_dev *ntb)
        tc->ntb = ntb;
        init_waitqueue_head(&tc->link_wq);
 
-       tc->mw_count = min(ntb_mw_count(tc->ntb, PIDX), MAX_MWS);
+       tc->mw_count = min(ntb_peer_mw_count(tc->ntb), MAX_MWS);
        for (i = 0; i < tc->mw_count; i++) {
                rc = tool_init_mw(tc, i);
                if (rc)
index 2e582a2409437bca7d603598290d023bd988c577..5f5cd306f76d05e8cb7351cb91403d7f9a554d9a 100644 (file)
@@ -794,7 +794,8 @@ static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts,
                int i;
 
                for (i = 0; i < ARRAY_SIZE(opt_tokens); i++) {
-                       if (opt_tokens[i].token & ~allowed_opts) {
+                       if ((opt_tokens[i].token & opts->mask) &&
+                           (opt_tokens[i].token & ~allowed_opts)) {
                                pr_warn("invalid parameter '%s'\n",
                                        opt_tokens[i].pattern);
                        }
index 74a124a062640ae77abb8554881e1a93222abd2d..925467b31a333940dc62d62c4c5f3376316e4120 100644 (file)
@@ -801,6 +801,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
                return;
        }
 
+       nvmeq->cqe_seen = 1;
        req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id);
        nvme_end_request(req, cqe->status, cqe->result);
 }
@@ -830,10 +831,8 @@ static void nvme_process_cq(struct nvme_queue *nvmeq)
                consumed++;
        }
 
-       if (consumed) {
+       if (consumed)
                nvme_ring_cq_doorbell(nvmeq);
-               nvmeq->cqe_seen = 1;
-       }
 }
 
 static irqreturn_t nvme_irq(int irq, void *data)
index 2d7a98ab53fbf2de131990b753b929fe31cd154b..a53bb6635b8378d00f7fb4d367a16170d81a846e 100644 (file)
@@ -199,12 +199,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
        copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1);
        copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE));
 
-       memset(id->mn, ' ', sizeof(id->mn));
-       strncpy((char *)id->mn, "Linux", sizeof(id->mn));
-
-       memset(id->fr, ' ', sizeof(id->fr));
-       strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr));
-
        id->rab = 6;
 
        /*
index 1b7f2520a20db7e151afe4a85a0e488fe0c85005..309c84aa7595b9b2ffab72c8a632c97f29def6d1 100644 (file)
@@ -394,7 +394,7 @@ nvmet_fc_free_ls_iodlist(struct nvmet_fc_tgtport *tgtport)
 static struct nvmet_fc_ls_iod *
 nvmet_fc_alloc_ls_iod(struct nvmet_fc_tgtport *tgtport)
 {
-       static struct nvmet_fc_ls_iod *iod;
+       struct nvmet_fc_ls_iod *iod;
        unsigned long flags;
 
        spin_lock_irqsave(&tgtport->lock, flags);
@@ -471,7 +471,7 @@ nvmet_fc_destroy_fcp_iodlist(struct nvmet_fc_tgtport *tgtport,
 static struct nvmet_fc_fcp_iod *
 nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue)
 {
-       static struct nvmet_fc_fcp_iod *fod;
+       struct nvmet_fc_fcp_iod *fod;
 
        lockdep_assert_held(&queue->qlock);
 
@@ -704,7 +704,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
 {
        struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport;
        struct nvmet_fc_fcp_iod *fod = queue->fod;
-       struct nvmet_fc_defer_fcp_req *deferfcp;
+       struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr;
        unsigned long flags;
        int i, writedataactive;
        bool disconnect;
@@ -735,7 +735,8 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
        }
 
        /* Cleanup defer'ed IOs in queue */
-       list_for_each_entry(deferfcp, &queue->avail_defer_list, req_list) {
+       list_for_each_entry_safe(deferfcp, tempptr, &queue->avail_defer_list,
+                               req_list) {
                list_del(&deferfcp->req_list);
                kfree(deferfcp);
        }
index 28c38c756f92858906ca2aee54a9c922522f9253..e0a28ea341fe95e84a866559dad8e317c8056401 100644 (file)
@@ -89,6 +89,7 @@ int of_dma_configure(struct device *dev, struct device_node *np)
        bool coherent;
        unsigned long offset;
        const struct iommu_ops *iommu;
+       u64 mask;
 
        /*
         * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
@@ -134,10 +135,9 @@ int of_dma_configure(struct device *dev, struct device_node *np)
         * Limit coherent and dma mask based on size and default mask
         * set by the driver.
         */
-       dev->coherent_dma_mask = min(dev->coherent_dma_mask,
-                                    DMA_BIT_MASK(ilog2(dma_addr + size)));
-       *dev->dma_mask = min((*dev->dma_mask),
-                            DMA_BIT_MASK(ilog2(dma_addr + size)));
+       mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1);
+       dev->coherent_dma_mask &= mask;
+       *dev->dma_mask &= mask;
 
        coherent = of_dma_is_coherent(np);
        dev_dbg(dev, "device is%sdma coherent\n",
index 5c63b920b4713eaf41954c4e8f0d041472c78b6d..ed92c1254cff473113f9b24e25a598a72871891d 100644 (file)
@@ -956,7 +956,7 @@ static int __init dino_probe(struct parisc_device *dev)
 
        dino_dev->hba.dev = dev;
        dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096);
-       dino_dev->hba.lmmio_space_offset = 0;   /* CPU addrs == bus addrs */
+       dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND;
        spin_lock_init(&dino_dev->dinosaur_pen);
        dino_dev->hba.iommu = ccio_get_iommu(dev);
 
index 253d92409bb3930b3348fd91037aa0df2355ce9c..2225afc1cbbb76a39c516230a58c8e8752b568f9 100644 (file)
@@ -538,12 +538,9 @@ msi_setup_entry(struct pci_dev *dev, int nvec, const struct irq_affinity *affd)
        struct msi_desc *entry;
        u16 control;
 
-       if (affd) {
+       if (affd)
                masks = irq_create_affinity_masks(nvec, affd);
-               if (!masks)
-                       dev_err(&dev->dev, "can't allocate MSI affinity masks for %d vectors\n",
-                               nvec);
-       }
+
 
        /* MSI Entry Initialization */
        entry = alloc_msi_entry(&dev->dev, nvec, masks);
@@ -679,12 +676,8 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base,
        struct msi_desc *entry;
        int ret, i;
 
-       if (affd) {
+       if (affd)
                masks = irq_create_affinity_masks(nvec, affd);
-               if (!masks)
-                       dev_err(&dev->dev, "can't allocate MSI-X affinity masks for %d vectors\n",
-                               nvec);
-       }
 
        for (i = 0, curmsk = masks; i < nvec; i++) {
                entry = alloc_msi_entry(&dev->dev, 1, curmsk);
index b4b7eab2940024024c46ead23d6b1c415fa146f7..fdf65a6c13f62558e887cd001f4c61ca2daef989 100644 (file)
@@ -514,7 +514,7 @@ EXPORT_SYMBOL(pci_find_resource);
  */
 struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev)
 {
-       struct pci_dev *bridge, *highest_pcie_bridge = NULL;
+       struct pci_dev *bridge, *highest_pcie_bridge = dev;
 
        bridge = pci_upstream_bridge(dev);
        while (bridge && pci_is_pcie(bridge)) {
index c31310db04047367c44b96ff6afa41a6b991bc28..e6a917b4acd3f3c63dff5d57b905ab093d7d0487 100644 (file)
@@ -1762,6 +1762,48 @@ static void pci_configure_extended_tags(struct pci_dev *dev)
                                         PCI_EXP_DEVCTL_EXT_TAG);
 }
 
+/**
+ * pcie_relaxed_ordering_enabled - Probe for PCIe relaxed ordering enable
+ * @dev: PCI device to query
+ *
+ * Returns true if the device has enabled relaxed ordering attribute.
+ */
+bool pcie_relaxed_ordering_enabled(struct pci_dev *dev)
+{
+       u16 v;
+
+       pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &v);
+
+       return !!(v & PCI_EXP_DEVCTL_RELAX_EN);
+}
+EXPORT_SYMBOL(pcie_relaxed_ordering_enabled);
+
+static void pci_configure_relaxed_ordering(struct pci_dev *dev)
+{
+       struct pci_dev *root;
+
+       /* PCI_EXP_DEVICE_RELAX_EN is RsvdP in VFs */
+       if (dev->is_virtfn)
+               return;
+
+       if (!pcie_relaxed_ordering_enabled(dev))
+               return;
+
+       /*
+        * For now, we only deal with Relaxed Ordering issues with Root
+        * Ports. Peer-to-Peer DMA is another can of worms.
+        */
+       root = pci_find_pcie_root_port(dev);
+       if (!root)
+               return;
+
+       if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) {
+               pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
+                                          PCI_EXP_DEVCTL_RELAX_EN);
+               dev_info(&dev->dev, "Disable Relaxed Ordering because the Root Port didn't support it\n");
+       }
+}
+
 static void pci_configure_device(struct pci_dev *dev)
 {
        struct hotplug_params hpp;
@@ -1769,6 +1811,7 @@ static void pci_configure_device(struct pci_dev *dev)
 
        pci_configure_mps(dev);
        pci_configure_extended_tags(dev);
+       pci_configure_relaxed_ordering(dev);
 
        memset(&hpp, 0, sizeof(hpp));
        ret = pci_get_hp_params(dev, &hpp);
index 6967c6b4cf6b017170619c285ee58feaa5975a5a..140760403f36a932b7d39eb73ae3eb96d76cab37 100644 (file)
@@ -4015,6 +4015,95 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6868, PCI_CLASS_NOT_DEFINED, 8,
 DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6869, PCI_CLASS_NOT_DEFINED, 8,
                              quirk_tw686x_class);
 
+/*
+ * Some devices have problems with Transaction Layer Packets with the Relaxed
+ * Ordering Attribute set.  Such devices should mark themselves and other
+ * Device Drivers should check before sending TLPs with RO set.
+ */
+static void quirk_relaxedordering_disable(struct pci_dev *dev)
+{
+       dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING;
+       dev_info(&dev->dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n");
+}
+
+/*
+ * Intel Xeon processors based on Broadwell/Haswell microarchitecture Root
+ * Complex has a Flow Control Credit issue which can cause performance
+ * problems with Upstream Transaction Layer Packets with Relaxed Ordering set.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f01, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f03, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f05, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f06, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f07, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f09, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0a, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0b, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0c, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0d, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0e, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f01, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f02, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f03, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f04, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f05, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f06, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f07, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f08, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f09, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0a, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0b, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0c, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0d, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0e, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+
+/*
+ * The AMD ARM A1100 (AKA "SEATTLE") SoC has a bug in its PCIe Root Complex
+ * where Upstream Transaction Layer Packets with the Relaxed Ordering
+ * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering
+ * set.  This is a violation of the PCIe 3.0 Transaction Ordering Rules
+ * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0
+ * November 10, 2010).  As a result, on this platform we can't use Relaxed
+ * Ordering for Upstream TLPs.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+
 /*
  * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same
  * values for the Attribute as were supplied in the header of the
index 4fac49e55d473e80c87eb932698a33383ffca04b..4b43aa62fbc789b049ecf05b3be7ec393dfa868d 100644 (file)
@@ -1301,7 +1301,6 @@ static void ds1307_clks_register(struct ds1307 *ds1307)
 static const struct regmap_config regmap_config = {
        .reg_bits = 8,
        .val_bits = 8,
-       .max_register = 0x12,
 };
 
 static int ds1307_probe(struct i2c_client *client,
index f4538d7a3016e2b1514df38c9e6e9b48939d6ce7..d145e0d9022755d476f8f48c22ea9c3a62377e28 100644 (file)
@@ -47,6 +47,17 @@ config SCSI_NETLINK
        default n
        depends on NET
 
+config SCSI_MQ_DEFAULT
+       bool "SCSI: use blk-mq I/O path by default"
+       depends on SCSI
+       ---help---
+         This option enables the new blk-mq based I/O path for SCSI
+         devices by default.  With the option the scsi_mod.use_blk_mq
+         module/boot option defaults to Y, without it to N, but it can
+         still be overridden either way.
+
+         If unsure say N.
+
 config SCSI_PROC_FS
        bool "legacy /proc/scsi/ support"
        depends on SCSI && PROC_FS
index 4591113c49de3af951908ed2257f6f5e88663b96..a1a2c71e162651f93d499c56e024e7073cc7fc79 100644 (file)
@@ -549,7 +549,9 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
        if ((le32_to_cpu(get_name_reply->status) == CT_OK)
         && (get_name_reply->data[0] != '\0')) {
                char *sp = get_name_reply->data;
-               sp[sizeof(((struct aac_get_name_resp *)NULL)->data)] = '\0';
+               int data_size = FIELD_SIZEOF(struct aac_get_name_resp, data);
+
+               sp[data_size - 1] = '\0';
                while (*sp == ' ')
                        ++sp;
                if (*sp) {
@@ -579,12 +581,15 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
 static int aac_get_container_name(struct scsi_cmnd * scsicmd)
 {
        int status;
+       int data_size;
        struct aac_get_name *dinfo;
        struct fib * cmd_fibcontext;
        struct aac_dev * dev;
 
        dev = (struct aac_dev *)scsicmd->device->host->hostdata;
 
+       data_size = FIELD_SIZEOF(struct aac_get_name_resp, data);
+
        cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd);
 
        aac_fib_init(cmd_fibcontext);
@@ -593,7 +598,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
        dinfo->command = cpu_to_le32(VM_ContainerConfig);
        dinfo->type = cpu_to_le32(CT_READ_NAME);
        dinfo->cid = cpu_to_le32(scmd_id(scsicmd));
-       dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
+       dinfo->count = cpu_to_le32(data_size - 1);
 
        status = aac_fib_send(ContainerCommand,
                  cmd_fibcontext,
index d31a9bc2ba69abdcf6cd6c6c8e6d99229ae50e4a..ee2667e20e4239f9129ebe21e7983a2428065b88 100644 (file)
@@ -2274,7 +2274,7 @@ struct aac_get_name_resp {
        __le32          parm3;
        __le32          parm4;
        __le32          parm5;
-       u8              data[16];
+       u8              data[17];
 };
 
 #define CT_CID_TO_32BITS_UID 165
index 2029ad225121162bddfec4ffcce7e38a940385f3..5be0086142cac6991598cd9099522212709a216c 100644 (file)
@@ -3845,8 +3845,10 @@ csio_hw_start(struct csio_hw *hw)
 
        if (csio_is_hw_ready(hw))
                return 0;
-       else
+       else if (csio_match_state(hw, csio_hws_uninit))
                return -EINVAL;
+       else
+               return -ENODEV;
 }
 
 int
index ea0c31086cc6b8b44517c8fcd34a44fb6c93fad9..dcd074169aa9b7794850c7034a1208353ba17266 100644 (file)
@@ -969,10 +969,14 @@ static int csio_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        pci_set_drvdata(pdev, hw);
 
-       if (csio_hw_start(hw) != 0) {
-               dev_err(&pdev->dev,
-                       "Failed to start FW, continuing in debug mode.\n");
-               return 0;
+       rv = csio_hw_start(hw);
+       if (rv) {
+               if (rv == -EINVAL) {
+                       dev_err(&pdev->dev,
+                               "Failed to start FW, continuing in debug mode.\n");
+                       return 0;
+               }
+               goto err_lnode_exit;
        }
 
        sprintf(hw->fwrev_str, "%u.%u.%u.%u\n",
index a69a9ac836f5d13c37d5220ecbb2711d588c4c35..1d02cf9fe06c5e941e5d1a76254f86ce658fc04b 100644 (file)
@@ -1635,6 +1635,9 @@ static int init_act_open(struct cxgbi_sock *csk)
                goto rel_resource;
        }
 
+       if (!(n->nud_state & NUD_VALID))
+               neigh_event_send(n, NULL);
+
        csk->atid = cxgb4_alloc_atid(lldi->tids, csk);
        if (csk->atid < 0) {
                pr_err("%s, NO atid available.\n", ndev->name);
index b0c68d24db011ba9465dd31a41c05acd4f13c283..da5bdbdcce527262489cae939761b9cf1834eeb0 100644 (file)
@@ -3351,6 +3351,16 @@ static void ipr_worker_thread(struct work_struct *work)
                return;
        }
 
+       if (ioa_cfg->scsi_unblock) {
+               ioa_cfg->scsi_unblock = 0;
+               ioa_cfg->scsi_blocked = 0;
+               spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
+               scsi_unblock_requests(ioa_cfg->host);
+               spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
+               if (ioa_cfg->scsi_blocked)
+                       scsi_block_requests(ioa_cfg->host);
+       }
+
        if (!ioa_cfg->scan_enabled) {
                spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
                return;
@@ -7211,9 +7221,8 @@ static int ipr_ioa_bringdown_done(struct ipr_cmnd *ipr_cmd)
        ENTER;
        if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
                ipr_trace;
-               spin_unlock_irq(ioa_cfg->host->host_lock);
-               scsi_unblock_requests(ioa_cfg->host);
-               spin_lock_irq(ioa_cfg->host->host_lock);
+               ioa_cfg->scsi_unblock = 1;
+               schedule_work(&ioa_cfg->work_q);
        }
 
        ioa_cfg->in_reset_reload = 0;
@@ -7287,13 +7296,7 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd)
        list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
        wake_up_all(&ioa_cfg->reset_wait_q);
 
-       spin_unlock(ioa_cfg->host->host_lock);
-       scsi_unblock_requests(ioa_cfg->host);
-       spin_lock(ioa_cfg->host->host_lock);
-
-       if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds)
-               scsi_block_requests(ioa_cfg->host);
-
+       ioa_cfg->scsi_unblock = 1;
        schedule_work(&ioa_cfg->work_q);
        LEAVE;
        return IPR_RC_JOB_RETURN;
@@ -9249,8 +9252,11 @@ static void _ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
                spin_unlock(&ioa_cfg->hrrq[i]._lock);
        }
        wmb();
-       if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa)
+       if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
+               ioa_cfg->scsi_unblock = 0;
+               ioa_cfg->scsi_blocked = 1;
                scsi_block_requests(ioa_cfg->host);
+       }
 
        ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
        ioa_cfg->reset_cmd = ipr_cmd;
@@ -9306,9 +9312,8 @@ static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
                        wake_up_all(&ioa_cfg->reset_wait_q);
 
                        if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
-                               spin_unlock_irq(ioa_cfg->host->host_lock);
-                               scsi_unblock_requests(ioa_cfg->host);
-                               spin_lock_irq(ioa_cfg->host->host_lock);
+                               ioa_cfg->scsi_unblock = 1;
+                               schedule_work(&ioa_cfg->work_q);
                        }
                        return;
                } else {
index e98a87a653357b54996326d6f422d2ffa7923bee..c7f0e9e3cd7d4986c1341c3b7e115e65de551723 100644 (file)
@@ -1488,6 +1488,8 @@ struct ipr_ioa_cfg {
        u8 cfg_locked:1;
        u8 clear_isr:1;
        u8 probe_done:1;
+       u8 scsi_unblock:1;
+       u8 scsi_blocked:1;
 
        u8 revid;
 
index 316c3df0c3fd80f9689499f0351082703772707f..71c4746341ea379e3881d32cf3078f135d15f999 100644 (file)
@@ -6228,8 +6228,8 @@ static int megasas_probe_one(struct pci_dev *pdev,
 fail_start_aen:
 fail_io_attach:
        megasas_mgmt_info.count--;
-       megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
        megasas_mgmt_info.max_index--;
+       megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
 
        instance->instancet->disable_intr(instance);
        megasas_destroy_irqs(instance);
index 33142610882f4d9bedce93076160180513ca5f82..b18646d6057f476e70d59137a0450e5f90d4b3fc 100644 (file)
@@ -401,9 +401,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_req_queues; i++) {
                        struct req_que *req = vha->hw->req_q_map[i];
 
-                       if (!test_bit(i, vha->hw->req_qid_map))
-                               continue;
-
                        if (req || !buf) {
                                length = req ?
                                    req->length : REQUEST_ENTRY_CNT_24XX;
@@ -418,9 +415,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_rsp_queues; i++) {
                        struct rsp_que *rsp = vha->hw->rsp_q_map[i];
 
-                       if (!test_bit(i, vha->hw->rsp_qid_map))
-                               continue;
-
                        if (rsp || !buf) {
                                length = rsp ?
                                    rsp->length : RESPONSE_ENTRY_CNT_MQ;
@@ -660,9 +654,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_req_queues; i++) {
                        struct req_que *req = vha->hw->req_q_map[i];
 
-                       if (!test_bit(i, vha->hw->req_qid_map))
-                               continue;
-
                        if (req || !buf) {
                                qla27xx_insert16(i, buf, len);
                                qla27xx_insert16(1, buf, len);
@@ -675,9 +666,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_rsp_queues; i++) {
                        struct rsp_que *rsp = vha->hw->rsp_q_map[i];
 
-                       if (!test_bit(i, vha->hw->rsp_qid_map))
-                               continue;
-
                        if (rsp || !buf) {
                                qla27xx_insert16(i, buf, len);
                                qla27xx_insert16(1, buf, len);
index 3d38c6d463b810f19fe2cbdd3dc69801465cd05a..1bf274e3b2b614b5331f4a082668e660ceba74e7 100644 (file)
@@ -800,7 +800,11 @@ MODULE_LICENSE("GPL");
 module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
 
+#ifdef CONFIG_SCSI_MQ_DEFAULT
 bool scsi_use_blk_mq = true;
+#else
+bool scsi_use_blk_mq = false;
+#endif
 module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO);
 
 static int __init init_scsi(void)
index bea36adeee178ab57bced3591b0969bc2d973264..e2647f2d44304b0ded65ebb0f55d629c7289d0b7 100644 (file)
@@ -1277,6 +1277,9 @@ static void sd_uninit_command(struct scsi_cmnd *SCpnt)
 {
        struct request *rq = SCpnt->request;
 
+       if (SCpnt->flags & SCMD_ZONE_WRITE_LOCK)
+               sd_zbc_write_unlock_zone(SCpnt);
+
        if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
                __free_page(rq->special_vec.bv_page);
 
index 96855df9f49ddf3756b8fc6ee98b127727d9bbeb..8aa54779aac1b4e6112d86dc536dd14b1522d6eb 100644 (file)
@@ -294,6 +294,9 @@ int sd_zbc_write_lock_zone(struct scsi_cmnd *cmd)
            test_and_set_bit(zno, sdkp->zones_wlock))
                return BLKPREP_DEFER;
 
+       WARN_ON_ONCE(cmd->flags & SCMD_ZONE_WRITE_LOCK);
+       cmd->flags |= SCMD_ZONE_WRITE_LOCK;
+
        return BLKPREP_OK;
 }
 
@@ -302,9 +305,10 @@ void sd_zbc_write_unlock_zone(struct scsi_cmnd *cmd)
        struct request *rq = cmd->request;
        struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
 
-       if (sdkp->zones_wlock) {
+       if (sdkp->zones_wlock && cmd->flags & SCMD_ZONE_WRITE_LOCK) {
                unsigned int zno = sd_zbc_zone_no(sdkp, blk_rq_pos(rq));
                WARN_ON_ONCE(!test_bit(zno, sdkp->zones_wlock));
+               cmd->flags &= ~SCMD_ZONE_WRITE_LOCK;
                clear_bit_unlock(zno, sdkp->zones_wlock);
                smp_mb__after_atomic();
        }
@@ -335,9 +339,6 @@ void sd_zbc_complete(struct scsi_cmnd *cmd,
        case REQ_OP_WRITE_ZEROES:
        case REQ_OP_WRITE_SAME:
 
-               /* Unlock the zone */
-               sd_zbc_write_unlock_zone(cmd);
-
                if (result &&
                    sshdr->sense_key == ILLEGAL_REQUEST &&
                    sshdr->asc == 0x21)
index f1cdf32d7514120b31515ddf2901960d4f766694..8927f9f54ad926f5b50439e23685a35b24c50edf 100644 (file)
@@ -99,7 +99,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 
        ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
                                NULL, SES_TIMEOUT, SES_RETRIES, NULL);
-       if (unlikely(!ret))
+       if (unlikely(ret))
                return ret;
 
        recv_page_code = ((unsigned char *)buf)[0];
index 8e5013d9cad445178a0461edd8eaf9abe4e84c38..94e402ed30f6ae54ecb32160480d554e6e118827 100644 (file)
@@ -4299,11 +4299,11 @@ static int st_probe(struct device *dev)
        kref_init(&tpnt->kref);
        tpnt->disk = disk;
        disk->private_data = &tpnt->driver;
-       disk->queue = SDp->request_queue;
        /* SCSI tape doesn't register this gendisk via add_disk().  Manually
         * take queue reference that release_disk() expects. */
-       if (!blk_get_queue(disk->queue))
+       if (!blk_get_queue(SDp->request_queue))
                goto out_put_disk;
+       disk->queue = SDp->request_queue;
        tpnt->driver = &st_template;
 
        tpnt->device = SDp;
index 3039072911a5bce09d375c04b9faf65071894c11..afc7ecc3c1876158d33e45933458fc035593c39f 100644 (file)
@@ -200,16 +200,11 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev)
 
        domain->dev = &pdev->dev;
 
-       ret = pm_genpd_init(&domain->genpd, NULL, true);
-       if (ret) {
-               dev_err(domain->dev, "Failed to init power domain\n");
-               return ret;
-       }
-
        domain->regulator = devm_regulator_get_optional(domain->dev, "power");
        if (IS_ERR(domain->regulator)) {
                if (PTR_ERR(domain->regulator) != -ENODEV) {
-                       dev_err(domain->dev, "Failed to get domain's regulator\n");
+                       if (PTR_ERR(domain->regulator) != -EPROBE_DEFER)
+                               dev_err(domain->dev, "Failed to get domain's regulator\n");
                        return PTR_ERR(domain->regulator);
                }
        } else {
@@ -217,6 +212,12 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev)
                                      domain->voltage, domain->voltage);
        }
 
+       ret = pm_genpd_init(&domain->genpd, NULL, true);
+       if (ret) {
+               dev_err(domain->dev, "Failed to init power domain\n");
+               return ret;
+       }
+
        ret = of_genpd_add_provider_simple(domain->dev->of_node,
                                           &domain->genpd);
        if (ret) {
index 279e7c5551dd55588fa95fee7547ea8a945ab58d..39225de9d7f1455e43d2ac6279193a68e5518562 100644 (file)
@@ -745,6 +745,9 @@ void *knav_pool_create(const char *name,
        bool slot_found;
        int ret;
 
+       if (!kdev)
+               return ERR_PTR(-EPROBE_DEFER);
+
        if (!kdev->dev)
                return ERR_PTR(-ENODEV);
 
index b0b283810e72245cb24d0f5ab1efc468d55e52c0..de31b9389e2ee710ed48677bcddbe64e88a26284 100644 (file)
@@ -176,6 +176,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
 
        ti_sci_pd->dev = dev;
 
+       ti_sci_pd->pd.name = "ti_sci_pd";
+
        ti_sci_pd->pd.attach_dev = ti_sci_pd_attach_dev;
        ti_sci_pd->pd.detach_dev = ti_sci_pd_detach_dev;
 
index b37a6f48225f5209999d54f338635b9b027ab967..8ea3920400a06b6a43e8456375fb6fae2b20577f 100644 (file)
@@ -16,9 +16,9 @@
 
 static bool __must_check fsl_mc_is_allocatable(const char *obj_type)
 {
-       return strcmp(obj_type, "dpbp") ||
-              strcmp(obj_type, "dpmcp") ||
-              strcmp(obj_type, "dpcon");
+       return strcmp(obj_type, "dpbp") == 0 ||
+              strcmp(obj_type, "dpmcp") == 0 ||
+              strcmp(obj_type, "dpcon") == 0;
 }
 
 /**
index d283341cfe4356914e3e9071f8d6851a7a180d46..56cd4e5e51b2f99906b5a7170854ea57629f5f34 100644 (file)
@@ -45,6 +45,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
        {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
        {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
        {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
+       {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
        {}      /* Terminating entry */
 };
 
index 284749fb0f6b96d3d6d667332e569ba0d745e048..a6d5164c33a9ca7e3d02bbda7fc94ff783d75929 100644 (file)
@@ -69,13 +69,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
 #ifdef CONFIG_UNIX98_PTYS
                if (tty->driver == ptm_driver) {
                        mutex_lock(&devpts_mutex);
-                       if (tty->link->driver_data) {
-                               struct path *path = tty->link->driver_data;
-
-                               devpts_pty_kill(path->dentry);
-                               path_put(path);
-                               kfree(path);
-                       }
+                       if (tty->link->driver_data)
+                               devpts_pty_kill(tty->link->driver_data);
                        mutex_unlock(&devpts_mutex);
                }
 #endif
@@ -607,25 +602,24 @@ static inline void legacy_pty_init(void) { }
 static struct cdev ptmx_cdev;
 
 /**
- *     pty_open_peer - open the peer of a pty
- *     @tty: the peer of the pty being opened
+ *     ptm_open_peer - open the peer of a pty
+ *     @master: the open struct file of the ptmx device node
+ *     @tty: the master of the pty being opened
+ *     @flags: the flags for open
  *
- *     Open the cached dentry in tty->link, providing a safe way for userspace
- *     to get the slave end of a pty (where they have the master fd and cannot
- *     access or trust the mount namespace /dev/pts was mounted inside).
+ *     Provide a race free way for userspace to open the slave end of a pty
+ *     (where they have the master fd and cannot access or trust the mount
+ *     namespace /dev/pts was mounted inside).
  */
-static struct file *pty_open_peer(struct tty_struct *tty, int flags)
-{
-       if (tty->driver->subtype != PTY_TYPE_MASTER)
-               return ERR_PTR(-EIO);
-       return dentry_open(tty->link->driver_data, flags, current_cred());
-}
-
-static int pty_get_peer(struct tty_struct *tty, int flags)
+int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
 {
        int fd = -1;
-       struct file *filp = NULL;
+       struct file *filp;
        int retval = -EINVAL;
+       struct path path;
+
+       if (tty->driver != ptm_driver)
+               return -EIO;
 
        fd = get_unused_fd_flags(0);
        if (fd < 0) {
@@ -633,7 +627,16 @@ static int pty_get_peer(struct tty_struct *tty, int flags)
                goto err;
        }
 
-       filp = pty_open_peer(tty, flags);
+       /* Compute the slave's path */
+       path.mnt = devpts_mntget(master, tty->driver_data);
+       if (IS_ERR(path.mnt)) {
+               retval = PTR_ERR(path.mnt);
+               goto err_put;
+       }
+       path.dentry = tty->link->driver_data;
+
+       filp = dentry_open(&path, flags, current_cred());
+       mntput(path.mnt);
        if (IS_ERR(filp)) {
                retval = PTR_ERR(filp);
                goto err_put;
@@ -662,8 +665,6 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
                return pty_get_pktmode(tty, (int __user *)arg);
        case TIOCGPTN: /* Get PT Number */
                return put_user(tty->index, (unsigned int __user *)arg);
-       case TIOCGPTPEER: /* Open the other end */
-               return pty_get_peer(tty, (int) arg);
        case TIOCSIG:    /* Send signal to other side of pty */
                return pty_signal(tty, (int) arg);
        }
@@ -791,7 +792,6 @@ static int ptmx_open(struct inode *inode, struct file *filp)
 {
        struct pts_fs_info *fsi;
        struct tty_struct *tty;
-       struct path *pts_path;
        struct dentry *dentry;
        int retval;
        int index;
@@ -845,26 +845,16 @@ static int ptmx_open(struct inode *inode, struct file *filp)
                retval = PTR_ERR(dentry);
                goto err_release;
        }
-       /* We need to cache a fake path for TIOCGPTPEER. */
-       pts_path = kmalloc(sizeof(struct path), GFP_KERNEL);
-       if (!pts_path)
-               goto err_release;
-       pts_path->mnt = filp->f_path.mnt;
-       pts_path->dentry = dentry;
-       path_get(pts_path);
-       tty->link->driver_data = pts_path;
+       tty->link->driver_data = dentry;
 
        retval = ptm_driver->ops->open(tty, filp);
        if (retval)
-               goto err_path_put;
+               goto err_release;
 
        tty_debug_hangup(tty, "opening (count=%d)\n", tty->count);
 
        tty_unlock(tty);
        return 0;
-err_path_put:
-       path_put(pts_path);
-       kfree(pts_path);
 err_release:
        tty_unlock(tty);
        // This will also put-ref the fsi
index 974b13d244010de234d0350b9c45425251ff99c6..10c4038c0e8dfe9d07b7fd5f02732de03cc4ed3e 100644 (file)
@@ -2518,6 +2518,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case TIOCSSERIAL:
                tty_warn_deprecated_flags(p);
                break;
+       case TIOCGPTPEER:
+               /* Special because the struct file is needed */
+               return ptm_open_peer(file, tty, (int)arg);
        default:
                retval = tty_jobctrl_ioctl(tty, real_tty, file, cmd, arg);
                if (retval != -ENOIOCTLCMD)
index 007a4f3660862e1aa6e9a16207ae54bbbab61d58..1c4797e53f686b03323e4316d443c256854268dc 100644 (file)
@@ -107,6 +107,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
 {
        struct virtio_pci_device *vp_dev = to_vp_device(vdev);
        const char *name = dev_name(&vp_dev->vdev.dev);
+       unsigned flags = PCI_IRQ_MSIX;
        unsigned i, v;
        int err = -ENOMEM;
 
@@ -126,10 +127,13 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
                                        GFP_KERNEL))
                        goto error;
 
+       if (desc) {
+               flags |= PCI_IRQ_AFFINITY;
+               desc->pre_vectors++; /* virtio config vector */
+       }
+
        err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors,
-                                            nvectors, PCI_IRQ_MSIX |
-                                            (desc ? PCI_IRQ_AFFINITY : 0),
-                                            desc);
+                                            nvectors, flags, desc);
        if (err < 0)
                goto error;
        vp_dev->msix_enabled = 1;
index 8feab810aed9222b97bd5959b42e6f09ffaaf83d..7f188b8d0c6703dda0ed4ae7647d7b082c429933 100644 (file)
@@ -7,9 +7,6 @@ obj-y   += xenbus/
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_features.o                      := $(nostackp)
 
-CFLAGS_efi.o                           += -fshort-wchar
-LDFLAGS                                        += $(call ld-option, --no-wchar-size-warning)
-
 dom0-$(CONFIG_ARM64) += arm-device.o
 dom0-$(CONFIG_PCI) += pci.o
 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
index 4da69dbf7dcad7f2e2898dd807a118596f86058a..1bdd02a6d6ac757c5a500db192b3d7923c316753 100644 (file)
@@ -10,8 +10,7 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
        unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page));
        unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page));
 
-       return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) &&
-               ((bfn1 == bfn2) || ((bfn1+1) == bfn2));
+       return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2;
 #else
        /*
         * XXX: Add support for merging bio_vec when using different page
index 879ff9c7ffd01a0f1f2d6a7e92c32926af5ef4c2..6466153f2bf099d357166192710167667abefa09 100644 (file)
@@ -664,8 +664,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
 {
        unsigned long random_variable = 0;
 
-       if ((current->flags & PF_RANDOMIZE) &&
-               !(current->personality & ADDR_NO_RANDOMIZE)) {
+       if (current->flags & PF_RANDOMIZE) {
                random_variable = get_random_long();
                random_variable &= STACK_RND_MASK;
                random_variable <<= PAGE_SHIFT;
index 080e2ebb8aa0137baef69edda45aa895bf8b7c7c..f45b61fe9a9ab8d54d87e98ab494e29cedd2e0ab 100644 (file)
@@ -3516,7 +3516,7 @@ static blk_status_t wait_dev_flush(struct btrfs_device *device)
        struct bio *bio = device->flush_bio;
 
        if (!device->flush_bio_sent)
-               return 0;
+               return BLK_STS_OK;
 
        device->flush_bio_sent = 0;
        wait_for_completion_io(&device->flush_wait);
@@ -3563,7 +3563,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
                        continue;
 
                write_dev_flush(dev);
-               dev->last_flush_error = 0;
+               dev->last_flush_error = BLK_STS_OK;
        }
 
        /* wait for all the barriers */
index 95c212037095fea727f4a35ea19d9d7e54ad8cfe..24bcd5cd9cf2fc680cc7ed32fb58cd254bb055b5 100644 (file)
@@ -7924,11 +7924,12 @@ err:
        return ret;
 }
 
-static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio,
-                                       int mirror_num)
+static inline blk_status_t submit_dio_repair_bio(struct inode *inode,
+                                                struct bio *bio,
+                                                int mirror_num)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-       int ret;
+       blk_status_t ret;
 
        BUG_ON(bio_op(bio) == REQ_OP_WRITE);
 
@@ -7980,10 +7981,10 @@ static int btrfs_check_dio_repairable(struct inode *inode,
        return 1;
 }
 
-static int dio_read_error(struct inode *inode, struct bio *failed_bio,
-                       struct page *page, unsigned int pgoff,
-                       u64 start, u64 end, int failed_mirror,
-                       bio_end_io_t *repair_endio, void *repair_arg)
+static blk_status_t dio_read_error(struct inode *inode, struct bio *failed_bio,
+                                  struct page *page, unsigned int pgoff,
+                                  u64 start, u64 end, int failed_mirror,
+                                  bio_end_io_t *repair_endio, void *repair_arg)
 {
        struct io_failure_record *failrec;
        struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
@@ -7993,18 +7994,19 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio,
        int read_mode = 0;
        int segs;
        int ret;
+       blk_status_t status;
 
        BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE);
 
        ret = btrfs_get_io_failure_record(inode, start, end, &failrec);
        if (ret)
-               return ret;
+               return errno_to_blk_status(ret);
 
        ret = btrfs_check_dio_repairable(inode, failed_bio, failrec,
                                         failed_mirror);
        if (!ret) {
                free_io_failure(failure_tree, io_tree, failrec);
-               return -EIO;
+               return BLK_STS_IOERR;
        }
 
        segs = bio_segments(failed_bio);
@@ -8022,13 +8024,13 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio,
                    "Repair DIO Read Error: submitting new dio read[%#x] to this_mirror=%d, in_validation=%d\n",
                    read_mode, failrec->this_mirror, failrec->in_validation);
 
-       ret = submit_dio_repair_bio(inode, bio, failrec->this_mirror);
-       if (ret) {
+       status = submit_dio_repair_bio(inode, bio, failrec->this_mirror);
+       if (status) {
                free_io_failure(failure_tree, io_tree, failrec);
                bio_put(bio);
        }
 
-       return ret;
+       return status;
 }
 
 struct btrfs_retry_complete {
@@ -8065,8 +8067,8 @@ end:
        bio_put(bio);
 }
 
-static int __btrfs_correct_data_nocsum(struct inode *inode,
-                                      struct btrfs_io_bio *io_bio)
+static blk_status_t __btrfs_correct_data_nocsum(struct inode *inode,
+                                               struct btrfs_io_bio *io_bio)
 {
        struct btrfs_fs_info *fs_info;
        struct bio_vec bvec;
@@ -8076,8 +8078,8 @@ static int __btrfs_correct_data_nocsum(struct inode *inode,
        unsigned int pgoff;
        u32 sectorsize;
        int nr_sectors;
-       int ret;
-       int err = 0;
+       blk_status_t ret;
+       blk_status_t err = BLK_STS_OK;
 
        fs_info = BTRFS_I(inode)->root->fs_info;
        sectorsize = fs_info->sectorsize;
@@ -8183,11 +8185,12 @@ static blk_status_t __btrfs_subio_endio_read(struct inode *inode,
        int csum_pos;
        bool uptodate = (err == 0);
        int ret;
+       blk_status_t status;
 
        fs_info = BTRFS_I(inode)->root->fs_info;
        sectorsize = fs_info->sectorsize;
 
-       err = 0;
+       err = BLK_STS_OK;
        start = io_bio->logical;
        done.inode = inode;
        io_bio->bio.bi_iter = io_bio->iter;
@@ -8209,12 +8212,12 @@ try_again:
                done.start = start;
                init_completion(&done.done);
 
-               ret = dio_read_error(inode, &io_bio->bio, bvec.bv_page,
-                               pgoff, start, start + sectorsize - 1,
-                               io_bio->mirror_num,
-                               btrfs_retry_endio, &done);
-               if (ret) {
-                       err = errno_to_blk_status(ret);
+               status = dio_read_error(inode, &io_bio->bio, bvec.bv_page,
+                                       pgoff, start, start + sectorsize - 1,
+                                       io_bio->mirror_num, btrfs_retry_endio,
+                                       &done);
+               if (status) {
+                       err = status;
                        goto next;
                }
 
@@ -8250,7 +8253,7 @@ static blk_status_t btrfs_subio_endio_read(struct inode *inode,
                if (unlikely(err))
                        return __btrfs_correct_data_nocsum(inode, io_bio);
                else
-                       return 0;
+                       return BLK_STS_OK;
        } else {
                return __btrfs_subio_endio_read(inode, io_bio, err);
        }
@@ -8423,9 +8426,9 @@ static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode,
        return 0;
 }
 
-static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
-                                        u64 file_offset, int skip_sum,
-                                        int async_submit)
+static inline blk_status_t
+__btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset,
+                      int skip_sum, int async_submit)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
        struct btrfs_dio_private *dip = bio->bi_private;
@@ -8488,6 +8491,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
        int clone_offset = 0;
        int clone_len;
        int ret;
+       blk_status_t status;
 
        map_length = orig_bio->bi_iter.bi_size;
        submit_len = map_length;
@@ -8537,9 +8541,9 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
                 */
                atomic_inc(&dip->pending_bios);
 
-               ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
-                                            async_submit);
-               if (ret) {
+               status = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
+                                               async_submit);
+               if (status) {
                        bio_put(bio);
                        atomic_dec(&dip->pending_bios);
                        goto out_err;
@@ -8557,9 +8561,9 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
        } while (submit_len > 0);
 
 submit:
-       ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
-                                    async_submit);
-       if (!ret)
+       status = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
+                                       async_submit);
+       if (!status)
                return 0;
 
        bio_put(bio);
index 208638384cd2abfb1206b2f5927b5763a6330283..2cf6ba40f7c441bb3483f9c543e1e17bbcea1971 100644 (file)
@@ -905,7 +905,7 @@ static void raid_write_end_io(struct bio *bio)
        if (!atomic_dec_and_test(&rbio->stripes_pending))
                return;
 
-       err = 0;
+       err = BLK_STS_OK;
 
        /* OK, we have read all the stripes we need to. */
        max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ?
@@ -1324,7 +1324,7 @@ write_data:
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 /*
@@ -1475,7 +1475,7 @@ static void raid_rmw_end_io(struct bio *bio)
 
 cleanup:
 
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
@@ -1579,7 +1579,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
        return 0;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
        return -EIO;
 
 finish:
@@ -1795,12 +1795,12 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
        void **pointers;
        int faila = -1, failb = -1;
        struct page *page;
-       int err;
+       blk_status_t err;
        int i;
 
        pointers = kcalloc(rbio->real_stripes, sizeof(void *), GFP_NOFS);
        if (!pointers) {
-               err = -ENOMEM;
+               err = BLK_STS_RESOURCE;
                goto cleanup_io;
        }
 
@@ -1856,7 +1856,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
                                         * a bad data or Q stripe.
                                         * TODO, we should redo the xor here.
                                         */
-                                       err = -EIO;
+                                       err = BLK_STS_IOERR;
                                        goto cleanup;
                                }
                                /*
@@ -1882,7 +1882,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
                        if (rbio->bbio->raid_map[failb] == RAID6_Q_STRIPE) {
                                if (rbio->bbio->raid_map[faila] ==
                                    RAID5_P_STRIPE) {
-                                       err = -EIO;
+                                       err = BLK_STS_IOERR;
                                        goto cleanup;
                                }
                                /*
@@ -1954,13 +1954,13 @@ pstripe:
                }
        }
 
-       err = 0;
+       err = BLK_STS_OK;
 cleanup:
        kfree(pointers);
 
 cleanup_io:
        if (rbio->operation == BTRFS_RBIO_READ_REBUILD) {
-               if (err == 0)
+               if (err == BLK_STS_OK)
                        cache_rbio_pages(rbio);
                else
                        clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags);
@@ -1968,7 +1968,7 @@ cleanup_io:
                rbio_orig_end_io(rbio, err);
        } else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) {
                rbio_orig_end_io(rbio, err);
-       } else if (err == 0) {
+       } else if (err == BLK_STS_OK) {
                rbio->faila = -1;
                rbio->failb = -1;
 
@@ -2005,7 +2005,7 @@ static void raid_recover_end_io(struct bio *bio)
                return;
 
        if (atomic_read(&rbio->error) > rbio->bbio->max_errors)
-               rbio_orig_end_io(rbio, -EIO);
+               rbio_orig_end_io(rbio, BLK_STS_IOERR);
        else
                __raid_recover_end_io(rbio);
 }
@@ -2104,7 +2104,7 @@ out:
 cleanup:
        if (rbio->operation == BTRFS_RBIO_READ_REBUILD ||
            rbio->operation == BTRFS_RBIO_REBUILD_MISSING)
-               rbio_orig_end_io(rbio, -EIO);
+               rbio_orig_end_io(rbio, BLK_STS_IOERR);
        return -EIO;
 }
 
@@ -2431,7 +2431,7 @@ submit_write:
        nr_data = bio_list_size(&bio_list);
        if (!nr_data) {
                /* Every parity is right */
-               rbio_orig_end_io(rbio, 0);
+               rbio_orig_end_io(rbio, BLK_STS_OK);
                return;
        }
 
@@ -2451,7 +2451,7 @@ submit_write:
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe)
@@ -2519,7 +2519,7 @@ static void validate_rbio_for_parity_scrub(struct btrfs_raid_bio *rbio)
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 /*
@@ -2633,7 +2633,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio)
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
        return;
 
 finish:
index e8b9a269fddec78fdf42adec32eabaffdf9c3636..bd679bc7a1a956cfc541fcb2a74ed4b49b815642 100644 (file)
@@ -6212,8 +6212,8 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)
        }
 }
 
-int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
-                 int mirror_num, int async_submit)
+blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
+                          int mirror_num, int async_submit)
 {
        struct btrfs_device *dev;
        struct bio *first_bio = bio;
@@ -6233,7 +6233,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                                &map_length, &bbio, mirror_num, 1);
        if (ret) {
                btrfs_bio_counter_dec(fs_info);
-               return ret;
+               return errno_to_blk_status(ret);
        }
 
        total_devs = bbio->num_stripes;
@@ -6256,7 +6256,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                }
 
                btrfs_bio_counter_dec(fs_info);
-               return ret;
+               return errno_to_blk_status(ret);
        }
 
        if (map_length < length) {
@@ -6283,7 +6283,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                                  dev_nr, async_submit);
        }
        btrfs_bio_counter_dec(fs_info);
-       return 0;
+       return BLK_STS_OK;
 }
 
 struct btrfs_device *btrfs_find_device(struct btrfs_fs_info *fs_info, u64 devid,
index 6f45fd60d15a92d7aea7a5711bb365a201cb09f9..93277fc60930561a7ffb8c40d2e4ae61ce5908a0 100644 (file)
@@ -74,7 +74,7 @@ struct btrfs_device {
        int missing;
        int can_discard;
        int is_tgtdev_for_dev_replace;
-       int last_flush_error;
+       blk_status_t last_flush_error;
        int flush_bio_sent;
 
 #ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED
@@ -416,8 +416,8 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                      struct btrfs_fs_info *fs_info, u64 type);
 void btrfs_mapping_init(struct btrfs_mapping_tree *tree);
 void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree);
-int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
-                 int mirror_num, int async_submit);
+blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
+                          int mirror_num, int async_submit);
 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
                       fmode_t flags, void *holder);
 int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
index 56366e9840769dd8a45250ec3a7b65097c979ff9..569d3fb736be070d2693f600f867bd836aeb1dc4 100644 (file)
@@ -194,15 +194,20 @@ cifs_bp_rename_retry:
 }
 
 /*
+ * Don't allow path components longer than the server max.
  * Don't allow the separator character in a path component.
  * The VFS will not allow "/", but "\" is allowed by posix.
  */
 static int
-check_name(struct dentry *direntry)
+check_name(struct dentry *direntry, struct cifs_tcon *tcon)
 {
        struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
        int i;
 
+       if (unlikely(direntry->d_name.len >
+                    tcon->fsAttrInfo.MaxPathNameComponentLength))
+               return -ENAMETOOLONG;
+
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) {
                for (i = 0; i < direntry->d_name.len; i++) {
                        if (direntry->d_name.name[i] == '\\') {
@@ -500,10 +505,6 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
                return finish_no_open(file, res);
        }
 
-       rc = check_name(direntry);
-       if (rc)
-               return rc;
-
        xid = get_xid();
 
        cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
@@ -516,6 +517,11 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
        }
 
        tcon = tlink_tcon(tlink);
+
+       rc = check_name(direntry, tcon);
+       if (rc)
+               goto out_free_xid;
+
        server = tcon->ses->server;
 
        if (server->ops->new_lease_key)
@@ -776,7 +782,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
        }
        pTcon = tlink_tcon(tlink);
 
-       rc = check_name(direntry);
+       rc = check_name(direntry, pTcon);
        if (rc)
                goto lookup_out;
 
index 5fb2fc2d0080b6e62fd0ad10e1a9c90c08308f2d..97edb4d376cd40e1e6044ed6b5ff7072e0d1b10c 100644 (file)
@@ -3219,8 +3219,8 @@ copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf,
        kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) *
                          le32_to_cpu(pfs_inf->SectorsPerAllocationUnit);
        kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits);
-       kst->f_bfree  = le64_to_cpu(pfs_inf->ActualAvailableAllocationUnits);
-       kst->f_bavail = le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
+       kst->f_bfree  = kst->f_bavail =
+                       le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
        return;
 }
 
index 306c2b603fb8aa8845558a2bf8226523e5282cdb..865d42c63e23e4746c6658fbe2746fd17ade11f9 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1383,6 +1383,16 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
 
        trace_dax_pmd_fault(inode, vmf, max_pgoff, 0);
 
+       /*
+        * Make sure that the faulting address's PMD offset (color) matches
+        * the PMD offset from the start of the file.  This is necessary so
+        * that a PMD range in the page table overlaps exactly with a PMD
+        * range in the radix tree.
+        */
+       if ((vmf->pgoff & PG_PMD_COLOUR) !=
+           ((vmf->address >> PAGE_SHIFT) & PG_PMD_COLOUR))
+               goto fallback;
+
        /* Fall back to PTEs if we're going to COW */
        if (write && !(vma->vm_flags & VM_SHARED))
                goto fallback;
index 108df2e3602c2c63186b61b2fede52794cb46482..7eae33ffa3fcc1d709790b79225521472c6f8281 100644 (file)
@@ -133,6 +133,50 @@ static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb)
        return sb->s_fs_info;
 }
 
+static int devpts_ptmx_path(struct path *path)
+{
+       struct super_block *sb;
+       int err;
+
+       /* Has the devpts filesystem already been found? */
+       if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
+               return 0;
+
+       /* Is a devpts filesystem at "pts" in the same directory? */
+       err = path_pts(path);
+       if (err)
+               return err;
+
+       /* Is the path the root of a devpts filesystem? */
+       sb = path->mnt->mnt_sb;
+       if ((sb->s_magic != DEVPTS_SUPER_MAGIC) ||
+           (path->mnt->mnt_root != sb->s_root))
+               return -ENODEV;
+
+       return 0;
+}
+
+struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi)
+{
+       struct path path;
+       int err;
+
+       path = filp->f_path;
+       path_get(&path);
+
+       err = devpts_ptmx_path(&path);
+       dput(path.dentry);
+       if (err) {
+               mntput(path.mnt);
+               path.mnt = ERR_PTR(err);
+       }
+       if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) {
+               mntput(path.mnt);
+               path.mnt = ERR_PTR(-ENODEV);
+       }
+       return path.mnt;
+}
+
 struct pts_fs_info *devpts_acquire(struct file *filp)
 {
        struct pts_fs_info *result;
@@ -143,27 +187,16 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
        path = filp->f_path;
        path_get(&path);
 
-       /* Has the devpts filesystem already been found? */
-       sb = path.mnt->mnt_sb;
-       if (sb->s_magic != DEVPTS_SUPER_MAGIC) {
-               /* Is a devpts filesystem at "pts" in the same directory? */
-               err = path_pts(&path);
-               if (err) {
-                       result = ERR_PTR(err);
-                       goto out;
-               }
-
-               /* Is the path the root of a devpts filesystem? */
-               result = ERR_PTR(-ENODEV);
-               sb = path.mnt->mnt_sb;
-               if ((sb->s_magic != DEVPTS_SUPER_MAGIC) ||
-                   (path.mnt->mnt_root != sb->s_root))
-                       goto out;
+       err = devpts_ptmx_path(&path);
+       if (err) {
+               result = ERR_PTR(err);
+               goto out;
        }
 
        /*
         * pty code needs to hold extra references in case of last /dev/tty close
         */
+       sb = path.mnt->mnt_sb;
        atomic_inc(&sb->s_active);
        result = DEVPTS_SB(sb);
 
index 5a1052627a81413685241f0c4669bbf755e2c5f9..701085620cd82cee3fda28ff6ca65921a9119fc1 100644 (file)
@@ -2300,7 +2300,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
                                             EXT4_MAX_BLOCK_LOG_SIZE);
        struct sg {
                struct ext4_group_info info;
-               ext4_grpblk_t counters[blocksize_bits + 2];
+               ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
        } sg;
 
        group--;
@@ -2309,6 +2309,9 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
                              " 2^0   2^1   2^2   2^3   2^4   2^5   2^6  "
                              " 2^7   2^8   2^9   2^10  2^11  2^12  2^13  ]\n");
 
+       i = (blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) +
+               sizeof(struct ext4_group_info);
+
        grinfo = ext4_get_group_info(sb, group);
        /* Load the group info in memory only if not already loaded. */
        if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) {
@@ -2320,7 +2323,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
                buddy_loaded = 1;
        }
 
-       memcpy(&sg, ext4_get_group_info(sb, group), sizeof(sg));
+       memcpy(&sg, ext4_get_group_info(sb, group), i);
 
        if (buddy_loaded)
                ext4_mb_unload_buddy(&e4b);
index 82a5af9f66685a6165a59a1f0c6ba603dd332e8b..3dd9701684488627d26294dd0489323b72afbba8 100644 (file)
@@ -1543,7 +1543,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
                        /* Clear padding bytes. */
                        memset(val + i->value_len, 0, new_size - i->value_len);
                }
-               return 0;
+               goto update_hash;
        }
 
        /* Compute min_offs and last. */
@@ -1707,6 +1707,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
                here->e_value_size = cpu_to_le32(i->value_len);
        }
 
+update_hash:
        if (i->value) {
                __le32 hash = 0;
 
@@ -1725,7 +1726,8 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
                                                     here->e_name_len,
                                                     &crc32c_hash, 1);
                } else if (is_block) {
-                       __le32 *value = s->base + min_offs - new_size;
+                       __le32 *value = s->base + le16_to_cpu(
+                                                       here->e_value_offs);
 
                        hash = ext4_xattr_hash_entry(here->e_name,
                                                     here->e_name_len, value,
index 039266128b7ff0b09ed2a55e621a9a0dc9e38720..59cc98ad7577b438a7928cdace1f2af3a7cabf75 100644 (file)
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
                unsigned long bytes;    /* Bytes to write to page */
 
                offset = (pos & (PAGE_SIZE - 1));
-               bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
+               bytes = min_t(loff_t, PAGE_SIZE - offset, length);
 
                rpage = __iomap_read_page(inode, pos);
                if (IS_ERR(rpage))
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
                unsigned offset, bytes;
 
                offset = pos & (PAGE_SIZE - 1); /* Within page */
-               bytes = min_t(unsigned, PAGE_SIZE - offset, count);
+               bytes = min_t(loff_t, PAGE_SIZE - offset, count);
 
                if (IS_DAX(inode))
                        status = iomap_dax_zero(pos, offset, bytes, iomap);
index 20fbcab977531bee75501a9403f4c8f60ee404d4..5f940d2a136b72a8e5ffcbff2f094b9f0ebfdaa3 100644 (file)
@@ -144,7 +144,7 @@ static void next_decode_page(struct nfsd4_compoundargs *argp)
        argp->p = page_address(argp->pagelist[0]);
        argp->pagelist++;
        if (argp->pagelen < PAGE_SIZE) {
-               argp->end = argp->p + (argp->pagelen>>2);
+               argp->end = argp->p + XDR_QUADLEN(argp->pagelen);
                argp->pagelen = 0;
        } else {
                argp->end = argp->p + (PAGE_SIZE>>2);
@@ -1279,9 +1279,7 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
                argp->pagelen -= pages * PAGE_SIZE;
                len -= pages * PAGE_SIZE;
 
-               argp->p = (__be32 *)page_address(argp->pagelist[0]);
-               argp->pagelist++;
-               argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
+               next_decode_page(argp);
        }
        argp->p += XDR_QUADLEN(len);
 
index 53a17496c5c536a9410cba73c16d70c5efdbba88..566e6ef99f077c76680cb005417ae995cb4e2878 100644 (file)
@@ -1124,6 +1124,10 @@ void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
                WARN_ON_ONCE(1);
                dquot->dq_dqb.dqb_rsvspace = 0;
        }
+       if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
+           dquot->dq_dqb.dqb_bsoftlimit)
+               dquot->dq_dqb.dqb_btime = (time64_t) 0;
+       clear_bit(DQ_BLKS_B, &dquot->dq_flags);
 }
 
 static void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
@@ -1145,7 +1149,8 @@ static void dquot_decr_space(struct dquot *dquot, qsize_t number)
                dquot->dq_dqb.dqb_curspace -= number;
        else
                dquot->dq_dqb.dqb_curspace = 0;
-       if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
+       if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
+           dquot->dq_dqb.dqb_bsoftlimit)
                dquot->dq_dqb.dqb_btime = (time64_t) 0;
        clear_bit(DQ_BLKS_B, &dquot->dq_flags);
 }
@@ -1381,14 +1386,18 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes)
 
 static int info_bdq_free(struct dquot *dquot, qsize_t space)
 {
+       qsize_t tspace;
+
+       tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace;
+
        if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
-           dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
+           tspace <= dquot->dq_dqb.dqb_bsoftlimit)
                return QUOTA_NL_NOWARN;
 
-       if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
+       if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
                return QUOTA_NL_BSOFTBELOW;
-       if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit &&
-           dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit)
+       if (tspace >= dquot->dq_dqb.dqb_bhardlimit &&
+           tspace - space < dquot->dq_dqb.dqb_bhardlimit)
                return QUOTA_NL_BHARDBELOW;
        return QUOTA_NL_NOWARN;
 }
@@ -2681,7 +2690,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
 
        if (check_blim) {
                if (!dm->dqb_bsoftlimit ||
-                   dm->dqb_curspace < dm->dqb_bsoftlimit) {
+                   dm->dqb_curspace + dm->dqb_rsvspace < dm->dqb_bsoftlimit) {
                        dm->dqb_btime = 0;
                        clear_bit(DQ_BLKS_B, &dquot->dq_flags);
                } else if (!(di->d_fieldmask & QC_SPC_TIMER))
index ffd5a15d1bb6d0955633d4e1f61f6a84aa79f3f7..abf5beaae907d32b484128f182bee2d1d7a7cd9e 100644 (file)
@@ -1246,13 +1246,13 @@ xfs_dialloc_ag_inobt(
 
                        /* free inodes to the left? */
                        if (useleft && trec.ir_freecount) {
-                               rec = trec;
                                xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
                                cur = tcur;
 
                                pag->pagl_leftrec = trec.ir_startino;
                                pag->pagl_rightrec = rec.ir_startino;
                                pag->pagl_pagino = pagino;
+                               rec = trec;
                                goto alloc_inode;
                        }
 
index 0053bcf2b10a1de59c459de8c74a8cd1d0269d3b..4ebd0bafc914ce7b7f1e4d35134c9dedb09a23b5 100644 (file)
@@ -749,9 +749,20 @@ xfs_log_mount_finish(
                return 0;
        }
 
+       /*
+        * During the second phase of log recovery, we need iget and
+        * iput to behave like they do for an active filesystem.
+        * xfs_fs_drop_inode needs to be able to prevent the deletion
+        * of inodes before we're done replaying log items on those
+        * inodes.  Turn it off immediately after recovery finishes
+        * so that we don't leak the quota inodes if subsequent mount
+        * activities fail.
+        */
+       mp->m_super->s_flags |= MS_ACTIVE;
        error = xlog_recover_finish(mp->m_log);
        if (!error)
                xfs_log_work_queue(mp);
+       mp->m_super->s_flags &= ~MS_ACTIVE;
 
        return error;
 }
index 40d4e8b4e193b41a123903735736248568bf26b9..ea7d4b4e50d0ca3eedee85ffd840542e0bb105db 100644 (file)
@@ -944,15 +944,6 @@ xfs_mountfs(
                }
        }
 
-       /*
-        * During the second phase of log recovery, we need iget and
-        * iput to behave like they do for an active filesystem.
-        * xfs_fs_drop_inode needs to be able to prevent the deletion
-        * of inodes before we're done replaying log items on those
-        * inodes.
-        */
-       mp->m_super->s_flags |= MS_ACTIVE;
-
        /*
         * Finish recovering the file system.  This part needed to be delayed
         * until after the root and real-time bitmap inodes were consistently
@@ -1028,12 +1019,13 @@ xfs_mountfs(
  out_quota:
        xfs_qm_unmount_quotas(mp);
  out_rtunmount:
-       mp->m_super->s_flags &= ~MS_ACTIVE;
        xfs_rtunmount_inodes(mp);
  out_rele_rip:
        IRELE(rip);
        cancel_delayed_work_sync(&mp->m_reclaim_work);
        xfs_reclaim_inodes(mp, SYNC_WAIT);
+       /* Clean out dquots that might be in memory after quotacheck. */
+       xfs_qm_unmount(mp);
  out_log_dealloc:
        mp->m_flags |= XFS_MOUNT_UNMOUNTING;
        xfs_log_mount_cancel(mp);
index da0be9a8d1de4c239e53aec01a5e8b9cd87e3bdd..9623d78f84947e3d2fa51c7e7839932e5572441b 100644 (file)
 /* Align . to a 8 byte boundary equals to maximum function alignment. */
 #define ALIGN_FUNCTION()  . = ALIGN(8)
 
+/*
+ * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which
+ * generates .data.identifier sections, which need to be pulled in with
+ * .data. We don't want to pull in .data..other sections, which Linux
+ * has defined. Same for text and bss.
+ */
+#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
+#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#else
+#define TEXT_MAIN .text
+#define DATA_MAIN .data
+#define BSS_MAIN .bss
+#endif
+
 /*
  * Align to a 32 byte boundary equal to the
  * alignment gcc 4.5 uses for a struct
 
 /*
  * .data section
- * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections generates
- * .data.identifier which needs to be pulled in with .data, but don't want to
- * pull in .data..stuff which has its own requirements. Same for bss.
  */
 #define DATA_DATA                                                      \
-       *(.data .data.[0-9a-zA-Z_]*)                                    \
+       *(DATA_MAIN)                                                    \
        *(.ref.data)                                                    \
        *(.data..shared_aligned) /* percpu related */                   \
        MEM_KEEP(init.data)                                             \
                VMLINUX_SYMBOL(__security_initcall_end) = .;            \
        }
 
-/* .text section. Map to function alignment to avoid address changes
+/*
+ * .text section. Map to function alignment to avoid address changes
  * during second ld run in second ld pass when generating System.map
- * LD_DEAD_CODE_DATA_ELIMINATION option enables -ffunction-sections generates
- * .text.identifier which needs to be pulled in with .text , but some
- * architectures define .text.foo which is not intended to be pulled in here.
- * Those enabling LD_DEAD_CODE_DATA_ELIMINATION must ensure they don't have
- * conflicting section names, and must pull in .text.[0-9a-zA-Z_]* */
+ *
+ * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
+ * code elimination is enabled, so these sections should be converted
+ * to use ".." first.
+ */
 #define TEXT_TEXT                                                      \
                ALIGN_FUNCTION();                                       \
-               *(.text.hot .text .text.fixup .text.unlikely)           \
+               *(.text.hot TEXT_MAIN .text.fixup .text.unlikely)       \
                *(.ref.text)                                            \
        MEM_KEEP(init.text)                                             \
        MEM_KEEP(exit.text)                                             \
                BSS_FIRST_SECTIONS                                      \
                *(.bss..page_aligned)                                   \
                *(.dynbss)                                              \
-               *(.bss .bss.[0-9a-zA-Z_]*)                              \
+               *(BSS_MAIN)                                             \
                *(COMMON)                                               \
        }
 
index 5fef5d1f8f820de5fc78102e5f996ae3181e0e53..111b4b0ec85a1660ea11f94c8438cf19adab1571 100644 (file)
 #define __DTS_IOMMU_PORT_MT8173_H
 
 #define MTK_M4U_ID(larb, port)         (((larb) << 5) | (port))
-/* Local arbiter ID */
-#define MTK_M4U_TO_LARB(id)            (((id) >> 5) & 0x7)
-/* PortID within the local arbiter */
-#define MTK_M4U_TO_PORT(id)            ((id) & 0x1f)
 
 #define M4U_LARB0_ID                   0
 #define M4U_LARB1_ID                   1
index 25f6a0cb27d3e9644c1ef42e7f1ff2b5d817293d..2a5d52fa90f5da353086a0faf5c8a5cdea63128a 100644 (file)
@@ -568,7 +568,6 @@ struct request_queue {
 
 #if defined(CONFIG_BLK_DEV_BSG)
        bsg_job_fn              *bsg_job_fn;
-       int                     bsg_job_size;
        struct bsg_class_device bsg_dev;
 #endif
 
index e34dde2da0ef57c3692ce7001fa66fe37c4dc578..637a20cfb237db4ab76a480172e918e6e48f849b 100644 (file)
@@ -24,6 +24,7 @@
 #define _BLK_BSG_
 
 #include <linux/blkdev.h>
+#include <scsi/scsi_request.h>
 
 struct request;
 struct device;
@@ -37,6 +38,7 @@ struct bsg_buffer {
 };
 
 struct bsg_job {
+       struct scsi_request sreq;
        struct device *dev;
        struct request *req;
 
index 277ab9af9ac29a95773ce2201809f7c7613391a1..100cb43437630114127bfecc3d29ad4454c03446 100644 (file)
@@ -19,6 +19,7 @@
 
 struct pts_fs_info;
 
+struct vfsmount *devpts_mntget(struct file *, struct pts_fs_info *);
 struct pts_fs_info *devpts_acquire(struct file *);
 void devpts_release(struct pts_fs_info *);
 
@@ -32,6 +33,15 @@ void *devpts_get_priv(struct dentry *);
 /* unlink */
 void devpts_pty_kill(struct dentry *);
 
+/* in pty.c */
+int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags);
+
+#else
+static inline int
+ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
+{
+       return -EIO;
+}
 #endif
 
 
index 6e1fd5d2124877c16bbbfab4487a772c8f7e37ee..cbfe127bccf8b112a2d65289a4ec7fef4809da22 100644 (file)
@@ -907,9 +907,9 @@ static inline struct file *get_file(struct file *f)
 /* Page cache limit. The filesystems should put that into their s_maxbytes 
    limits, otherwise bad things can happen in VM. */ 
 #if BITS_PER_LONG==32
-#define MAX_LFS_FILESIZE       (((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1)
+#define MAX_LFS_FILESIZE       ((loff_t)ULONG_MAX << PAGE_SHIFT)
 #elif BITS_PER_LONG==64
-#define MAX_LFS_FILESIZE       ((loff_t)0x7fffffffffffffffLL)
+#define MAX_LFS_FILESIZE       ((loff_t)LLONG_MAX)
 #endif
 
 #define FL_POSIX       1
index d68bec297a45ee5e212ca253d903bf382d0ccfd9..c380daa40c0e3e6594b79a81128fc64326ee8a99 100644 (file)
@@ -535,7 +535,7 @@ struct iio_buffer_setup_ops {
  * @scan_timestamp:    [INTERN] set if any buffers have requested timestamp
  * @scan_index_timestamp:[INTERN] cache of the index to the timestamp
  * @trig:              [INTERN] current device trigger (buffer modes)
- * @trig_readonly      [INTERN] mark the current trigger immutable
+ * @trig_readonly:     [INTERN] mark the current trigger immutable
  * @pollfunc:          [DRIVER] function run on trigger being received
  * @pollfunc_event:    [DRIVER] function run on events trigger being received
  * @channels:          [DRIVER] channel specification structure table
index ea08302f2d7b27967fb1f0947dcede46411f396c..7142d8d6e470e13257ee12035f045bdabe1b4d7e 100644 (file)
@@ -144,8 +144,8 @@ void devm_iio_trigger_unregister(struct device *dev,
 /**
  * iio_trigger_set_immutable() - set an immutable trigger on destination
  *
- * @indio_dev - IIO device structure containing the device
- * @trig - trigger to assign to device
+ * @indio_dev: IIO device structure containing the device
+ * @trig: trigger to assign to device
  *
  **/
 int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig);
index 2cb54adc4a334aa3f3a1732c35eaf9749d64b9e8..a7f2ac689d2917e2902e78604e8b6b33df1ee333 100644 (file)
@@ -167,6 +167,10 @@ struct iommu_resv_region {
  * @map: map a physically contiguous memory region to an iommu domain
  * @unmap: unmap a physically contiguous memory region from an iommu domain
  * @map_sg: map a scatter-gather list of physically contiguous memory chunks
+ * @flush_tlb_all: Synchronously flush all hardware TLBs for this domain
+ * @tlb_range_add: Add a given iova range to the flush queue for this domain
+ * @tlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
+ *            queue
  * to an iommu domain
  * @iova_to_phys: translate iova to physical address
  * @add_device: add device to iommu grouping
@@ -199,6 +203,10 @@ struct iommu_ops {
                     size_t size);
        size_t (*map_sg)(struct iommu_domain *domain, unsigned long iova,
                         struct scatterlist *sg, unsigned int nents, int prot);
+       void (*flush_iotlb_all)(struct iommu_domain *domain);
+       void (*iotlb_range_add)(struct iommu_domain *domain,
+                               unsigned long iova, size_t size);
+       void (*iotlb_sync)(struct iommu_domain *domain);
        phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
        int (*add_device)(struct device *dev);
        void (*remove_device)(struct device *dev);
@@ -225,6 +233,7 @@ struct iommu_ops {
        u32 (*domain_get_windows)(struct iommu_domain *domain);
 
        int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
+       bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);
 
        unsigned long pgsize_bitmap;
 };
@@ -240,7 +249,7 @@ struct iommu_device {
        struct list_head list;
        const struct iommu_ops *ops;
        struct fwnode_handle *fwnode;
-       struct device dev;
+       struct device *dev;
 };
 
 int  iommu_device_register(struct iommu_device *iommu);
@@ -265,6 +274,11 @@ static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
        iommu->fwnode = fwnode;
 }
 
+static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
+{
+       return (struct iommu_device *)dev_get_drvdata(dev);
+}
+
 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE          1 /* Device added */
 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE          2 /* Pre Device removed */
 #define IOMMU_GROUP_NOTIFY_BIND_DRIVER         3 /* Pre Driver bind */
@@ -286,7 +300,9 @@ extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
 extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
                     phys_addr_t paddr, size_t size, int prot);
 extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
-                      size_t size);
+                         size_t size);
+extern size_t iommu_unmap_fast(struct iommu_domain *domain,
+                              unsigned long iova, size_t size);
 extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
                                struct scatterlist *sg,unsigned int nents,
                                int prot);
@@ -343,6 +359,25 @@ extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr)
 extern int report_iommu_fault(struct iommu_domain *domain, struct device *dev,
                              unsigned long iova, int flags);
 
+static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
+{
+       if (domain->ops->flush_iotlb_all)
+               domain->ops->flush_iotlb_all(domain);
+}
+
+static inline void iommu_tlb_range_add(struct iommu_domain *domain,
+                                      unsigned long iova, size_t size)
+{
+       if (domain->ops->iotlb_range_add)
+               domain->ops->iotlb_range_add(domain, iova, size);
+}
+
+static inline void iommu_tlb_sync(struct iommu_domain *domain)
+{
+       if (domain->ops->iotlb_sync)
+               domain->ops->iotlb_sync(domain);
+}
+
 static inline size_t iommu_map_sg(struct iommu_domain *domain,
                                  unsigned long iova, struct scatterlist *sg,
                                  unsigned int nents, int prot)
@@ -425,13 +460,19 @@ static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
 }
 
 static inline int iommu_map(struct iommu_domain *domain, unsigned long iova,
-                           phys_addr_t paddr, int gfp_order, int prot)
+                           phys_addr_t paddr, size_t size, int prot)
 {
        return -ENODEV;
 }
 
 static inline int iommu_unmap(struct iommu_domain *domain, unsigned long iova,
-                             int gfp_order)
+                             size_t size)
+{
+       return -ENODEV;
+}
+
+static inline int iommu_unmap_fast(struct iommu_domain *domain, unsigned long iova,
+                                  int gfp_order)
 {
        return -ENODEV;
 }
@@ -443,6 +484,19 @@ static inline size_t iommu_map_sg(struct iommu_domain *domain,
        return -ENODEV;
 }
 
+static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
+{
+}
+
+static inline void iommu_tlb_range_add(struct iommu_domain *domain,
+                                      unsigned long iova, size_t size)
+{
+}
+
+static inline void iommu_tlb_sync(struct iommu_domain *domain)
+{
+}
+
 static inline int iommu_domain_window_enable(struct iommu_domain *domain,
                                             u32 wnd_nr, phys_addr_t paddr,
                                             u64 size, int prot)
@@ -589,6 +643,11 @@ static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
 {
 }
 
+static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
+{
+       return NULL;
+}
+
 static inline void iommu_device_unregister(struct iommu_device *iommu)
 {
 }
index e0a892ae45c0834a82d42e06a6bfab65b424c899..d179b9bf7814767462dbbf592ca75cb78fa0d9fc 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/rbtree.h>
+#include <linux/atomic.h>
 #include <linux/dma-mapping.h>
 
 /* iova structure */
@@ -36,6 +37,35 @@ struct iova_rcache {
        struct iova_cpu_rcache __percpu *cpu_rcaches;
 };
 
+struct iova_domain;
+
+/* Call-Back from IOVA code into IOMMU drivers */
+typedef void (* iova_flush_cb)(struct iova_domain *domain);
+
+/* Destructor for per-entry data */
+typedef void (* iova_entry_dtor)(unsigned long data);
+
+/* Number of entries per Flush Queue */
+#define IOVA_FQ_SIZE   256
+
+/* Timeout (in ms) after which entries are flushed from the Flush-Queue */
+#define IOVA_FQ_TIMEOUT        10
+
+/* Flush Queue entry for defered flushing */
+struct iova_fq_entry {
+       unsigned long iova_pfn;
+       unsigned long pages;
+       unsigned long data;
+       u64 counter; /* Flush counter when this entrie was added */
+};
+
+/* Per-CPU Flush Queue structure */
+struct iova_fq {
+       struct iova_fq_entry entries[IOVA_FQ_SIZE];
+       unsigned head, tail;
+       spinlock_t lock;
+};
+
 /* holds all the iova translations for a domain */
 struct iova_domain {
        spinlock_t      iova_rbtree_lock; /* Lock to protect update of rbtree */
@@ -45,6 +75,25 @@ struct iova_domain {
        unsigned long   start_pfn;      /* Lower limit for this domain */
        unsigned long   dma_32bit_pfn;
        struct iova_rcache rcaches[IOVA_RANGE_CACHE_MAX_SIZE];  /* IOVA range caches */
+
+       iova_flush_cb   flush_cb;       /* Call-Back function to flush IOMMU
+                                          TLBs */
+
+       iova_entry_dtor entry_dtor;     /* IOMMU driver specific destructor for
+                                          iova entry */
+
+       struct iova_fq __percpu *fq;    /* Flush Queue */
+
+       atomic64_t      fq_flush_start_cnt;     /* Number of TLB flushes that
+                                                  have been started */
+
+       atomic64_t      fq_flush_finish_cnt;    /* Number of TLB flushes that
+                                                  have been finished */
+
+       struct timer_list fq_timer;             /* Timer to regularily empty the
+                                                  flush-queues */
+       atomic_t fq_timer_on;                   /* 1 when timer is active, 0
+                                                  when not */
 };
 
 static inline unsigned long iova_size(struct iova *iova)
@@ -95,6 +144,9 @@ struct iova *alloc_iova(struct iova_domain *iovad, unsigned long size,
        bool size_aligned);
 void free_iova_fast(struct iova_domain *iovad, unsigned long pfn,
                    unsigned long size);
+void queue_iova(struct iova_domain *iovad,
+               unsigned long pfn, unsigned long pages,
+               unsigned long data);
 unsigned long alloc_iova_fast(struct iova_domain *iovad, unsigned long size,
                              unsigned long limit_pfn);
 struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,
@@ -102,6 +154,8 @@ struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,
 void copy_reserved_iova(struct iova_domain *from, struct iova_domain *to);
 void init_iova_domain(struct iova_domain *iovad, unsigned long granule,
        unsigned long start_pfn, unsigned long pfn_32bit);
+int init_iova_flush_queue(struct iova_domain *iovad,
+                         iova_flush_cb flush_cb, iova_entry_dtor entry_dtor);
 struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn);
 void put_iova_domain(struct iova_domain *iovad);
 struct iova *split_and_remove_iova(struct iova_domain *iovad,
@@ -148,6 +202,12 @@ static inline void free_iova_fast(struct iova_domain *iovad,
 {
 }
 
+static inline void queue_iova(struct iova_domain *iovad,
+                             unsigned long pfn, unsigned long pages,
+                             unsigned long data)
+{
+}
+
 static inline unsigned long alloc_iova_fast(struct iova_domain *iovad,
                                            unsigned long size,
                                            unsigned long limit_pfn)
@@ -174,6 +234,13 @@ static inline void init_iova_domain(struct iova_domain *iovad,
 {
 }
 
+static inline int init_iova_flush_queue(struct iova_domain *iovad,
+                                       iova_flush_cb flush_cb,
+                                       iova_entry_dtor entry_dtor)
+{
+       return -ENODEV;
+}
+
 static inline struct iova *find_iova(struct iova_domain *iovad,
                                     unsigned long pfn)
 {
index 77d427974f575699d181265a9eb4c8d1cdd4dad5..bae11c7e7bf31920fcf0b928b31dc29ad70f6f8b 100644 (file)
@@ -61,6 +61,7 @@ extern int memblock_debug;
 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
 #define __init_memblock __meminit
 #define __initdata_memblock __meminitdata
+void memblock_discard(void);
 #else
 #define __init_memblock
 #define __initdata_memblock
@@ -74,8 +75,6 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
                                        int nid, ulong flags);
 phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
                                   phys_addr_t size, phys_addr_t align);
-phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
-phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
 void memblock_allow_resize(void);
 int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
 int memblock_add(phys_addr_t base, phys_addr_t size);
@@ -110,6 +109,9 @@ void __next_mem_range_rev(u64 *idx, int nid, ulong flags,
 void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start,
                                phys_addr_t *out_end);
 
+void __memblock_free_early(phys_addr_t base, phys_addr_t size);
+void __memblock_free_late(phys_addr_t base, phys_addr_t size);
+
 /**
  * for_each_mem_range - iterate through memblock areas from type_a and not
  * included in type_b. Or just type_a if type_b is NULL.
index 3914e3dd61680a9bc8814d9b9a386c59611eca81..9b15a4bcfa77dca9c51f88a195a753a018425e53 100644 (file)
@@ -484,7 +484,8 @@ bool mem_cgroup_oom_synchronize(bool wait);
 extern int do_swap_account;
 #endif
 
-void lock_page_memcg(struct page *page);
+struct mem_cgroup *lock_page_memcg(struct page *page);
+void __unlock_page_memcg(struct mem_cgroup *memcg);
 void unlock_page_memcg(struct page *page);
 
 static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
@@ -809,7 +810,12 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
 {
 }
 
-static inline void lock_page_memcg(struct page *page)
+static inline struct mem_cgroup *lock_page_memcg(struct page *page)
+{
+       return NULL;
+}
+
+static inline void __unlock_page_memcg(struct mem_cgroup *memcg)
 {
 }
 
index dda2cc939a531dab67441c6ddf4b7869c6a06159..ebeb48c920054d705924453f6ed6c6aca0233af4 100644 (file)
@@ -37,7 +37,7 @@ struct net;
 
 /* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located
  * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected.
- * Eventually all flags will be in sk->sk_wq_flags.
+ * Eventually all flags will be in sk->sk_wq->flags.
  */
 #define SOCKWQ_ASYNC_NOSPACE   0
 #define SOCKWQ_ASYNC_WAITDATA  1
index 8aa01fd859fb84e5f64e9d7ffb0c20957afdfd2d..a36abe2da13e1a23edc8aa152205af143f658990 100644 (file)
@@ -168,6 +168,14 @@ extern int sysctl_hardlockup_all_cpu_backtrace;
 #define sysctl_softlockup_all_cpu_backtrace 0
 #define sysctl_hardlockup_all_cpu_backtrace 0
 #endif
+
+#if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \
+    defined(CONFIG_HARDLOCKUP_DETECTOR)
+void watchdog_update_hrtimer_threshold(u64 period);
+#else
+static inline void watchdog_update_hrtimer_threshold(u64 period) { }
+#endif
+
 extern bool is_hardlockup(void);
 struct ctl_table;
 extern int proc_watchdog(struct ctl_table *, int ,
index 8a266e2be5a63a29a2de38ff76f0bdc2e4fac08e..76aac4ce39bcf59e2e5eeb38053cf05f0c9d05ae 100644 (file)
@@ -6,6 +6,8 @@
 #include <linux/types.h>
 #include <linux/nodemask.h>
 #include <uapi/linux/oom.h>
+#include <linux/sched/coredump.h> /* MMF_* */
+#include <linux/mm.h> /* VM_FAULT* */
 
 struct zonelist;
 struct notifier_block;
@@ -63,6 +65,26 @@ static inline bool tsk_is_oom_victim(struct task_struct * tsk)
        return tsk->signal->oom_mm;
 }
 
+/*
+ * Checks whether a page fault on the given mm is still reliable.
+ * This is no longer true if the oom reaper started to reap the
+ * address space which is reflected by MMF_UNSTABLE flag set in
+ * the mm. At that moment any !shared mapping would lose the content
+ * and could cause a memory corruption (zero pages instead of the
+ * original content).
+ *
+ * User should call this before establishing a page table entry for
+ * a !shared mapping and under the proper page table lock.
+ *
+ * Return 0 when the PF is safe VM_FAULT_SIGBUS otherwise.
+ */
+static inline int check_stable_address_space(struct mm_struct *mm)
+{
+       if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags)))
+               return VM_FAULT_SIGBUS;
+       return 0;
+}
+
 extern unsigned long oom_badness(struct task_struct *p,
                struct mem_cgroup *memcg, const nodemask_t *nodemask,
                unsigned long totalpages);
index a75c136738529db410baf870f3baafc6e178a5a0..f958d0732af685761c8b996cc6c79ca87f99f43f 100644 (file)
@@ -188,6 +188,8 @@ enum pci_dev_flags {
         * the direct_complete optimization.
         */
        PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11),
+       /* Don't use Relaxed Ordering for TLPs directed at this device */
+       PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 12),
 };
 
 enum pci_irq_reroute_variant {
@@ -1126,6 +1128,7 @@ bool pci_check_pme_status(struct pci_dev *dev);
 void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
+bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
 
 /* PCI Virtual Channel */
 int pci_save_vc_state(struct pci_dev *dev);
index a3b873fc59e41745c78bc31a70f0c71d7e4374c3..b14095bcf4bb40522b66716d4c1e7b59ebf72eb4 100644 (file)
@@ -310,8 +310,8 @@ struct pmu {
         * Notification that the event was mapped or unmapped.  Called
         * in the context of the mapping task.
         */
-       void (*event_mapped)            (struct perf_event *event); /*optional*/
-       void (*event_unmapped)          (struct perf_event *event); /*optional*/
+       void (*event_mapped)            (struct perf_event *event, struct mm_struct *mm); /* optional */
+       void (*event_unmapped)          (struct perf_event *event, struct mm_struct *mm); /* optional */
 
        /*
         * Flags for ->add()/->del()/ ->start()/->stop(). There are
index 4d179316e43108f3a14ef48659a1d3a94ac320fb..719582744a2e873a978dbf9a925e143ec29243da 100644 (file)
@@ -8,7 +8,9 @@ enum pid_type
        PIDTYPE_PID,
        PIDTYPE_PGID,
        PIDTYPE_SID,
-       PIDTYPE_MAX
+       PIDTYPE_MAX,
+       /* only valid to __task_pid_nr_ns() */
+       __PIDTYPE_TGID
 };
 
 /*
index d8c97ec8a8e66d865f516f708a5b3f8fe567da29..37b4bb2545b32dc82633df6b76e629b9999f900b 100644 (file)
@@ -436,9 +436,9 @@ static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r,
        __PTR_RING_PEEK_CALL_v; \
 })
 
-static inline void **__ptr_ring_init_queue_alloc(int size, gfp_t gfp)
+static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp)
 {
-       return kzalloc(ALIGN(size * sizeof(void *), SMP_CACHE_BYTES), gfp);
+       return kcalloc(size, sizeof(void *), gfp);
 }
 
 static inline void __ptr_ring_set_size(struct ptr_ring *r, int size)
@@ -582,7 +582,8 @@ static inline int ptr_ring_resize(struct ptr_ring *r, int size, gfp_t gfp,
  * In particular if you consume ring in interrupt or BH context, you must
  * disable interrupts/BH when doing so.
  */
-static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings,
+static inline int ptr_ring_resize_multiple(struct ptr_ring **rings,
+                                          unsigned int nrings,
                                           int size,
                                           gfp_t gfp, void (*destroy)(void *))
 {
@@ -590,7 +591,7 @@ static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings,
        void ***queues;
        int i;
 
-       queues = kmalloc(nrings * sizeof *queues, gfp);
+       queues = kmalloc_array(nrings, sizeof(*queues), gfp);
        if (!queues)
                goto noqueues;
 
index 8337e2db0bb2e71473f94c283c5e51639ddd8dc8..c05ac5f5aa034db128e9abcdd02e176f21904b8b 100644 (file)
@@ -1163,13 +1163,6 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk)
        return tsk->tgid;
 }
 
-extern pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
-
-static inline pid_t task_tgid_vnr(struct task_struct *tsk)
-{
-       return pid_vnr(task_tgid(tsk));
-}
-
 /**
  * pid_alive - check that a task structure is not stale
  * @p: Task structure to be checked.
@@ -1185,23 +1178,6 @@ static inline int pid_alive(const struct task_struct *p)
        return p->pids[PIDTYPE_PID].pid != NULL;
 }
 
-static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
-{
-       pid_t pid = 0;
-
-       rcu_read_lock();
-       if (pid_alive(tsk))
-               pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
-       rcu_read_unlock();
-
-       return pid;
-}
-
-static inline pid_t task_ppid_nr(const struct task_struct *tsk)
-{
-       return task_ppid_nr_ns(tsk, &init_pid_ns);
-}
-
 static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
 {
        return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
@@ -1223,6 +1199,33 @@ static inline pid_t task_session_vnr(struct task_struct *tsk)
        return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
 }
 
+static inline pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
+{
+       return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, ns);
+}
+
+static inline pid_t task_tgid_vnr(struct task_struct *tsk)
+{
+       return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, NULL);
+}
+
+static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
+{
+       pid_t pid = 0;
+
+       rcu_read_lock();
+       if (pid_alive(tsk))
+               pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
+       rcu_read_unlock();
+
+       return pid;
+}
+
+static inline pid_t task_ppid_nr(const struct task_struct *tsk)
+{
+       return task_ppid_nr_ns(tsk, &init_pid_ns);
+}
+
 /* Obsolete, do not use: */
 static inline pid_t task_pgrp_nr(struct task_struct *tsk)
 {
index 35226cd4efb0f32afcf38cc4a97441e9524424f0..8621ffdeecbf0542e57c2d7fee12f53546af7774 100644 (file)
@@ -193,7 +193,8 @@ static inline int skb_array_resize(struct skb_array *a, int size, gfp_t gfp)
 }
 
 static inline int skb_array_resize_multiple(struct skb_array **rings,
-                                           int nrings, int size, gfp_t gfp)
+                                           int nrings, unsigned int size,
+                                           gfp_t gfp)
 {
        BUILD_BUG_ON(offsetof(struct skb_array, ring));
        return ptr_ring_resize_multiple((struct ptr_ring **)rings,
index 5b74e36c0ca896481acd04bbea92be002ad4ba64..dc19880c02f5eb9091d185c567b961754cfa46e2 100644 (file)
@@ -757,6 +757,43 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
        __ret;                                                                  \
 })
 
+#define __wait_event_killable_timeout(wq_head, condition, timeout)             \
+       ___wait_event(wq_head, ___wait_cond_timeout(condition),                 \
+                     TASK_KILLABLE, 0, timeout,                                \
+                     __ret = schedule_timeout(__ret))
+
+/**
+ * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses
+ * @wq_head: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ * @timeout: timeout, in jiffies
+ *
+ * The process is put to sleep (TASK_KILLABLE) until the
+ * @condition evaluates to true or a kill signal is received.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
+ *
+ * wake_up() has to be called after changing any variable that could
+ * change the result of the wait condition.
+ *
+ * Returns:
+ * 0 if the @condition evaluated to %false after the @timeout elapsed,
+ * 1 if the @condition evaluated to %true after the @timeout elapsed,
+ * the remaining jiffies (at least 1) if the @condition evaluated
+ * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
+ * interrupted by a kill signal.
+ *
+ * Only kill signals interrupt this process.
+ */
+#define wait_event_killable_timeout(wq_head, condition, timeout)               \
+({                                                                             \
+       long __ret = timeout;                                                   \
+       might_sleep();                                                          \
+       if (!___wait_cond_timeout(condition))                                   \
+               __ret = __wait_event_killable_timeout(wq_head,                  \
+                                               condition, timeout);            \
+       __ret;                                                                  \
+})
+
 
 #define __wait_event_lock_irq(wq_head, condition, lock, cmd)                   \
        (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0,     \
index 6df79e96a780b3bf0c141fee5b43eded5276775c..f44ff2476758e27ad9f9cc20d96d96f16e5ee98c 100644 (file)
@@ -336,6 +336,16 @@ static inline void in6_dev_put(struct inet6_dev *idev)
                in6_dev_finish_destroy(idev);
 }
 
+static inline void in6_dev_put_clear(struct inet6_dev **pidev)
+{
+       struct inet6_dev *idev = *pidev;
+
+       if (idev) {
+               in6_dev_put(idev);
+               *pidev = NULL;
+       }
+}
+
 static inline void __in6_dev_put(struct inet6_dev *idev)
 {
        refcount_dec(&idev->refcnt);
index b00508d22e0a6adc37ee4e69187377fea3bc102d..b2e68657a2162cd55b957c9230779f5d066fe6f3 100644 (file)
@@ -277,6 +277,11 @@ static inline bool bond_is_lb(const struct bonding *bond)
               BOND_MODE(bond) == BOND_MODE_ALB;
 }
 
+static inline bool bond_needs_speed_duplex(const struct bonding *bond)
+{
+       return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond);
+}
+
 static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
 {
        return (BOND_MODE(bond) == BOND_MODE_TLB)  &&
index 8ffd434676b7a270af73534f3dbcc26f370fe215..71c72a939bf8b21c5102994ea68796dc89c4f097 100644 (file)
 #include <linux/sched/signal.h>
 #include <net/ip.h>
 
-#ifdef CONFIG_NET_RX_BUSY_POLL
-
-struct napi_struct;
-extern unsigned int sysctl_net_busy_read __read_mostly;
-extern unsigned int sysctl_net_busy_poll __read_mostly;
-
 /*             0 - Reserved to indicate value not set
  *     1..NR_CPUS - Reserved for sender_cpu
  *  NR_CPUS+1..~0 - Region available for NAPI IDs
  */
 #define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
 
+#ifdef CONFIG_NET_RX_BUSY_POLL
+
+struct napi_struct;
+extern unsigned int sysctl_net_busy_read __read_mostly;
+extern unsigned int sysctl_net_busy_poll __read_mostly;
+
 static inline bool net_busy_loop_on(void)
 {
        return sysctl_net_busy_poll;
index 821cedcc8e73b68af72d1918242c25d757c63d24..0cf7f5a65fe6be2be30259aa5cd251d02de489d5 100644 (file)
@@ -352,7 +352,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
            !forwarding)
                return dst_mtu(dst);
 
-       return min(dst->dev->mtu, IP_MAX_MTU);
+       return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU);
 }
 
 static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
@@ -364,7 +364,7 @@ static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
                return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding);
        }
 
-       return min(skb_dst(skb)->dev->mtu, IP_MAX_MTU);
+       return min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU);
 }
 
 u32 ip_idents_reserve(u32 hash, int segs);
index b2b5419467cc123b4a2b70c2d926b4576651248d..f8149ca192b430c181406fa9a3e4db8fc0a17252 100644 (file)
@@ -5499,6 +5499,21 @@ static inline void ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif,
        ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS);
 }
 
+/**
+ * ieee80211_rx_ba_timer_expired - stop a Rx BA session due to timeout
+ *
+ * Some device drivers do not offload AddBa/DelBa negotiation, but handle rx
+ * buffer reording internally, and therefore also handle the session timer.
+ *
+ * Trigger the timeout flow, which sends a DelBa.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback
+ * @addr: station mac address
+ * @tid: the rx tid
+ */
+void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
+                                  const u8 *addr, unsigned int tid);
+
 /* Rate control API */
 
 /**
index 1c123e2b2415797e7d32a0248df817cb9fbcb0c9..67f815e5d52517390226bc3531b1ea7b5f1020bc 100644 (file)
@@ -806,8 +806,11 @@ static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
        old = *pold;
        *pold = new;
        if (old != NULL) {
-               qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog);
+               unsigned int qlen = old->q.qlen;
+               unsigned int backlog = old->qstats.backlog;
+
                qdisc_reset(old);
+               qdisc_tree_reduce_backlog(old, qlen, backlog);
        }
        sch_tree_unlock(sch);
 
index 7c0632c7e87043ca18fe5d32d7d55792f75ca6e8..aeeec62992ca7dc5ff80f8d7164a1c143f606b03 100644 (file)
@@ -507,9 +507,7 @@ int sk_set_peek_off(struct sock *sk, int val);
 static inline int sk_peek_offset(struct sock *sk, int flags)
 {
        if (unlikely(flags & MSG_PEEK)) {
-               s32 off = READ_ONCE(sk->sk_peek_off);
-               if (off >= 0)
-                       return off;
+               return READ_ONCE(sk->sk_peek_off);
        }
 
        return 0;
index cc8036987dcb885012c6c5eda0fb2bed2e588841..586de4b811b5678c72a045a3ede9852164b9b3e2 100644 (file)
@@ -366,12 +366,13 @@ static inline bool udp_skb_is_linear(struct sk_buff *skb)
 static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
                                  struct iov_iter *to)
 {
-       int n, copy = len - off;
+       int n;
 
-       n = copy_to_iter(skb->data + off, copy, to);
-       if (n == copy)
+       n = copy_to_iter(skb->data + off, len, to);
+       if (n == len)
                return 0;
 
+       iov_iter_revert(to, n);
        return -EFAULT;
 }
 
index b5732432bb297dbf6067ae34b16c00073cb2949d..88c32aba32f71b15370e2d4b5cc724c31feed9d3 100644 (file)
@@ -1683,6 +1683,7 @@ struct ib_qp {
        enum ib_qp_type         qp_type;
        struct ib_rwq_ind_table *rwq_ind_tbl;
        struct ib_qp_security  *qp_sec;
+       u8                      port;
 };
 
 struct ib_mr {
index a1266d318c855dec12dbb41a6bb1ab9e4dc27f08..6af198d8120b098f31d674f15584ec7114832743 100644 (file)
@@ -57,6 +57,7 @@ struct scsi_pointer {
 /* for scmd->flags */
 #define SCMD_TAGGED            (1 << 0)
 #define SCMD_UNCHECKED_ISA_DMA (1 << 1)
+#define SCMD_ZONE_WRITE_LOCK   (1 << 2)
 
 struct scsi_cmnd {
        struct scsi_request req;
index 8893c5eacd07e1ed5169bba2cff3ebf5ab6dc562..5201e9022c86fa90a580735d886dddfa7e9144dd 100644 (file)
@@ -19,7 +19,7 @@
 
 #ifdef CONFIG_MTK_SMI
 
-#define MTK_LARB_NR_MAX                8
+#define MTK_LARB_NR_MAX                16
 
 #define MTK_SMI_MMU_EN(port)   BIT(port)
 
index a3960f98679c13567c3db4ecb7919cd14a70cfb0..c8125ec1f4f2270a5a01a358832425cd57edb11a 100644 (file)
@@ -22,7 +22,6 @@ enum {
        LO_FLAGS_AUTOCLEAR      = 4,
        LO_FLAGS_PARTSCAN       = 8,
        LO_FLAGS_DIRECT_IO      = 16,
-       LO_FLAGS_BLOCKSIZE      = 32,
 };
 
 #include <asm/posix_types.h>   /* for __kernel_old_dev_t */
@@ -60,8 +59,6 @@ struct loop_info64 {
        __u64              lo_init[2];
 };
 
-#define LO_INFO_BLOCKSIZE(l) (l)->lo_init[0]
-
 /*
  * Loop filter types
  */
index 62d686d965813aeb4b8ef34877e886e08bd71912..9eb8b3511636e96e0607be2484119823b1034fb5 100644 (file)
@@ -66,7 +66,7 @@ static struct fsnotify_group *audit_watch_group;
 
 /* fsnotify events we care about. */
 #define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\
-                       FS_MOVE_SELF | FS_EVENT_ON_CHILD)
+                       FS_MOVE_SELF | FS_EVENT_ON_CHILD | FS_UNMOUNT)
 
 static void audit_free_parent(struct audit_parent *parent)
 {
@@ -457,13 +457,15 @@ void audit_remove_watch_rule(struct audit_krule *krule)
        list_del(&krule->rlist);
 
        if (list_empty(&watch->rules)) {
+               /*
+                * audit_remove_watch() drops our reference to 'parent' which
+                * can get freed. Grab our own reference to be safe.
+                */
+               audit_get_parent(parent);
                audit_remove_watch(watch);
-
-               if (list_empty(&parent->watches)) {
-                       audit_get_parent(parent);
+               if (list_empty(&parent->watches))
                        fsnotify_destroy_mark(&parent->mark, audit_watch_group);
-                       audit_put_parent(parent);
-               }
+               audit_put_parent(parent);
        }
 }
 
index 426c2ffba16d4ce1474a798a4c43d78d5abedb1e..3504125871d2f058fa717638e785b9c85220213a 100644 (file)
@@ -2217,6 +2217,33 @@ static int group_can_go_on(struct perf_event *event,
        return can_add_hw;
 }
 
+/*
+ * Complement to update_event_times(). This computes the tstamp_* values to
+ * continue 'enabled' state from @now, and effectively discards the time
+ * between the prior tstamp_stopped and now (as we were in the OFF state, or
+ * just switched (context) time base).
+ *
+ * This further assumes '@event->state == INACTIVE' (we just came from OFF) and
+ * cannot have been scheduled in yet. And going into INACTIVE state means
+ * '@event->tstamp_stopped = @now'.
+ *
+ * Thus given the rules of update_event_times():
+ *
+ *   total_time_enabled = tstamp_stopped - tstamp_enabled
+ *   total_time_running = tstamp_stopped - tstamp_running
+ *
+ * We can insert 'tstamp_stopped == now' and reverse them to compute new
+ * tstamp_* values.
+ */
+static void __perf_event_enable_time(struct perf_event *event, u64 now)
+{
+       WARN_ON_ONCE(event->state != PERF_EVENT_STATE_INACTIVE);
+
+       event->tstamp_stopped = now;
+       event->tstamp_enabled = now - event->total_time_enabled;
+       event->tstamp_running = now - event->total_time_running;
+}
+
 static void add_event_to_ctx(struct perf_event *event,
                               struct perf_event_context *ctx)
 {
@@ -2224,9 +2251,12 @@ static void add_event_to_ctx(struct perf_event *event,
 
        list_add_event(event, ctx);
        perf_group_attach(event);
-       event->tstamp_enabled = tstamp;
-       event->tstamp_running = tstamp;
-       event->tstamp_stopped = tstamp;
+       /*
+        * We can be called with event->state == STATE_OFF when we create with
+        * .disabled = 1. In that case the IOC_ENABLE will call this function.
+        */
+       if (event->state == PERF_EVENT_STATE_INACTIVE)
+               __perf_event_enable_time(event, tstamp);
 }
 
 static void ctx_sched_out(struct perf_event_context *ctx,
@@ -2471,10 +2501,11 @@ static void __perf_event_mark_enabled(struct perf_event *event)
        u64 tstamp = perf_event_time(event);
 
        event->state = PERF_EVENT_STATE_INACTIVE;
-       event->tstamp_enabled = tstamp - event->total_time_enabled;
+       __perf_event_enable_time(event, tstamp);
        list_for_each_entry(sub, &event->sibling_list, group_entry) {
+               /* XXX should not be > INACTIVE if event isn't */
                if (sub->state >= PERF_EVENT_STATE_INACTIVE)
-                       sub->tstamp_enabled = tstamp - sub->total_time_enabled;
+                       __perf_event_enable_time(sub, tstamp);
        }
 }
 
@@ -5090,7 +5121,7 @@ static void perf_mmap_open(struct vm_area_struct *vma)
                atomic_inc(&event->rb->aux_mmap_count);
 
        if (event->pmu->event_mapped)
-               event->pmu->event_mapped(event);
+               event->pmu->event_mapped(event, vma->vm_mm);
 }
 
 static void perf_pmu_output_stop(struct perf_event *event);
@@ -5113,7 +5144,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
        unsigned long size = perf_data_size(rb);
 
        if (event->pmu->event_unmapped)
-               event->pmu->event_unmapped(event);
+               event->pmu->event_unmapped(event, vma->vm_mm);
 
        /*
         * rb->aux_mmap_count will always drop before rb->mmap_count and
@@ -5411,7 +5442,7 @@ aux_unlock:
        vma->vm_ops = &perf_mmap_vmops;
 
        if (event->pmu->event_mapped)
-               event->pmu->event_mapped(event);
+               event->pmu->event_mapped(event, vma->vm_mm);
 
        return ret;
 }
@@ -10001,28 +10032,27 @@ SYSCALL_DEFINE5(perf_event_open,
                        goto err_context;
 
                /*
-                * Do not allow to attach to a group in a different
-                * task or CPU context:
+                * Make sure we're both events for the same CPU;
+                * grouping events for different CPUs is broken; since
+                * you can never concurrently schedule them anyhow.
                 */
-               if (move_group) {
-                       /*
-                        * Make sure we're both on the same task, or both
-                        * per-cpu events.
-                        */
-                       if (group_leader->ctx->task != ctx->task)
-                               goto err_context;
+               if (group_leader->cpu != event->cpu)
+                       goto err_context;
 
-                       /*
-                        * Make sure we're both events for the same CPU;
-                        * grouping events for different CPUs is broken; since
-                        * you can never concurrently schedule them anyhow.
-                        */
-                       if (group_leader->cpu != event->cpu)
-                               goto err_context;
-               } else {
-                       if (group_leader->ctx != ctx)
-                               goto err_context;
-               }
+               /*
+                * Make sure we're both on the same task, or both
+                * per-CPU events.
+                */
+               if (group_leader->ctx->task != ctx->task)
+                       goto err_context;
+
+               /*
+                * Do not allow to attach to a group in a different task
+                * or CPU context. If we're moving SW events, we'll fix
+                * this up later, so allow that.
+                */
+               if (!move_group && group_leader->ctx != ctx)
+                       goto err_context;
 
                /*
                 * Only a group leader can be exclusive or pinned
index e075b7780421dee1d8243b9dc178248398c5f189..cbbea277b3fba7a8a1ff73ffaf620202a706036a 100644 (file)
@@ -806,6 +806,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
        mm_init_cpumask(mm);
        mm_init_aio(mm);
        mm_init_owner(mm, p);
+       RCU_INIT_POINTER(mm->exe_file, NULL);
        mmu_notifier_mm_init(mm);
        init_tlb_flush_pending(mm);
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
index a3cc37c0c85e2267497f650611b656af90aaf5aa..3675c6004f2a68c9d60493c7c46e9c46a0baa73f 100644 (file)
@@ -1000,7 +1000,7 @@ EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name);
 
 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 {
-       unsigned long flags;
+       unsigned long flags, trigger, tmp;
        struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
 
        if (!desc)
@@ -1014,6 +1014,8 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 
        irq_settings_clr_and_set(desc, clr, set);
 
+       trigger = irqd_get_trigger_type(&desc->irq_data);
+
        irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
                   IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
        if (irq_settings_has_no_balance_set(desc))
@@ -1025,7 +1027,11 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
        if (irq_settings_is_level(desc))
                irqd_set(&desc->irq_data, IRQD_LEVEL);
 
-       irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
+       tmp = irq_settings_get_trigger_mask(desc);
+       if (tmp != IRQ_TYPE_NONE)
+               trigger = tmp;
+
+       irqd_set(&desc->irq_data, trigger);
 
        irq_put_desc_unlock(desc, flags);
 }
index 1a9abc1c8ea0046d6491d1786645f1c1e4e1eee2..259a22aa9934cf9d67eb779e5e3eae22db0a3412 100644 (file)
@@ -165,7 +165,7 @@ irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu)
        struct irq_data *data = irq_get_irq_data(irq);
        struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
 
-       if (!data || !ipimask || cpu > nr_cpu_ids)
+       if (!data || !ipimask || cpu >= nr_cpu_ids)
                return INVALID_HWIRQ;
 
        if (!cpumask_test_cpu(cpu, ipimask))
@@ -195,7 +195,7 @@ static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data,
        if (!chip->ipi_send_single && !chip->ipi_send_mask)
                return -EINVAL;
 
-       if (cpu > nr_cpu_ids)
+       if (cpu >= nr_cpu_ids)
                return -EINVAL;
 
        if (dest) {
index 6d016c5d97c8390f561e6a9456a4e0c1ca59bffe..2f37acde640b6c6e2ce73933a52dbad65f014cf3 100644 (file)
@@ -70,6 +70,18 @@ static DECLARE_RWSEM(umhelper_sem);
 static atomic_t kmod_concurrent_max = ATOMIC_INIT(MAX_KMOD_CONCURRENT);
 static DECLARE_WAIT_QUEUE_HEAD(kmod_wq);
 
+/*
+ * This is a restriction on having *all* MAX_KMOD_CONCURRENT threads
+ * running at the same time without returning. When this happens we
+ * believe you've somehow ended up with a recursive module dependency
+ * creating a loop.
+ *
+ * We have no option but to fail.
+ *
+ * Userspace should proactively try to detect and prevent these.
+ */
+#define MAX_KMOD_ALL_BUSY_TIMEOUT 5
+
 /*
        modprobe_path is set via /proc/sys.
 */
@@ -167,8 +179,17 @@ int __request_module(bool wait, const char *fmt, ...)
                pr_warn_ratelimited("request_module: kmod_concurrent_max (%u) close to 0 (max_modprobes: %u), for module %s, throttling...",
                                    atomic_read(&kmod_concurrent_max),
                                    MAX_KMOD_CONCURRENT, module_name);
-               wait_event_interruptible(kmod_wq,
-                                        atomic_dec_if_positive(&kmod_concurrent_max) >= 0);
+               ret = wait_event_killable_timeout(kmod_wq,
+                                                 atomic_dec_if_positive(&kmod_concurrent_max) >= 0,
+                                                 MAX_KMOD_ALL_BUSY_TIMEOUT * HZ);
+               if (!ret) {
+                       pr_warn_ratelimited("request_module: modprobe %s cannot be processed, kmod busy with %d threads for more than %d seconds now",
+                                           module_name, MAX_KMOD_CONCURRENT, MAX_KMOD_ALL_BUSY_TIMEOUT);
+                       return -ETIME;
+               } else if (ret == -ERESTARTSYS) {
+                       pr_warn_ratelimited("request_module: sigkill sent for modprobe %s, giving up", module_name);
+                       return ret;
+               }
        }
 
        trace_module_request(module_name, wait, _RET_IP_);
index c69c30d827e5a2fc2605c6449617eb3754d8479b..020dedbdf066bccbc370cba20be8dc7dbc914629 100644 (file)
@@ -527,8 +527,11 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
        if (!ns)
                ns = task_active_pid_ns(current);
        if (likely(pid_alive(task))) {
-               if (type != PIDTYPE_PID)
+               if (type != PIDTYPE_PID) {
+                       if (type == __PIDTYPE_TGID)
+                               type = PIDTYPE_PID;
                        task = task->group_leader;
+               }
                nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns);
        }
        rcu_read_unlock();
@@ -537,12 +540,6 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
 }
 EXPORT_SYMBOL(__task_pid_nr_ns);
 
-pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
-{
-       return pid_nr_ns(task_tgid(tsk), ns);
-}
-EXPORT_SYMBOL(task_tgid_nr_ns);
-
 struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
 {
        return ns_of_pid(task_pid(tsk));
index 17f11c6b0a9f7a87010c17d3b775739d7e0d93a1..d6afed6d0752c6cdd09a094d61d0bcae9184f865 100644 (file)
@@ -70,9 +70,10 @@ static void __wake_up_common(struct wait_queue_head *wq_head, unsigned int mode,
 
        list_for_each_entry_safe(curr, next, &wq_head->head, entry) {
                unsigned flags = curr->flags;
-
-               if (curr->func(curr, mode, wake_flags, key) &&
-                               (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
+               int ret = curr->func(curr, mode, wake_flags, key);
+               if (ret < 0)
+                       break;
+               if (ret && (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
                        break;
        }
 }
index 7e33f8c583e64c91d7cb6ac1fb330b01299b7be2..ed804a470dcd151c18915f956c2f325b6d22bb0f 100644 (file)
@@ -1194,7 +1194,11 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
                        recalc_sigpending_and_wake(t);
                }
        }
-       if (action->sa.sa_handler == SIG_DFL)
+       /*
+        * Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect
+        * debugging to leave init killable.
+        */
+       if (action->sa.sa_handler == SIG_DFL && !t->ptrace)
                t->signal->flags &= ~SIGNAL_UNKILLABLE;
        ret = specific_send_sig_info(sig, info, t);
        spin_unlock_irqrestore(&t->sighand->siglock, flags);
index 8f5d1bf18854593e6fa27730d07a99c6700ab45c..f2674a056c268a58e0525194ea225fcd0bd9e1d5 100644 (file)
@@ -203,6 +203,7 @@ struct timer_base {
        bool                    migration_enabled;
        bool                    nohz_active;
        bool                    is_idle;
+       bool                    must_forward_clk;
        DECLARE_BITMAP(pending_map, WHEEL_SIZE);
        struct hlist_head       vectors[WHEEL_SIZE];
 } ____cacheline_aligned;
@@ -856,13 +857,19 @@ get_target_base(struct timer_base *base, unsigned tflags)
 
 static inline void forward_timer_base(struct timer_base *base)
 {
-       unsigned long jnow = READ_ONCE(jiffies);
+       unsigned long jnow;
 
        /*
-        * We only forward the base when it's idle and we have a delta between
-        * base clock and jiffies.
+        * We only forward the base when we are idle or have just come out of
+        * idle (must_forward_clk logic), and have a delta between base clock
+        * and jiffies. In the common case, run_timers will take care of it.
         */
-       if (!base->is_idle || (long) (jnow - base->clk) < 2)
+       if (likely(!base->must_forward_clk))
+               return;
+
+       jnow = READ_ONCE(jiffies);
+       base->must_forward_clk = base->is_idle;
+       if ((long)(jnow - base->clk) < 2)
                return;
 
        /*
@@ -938,6 +945,11 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
         * same array bucket then just return:
         */
        if (timer_pending(timer)) {
+               /*
+                * The downside of this optimization is that it can result in
+                * larger granularity than you would get from adding a new
+                * timer with this expiry.
+                */
                if (timer->expires == expires)
                        return 1;
 
@@ -948,6 +960,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                 * dequeue/enqueue dance.
                 */
                base = lock_timer_base(timer, &flags);
+               forward_timer_base(base);
 
                clk = base->clk;
                idx = calc_wheel_index(expires, clk);
@@ -964,6 +977,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                }
        } else {
                base = lock_timer_base(timer, &flags);
+               forward_timer_base(base);
        }
 
        ret = detach_if_pending(timer, base, false);
@@ -991,12 +1005,10 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                        raw_spin_lock(&base->lock);
                        WRITE_ONCE(timer->flags,
                                   (timer->flags & ~TIMER_BASEMASK) | base->cpu);
+                       forward_timer_base(base);
                }
        }
 
-       /* Try to forward a stale timer base clock */
-       forward_timer_base(base);
-
        timer->expires = expires;
        /*
         * If 'idx' was calculated above and the base time did not advance
@@ -1112,6 +1124,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
                WRITE_ONCE(timer->flags,
                           (timer->flags & ~TIMER_BASEMASK) | cpu);
        }
+       forward_timer_base(base);
 
        debug_activate(timer, timer->expires);
        internal_add_timer(base, timer);
@@ -1497,10 +1510,16 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
                if (!is_max_delta)
                        expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
                /*
-                * If we expect to sleep more than a tick, mark the base idle:
+                * If we expect to sleep more than a tick, mark the base idle.
+                * Also the tick is stopped so any added timer must forward
+                * the base clk itself to keep granularity small. This idle
+                * logic is only maintained for the BASE_STD base, deferrable
+                * timers may still see large granularity skew (by design).
                 */
-               if ((expires - basem) > TICK_NSEC)
+               if ((expires - basem) > TICK_NSEC) {
+                       base->must_forward_clk = true;
                        base->is_idle = true;
+               }
        }
        raw_spin_unlock(&base->lock);
 
@@ -1611,6 +1630,19 @@ static __latent_entropy void run_timer_softirq(struct softirq_action *h)
 {
        struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
 
+       /*
+        * must_forward_clk must be cleared before running timers so that any
+        * timer functions that call mod_timer will not try to forward the
+        * base. idle trcking / clock forwarding logic is only used with
+        * BASE_STD timers.
+        *
+        * The deferrable base does not do idle tracking at all, so we do
+        * not forward it. This can result in very large variations in
+        * granularity for deferrable timers, but they can be deferred for
+        * long periods due to idle.
+        */
+       base->must_forward_clk = false;
+
        __run_timers(base);
        if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && base->nohz_active)
                __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF]));
index 37385193a6084ed1b8fdd794eb0938c2021fcfa4..dc498b605d5dd36137eaba7bd0ee93da72a36c33 100644 (file)
@@ -204,10 +204,36 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
                fmt_cnt++;
        }
 
-       return __trace_printk(1/* fake ip will not be printed */, fmt,
-                             mod[0] == 2 ? arg1 : mod[0] == 1 ? (long) arg1 : (u32) arg1,
-                             mod[1] == 2 ? arg2 : mod[1] == 1 ? (long) arg2 : (u32) arg2,
-                             mod[2] == 2 ? arg3 : mod[2] == 1 ? (long) arg3 : (u32) arg3);
+/* Horrid workaround for getting va_list handling working with different
+ * argument type combinations generically for 32 and 64 bit archs.
+ */
+#define __BPF_TP_EMIT()        __BPF_ARG3_TP()
+#define __BPF_TP(...)                                                  \
+       __trace_printk(1 /* Fake ip will not be printed. */,            \
+                      fmt, ##__VA_ARGS__)
+
+#define __BPF_ARG1_TP(...)                                             \
+       ((mod[0] == 2 || (mod[0] == 1 && __BITS_PER_LONG == 64))        \
+         ? __BPF_TP(arg1, ##__VA_ARGS__)                               \
+         : ((mod[0] == 1 || (mod[0] == 0 && __BITS_PER_LONG == 32))    \
+             ? __BPF_TP((long)arg1, ##__VA_ARGS__)                     \
+             : __BPF_TP((u32)arg1, ##__VA_ARGS__)))
+
+#define __BPF_ARG2_TP(...)                                             \
+       ((mod[1] == 2 || (mod[1] == 1 && __BITS_PER_LONG == 64))        \
+         ? __BPF_ARG1_TP(arg2, ##__VA_ARGS__)                          \
+         : ((mod[1] == 1 || (mod[1] == 0 && __BITS_PER_LONG == 32))    \
+             ? __BPF_ARG1_TP((long)arg2, ##__VA_ARGS__)                \
+             : __BPF_ARG1_TP((u32)arg2, ##__VA_ARGS__)))
+
+#define __BPF_ARG3_TP(...)                                             \
+       ((mod[2] == 2 || (mod[2] == 1 && __BITS_PER_LONG == 64))        \
+         ? __BPF_ARG2_TP(arg3, ##__VA_ARGS__)                          \
+         : ((mod[2] == 1 || (mod[2] == 0 && __BITS_PER_LONG == 32))    \
+             ? __BPF_ARG2_TP((long)arg3, ##__VA_ARGS__)                \
+             : __BPF_ARG2_TP((u32)arg3, ##__VA_ARGS__)))
+
+       return __BPF_TP_EMIT();
 }
 
 static const struct bpf_func_proto bpf_trace_printk_proto = {
index 02004ae918608f915b28341b6ed1b3b7f551c5a5..96cea88fa00fcdab41db0a2054ef6cfe50a778aa 100644 (file)
@@ -889,6 +889,10 @@ static int profile_graph_entry(struct ftrace_graph_ent *trace)
 
        function_profile_call(trace->func, 0, NULL, NULL);
 
+       /* If function graph is shutting down, ret_stack can be NULL */
+       if (!current->ret_stack)
+               return 0;
+
        if (index >= 0 && index < FTRACE_RETFUNC_DEPTH)
                current->ret_stack[index].subtime = 0;
 
index 529cc50d7243d6c1007e517bcdc83a5312f7ae6b..81279c6602ff1753d8c38c8def566c3576578962 100644 (file)
@@ -4386,15 +4386,19 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
  * the page that was allocated, with the read page of the buffer.
  *
  * Returns:
- *  The page allocated, or NULL on error.
+ *  The page allocated, or ERR_PTR
  */
 void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu)
 {
-       struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
+       struct ring_buffer_per_cpu *cpu_buffer;
        struct buffer_data_page *bpage = NULL;
        unsigned long flags;
        struct page *page;
 
+       if (!cpumask_test_cpu(cpu, buffer->cpumask))
+               return ERR_PTR(-ENODEV);
+
+       cpu_buffer = buffer->buffers[cpu];
        local_irq_save(flags);
        arch_spin_lock(&cpu_buffer->lock);
 
@@ -4412,7 +4416,7 @@ void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu)
        page = alloc_pages_node(cpu_to_node(cpu),
                                GFP_KERNEL | __GFP_NORETRY, 0);
        if (!page)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        bpage = page_address(page);
 
@@ -4467,8 +4471,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_free_read_page);
  *
  * for example:
  *     rpage = ring_buffer_alloc_read_page(buffer, cpu);
- *     if (!rpage)
- *             return error;
+ *     if (IS_ERR(rpage))
+ *             return PTR_ERR(rpage);
  *     ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0);
  *     if (ret >= 0)
  *             process_page(rpage, ret);
index 9fbcaf56788626335bfd5412dffaf820a9b308bc..68ee79afe31c223218e8fab1ffd829b7be1226d3 100644 (file)
@@ -113,7 +113,7 @@ static enum event_status read_page(int cpu)
        int i;
 
        bpage = ring_buffer_alloc_read_page(buffer, cpu);
-       if (!bpage)
+       if (IS_ERR(bpage))
                return EVENT_DROPPED;
 
        ret = ring_buffer_read_page(buffer, &bpage, PAGE_SIZE, cpu, 1);
index 42b9355033d45d5a7c27bf0606799772e70d7421..44004d8aa3b33f259ed90dd13ce4c102034da23a 100644 (file)
@@ -6598,7 +6598,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
 {
        struct ftrace_buffer_info *info = filp->private_data;
        struct trace_iterator *iter = &info->iter;
-       ssize_t ret;
+       ssize_t ret = 0;
        ssize_t size;
 
        if (!count)
@@ -6612,10 +6612,15 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
        if (!info->spare) {
                info->spare = ring_buffer_alloc_read_page(iter->trace_buffer->buffer,
                                                          iter->cpu_file);
-               info->spare_cpu = iter->cpu_file;
+               if (IS_ERR(info->spare)) {
+                       ret = PTR_ERR(info->spare);
+                       info->spare = NULL;
+               } else {
+                       info->spare_cpu = iter->cpu_file;
+               }
        }
        if (!info->spare)
-               return -ENOMEM;
+               return ret;
 
        /* Do we have previous read data to read? */
        if (info->read < PAGE_SIZE)
@@ -6790,8 +6795,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
                ref->ref = 1;
                ref->buffer = iter->trace_buffer->buffer;
                ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
-               if (!ref->page) {
-                       ret = -ENOMEM;
+               if (IS_ERR(ref->page)) {
+                       ret = PTR_ERR(ref->page);
+                       ref->page = NULL;
                        kfree(ref);
                        break;
                }
@@ -8293,6 +8299,7 @@ __init static int tracer_alloc_buffers(void)
        if (ret < 0)
                goto out_free_cpumask;
        /* Used for event triggers */
+       ret = -ENOMEM;
        temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE);
        if (!temp_buffer)
                goto out_rm_hp_state;
@@ -8407,4 +8414,4 @@ __init static int clear_boot_tracer(void)
 }
 
 fs_initcall(tracer_init_tracefs);
-late_initcall(clear_boot_tracer);
+late_initcall_sync(clear_boot_tracer);
index 59a411ff60c709834121fc70363c74560dfe1ff5..181e139a8057bed695ad6d1d7460036e378f5ca0 100644 (file)
@@ -1959,6 +1959,10 @@ static int create_filter(struct trace_event_call *call,
                if (err && set_str)
                        append_filter_err(ps, filter);
        }
+       if (err && !set_str) {
+               free_event_filter(filter);
+               filter = NULL;
+       }
        create_filter_finish(ps);
 
        *filterp = filter;
index 0a689bbb78ef4fe48d9e55cb867e836aea87a726..305039b122fafba242f73b5982289ce4a12a6e20 100644 (file)
@@ -221,16 +221,19 @@ void tracing_map_array_free(struct tracing_map_array *a)
        if (!a)
                return;
 
-       if (!a->pages) {
-               kfree(a);
-               return;
-       }
+       if (!a->pages)
+               goto free;
 
        for (i = 0; i < a->n_pages; i++) {
                if (!a->pages[i])
                        break;
                free_page((unsigned long)a->pages[i]);
        }
+
+       kfree(a->pages);
+
+ free:
+       kfree(a);
 }
 
 struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts,
index 06d3389bca0df01c8a730f7b270767f6ed35a8a9..f5d52024f6b72a9d1354b1a44c12c3e3b6af06a9 100644 (file)
@@ -240,6 +240,7 @@ static void set_sample_period(void)
         * hardlockup detector generates a warning
         */
        sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
+       watchdog_update_hrtimer_threshold(sample_period);
 }
 
 /* Commands for resetting the watchdog */
index 295a0d84934cb1d3a9a87abd4a8ac0f1d38656a5..3a09ea1b1d3d5e6e284d058052403ac1396804ca 100644 (file)
@@ -37,6 +37,62 @@ void arch_touch_nmi_watchdog(void)
 }
 EXPORT_SYMBOL(arch_touch_nmi_watchdog);
 
+#ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP
+static DEFINE_PER_CPU(ktime_t, last_timestamp);
+static DEFINE_PER_CPU(unsigned int, nmi_rearmed);
+static ktime_t watchdog_hrtimer_sample_threshold __read_mostly;
+
+void watchdog_update_hrtimer_threshold(u64 period)
+{
+       /*
+        * The hrtimer runs with a period of (watchdog_threshold * 2) / 5
+        *
+        * So it runs effectively with 2.5 times the rate of the NMI
+        * watchdog. That means the hrtimer should fire 2-3 times before
+        * the NMI watchdog expires. The NMI watchdog on x86 is based on
+        * unhalted CPU cycles, so if Turbo-Mode is enabled the CPU cycles
+        * might run way faster than expected and the NMI fires in a
+        * smaller period than the one deduced from the nominal CPU
+        * frequency. Depending on the Turbo-Mode factor this might be fast
+        * enough to get the NMI period smaller than the hrtimer watchdog
+        * period and trigger false positives.
+        *
+        * The sample threshold is used to check in the NMI handler whether
+        * the minimum time between two NMI samples has elapsed. That
+        * prevents false positives.
+        *
+        * Set this to 4/5 of the actual watchdog threshold period so the
+        * hrtimer is guaranteed to fire at least once within the real
+        * watchdog threshold.
+        */
+       watchdog_hrtimer_sample_threshold = period * 2;
+}
+
+static bool watchdog_check_timestamp(void)
+{
+       ktime_t delta, now = ktime_get_mono_fast_ns();
+
+       delta = now - __this_cpu_read(last_timestamp);
+       if (delta < watchdog_hrtimer_sample_threshold) {
+               /*
+                * If ktime is jiffies based, a stalled timer would prevent
+                * jiffies from being incremented and the filter would look
+                * at a stale timestamp and never trigger.
+                */
+               if (__this_cpu_inc_return(nmi_rearmed) < 10)
+                       return false;
+       }
+       __this_cpu_write(nmi_rearmed, 0);
+       __this_cpu_write(last_timestamp, now);
+       return true;
+}
+#else
+static inline bool watchdog_check_timestamp(void)
+{
+       return true;
+}
+#endif
+
 static struct perf_event_attr wd_hw_attr = {
        .type           = PERF_TYPE_HARDWARE,
        .config         = PERF_COUNT_HW_CPU_CYCLES,
@@ -61,6 +117,9 @@ static void watchdog_overflow_callback(struct perf_event *event,
                return;
        }
 
+       if (!watchdog_check_timestamp())
+               return;
+
        /* check for a hardlockup
         * This is done by making sure our timer interrupt
         * is incrementing.  The timer interrupt should have
index 98fe715522e8d1834083e608d32a78ed0600deb9..c617b9d1d6cb687c93fb0c65e8d05424f5dd3c43 100644 (file)
@@ -797,6 +797,13 @@ config HARDLOCKUP_DETECTOR_PERF
        bool
        select SOFTLOCKUP_DETECTOR
 
+#
+# Enables a timestamp based low pass filter to compensate for perf based
+# hard lockup detection which runs too fast due to turbo modes.
+#
+config HARDLOCKUP_CHECK_TIMESTAMP
+       bool
+
 #
 # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard
 # lockup detector rather than the perf based detector.
index 595b757bef72722fb2715afd9ab0cd1536181c9e..c03ccbc405a066038619361cf995f675dc2efaa1 100644 (file)
@@ -167,7 +167,7 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
        char name[16];
        int u32s;
 
-       sprintf(name, "cma-%s", cma->name);
+       scnprintf(name, sizeof(name), "cma-%s", cma->name);
 
        tmp = debugfs_create_dir(name, cma_debugfs_root);
 
index a49702445ce05beeb8d80b46f0ee57c116986be2..0b41c8cbeabc7a6b4e2533be1dfd74b9f10e29cd 100644 (file)
@@ -885,6 +885,7 @@ void __init pagecache_init(void)
        page_writeback_init();
 }
 
+/* This has the same layout as wait_bit_key - see fs/cachefiles/rdwr.c */
 struct wait_page_key {
        struct page *page;
        int bit_nr;
@@ -909,8 +910,10 @@ static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync,
 
        if (wait_page->bit_nr != key->bit_nr)
                return 0;
+
+       /* Stop walking if it's locked */
        if (test_bit(key->bit_nr, &key->page->flags))
-               return 0;
+               return -1;
 
        return autoremove_wake_function(wait, mode, sync, key);
 }
@@ -964,6 +967,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
        int ret = 0;
 
        init_wait(wait);
+       wait->flags = lock ? WQ_FLAG_EXCLUSIVE : 0;
        wait->func = wake_page_function;
        wait_page.page = page;
        wait_page.bit_nr = bit_nr;
@@ -972,10 +976,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
                spin_lock_irq(&q->lock);
 
                if (likely(list_empty(&wait->entry))) {
-                       if (lock)
-                               __add_wait_queue_entry_tail_exclusive(q, wait);
-                       else
-                               __add_wait_queue(q, wait);
+                       __add_wait_queue_entry_tail(q, wait);
                        SetPageWaiters(page);
                }
 
@@ -985,10 +986,6 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
 
                if (likely(test_bit(bit_nr, &page->flags))) {
                        io_schedule();
-                       if (unlikely(signal_pending_state(state, current))) {
-                               ret = -EINTR;
-                               break;
-                       }
                }
 
                if (lock) {
@@ -998,6 +995,11 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
                        if (!test_bit(bit_nr, &page->flags))
                                break;
                }
+
+               if (unlikely(signal_pending_state(state, current))) {
+                       ret = -EINTR;
+                       break;
+               }
        }
 
        finish_wait(q, wait);
index 216114f6ef0b7f8c09378edd3615d6a39527ead0..90731e3b7e589ea9f83c21827916917a27f71b82 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/userfaultfd_k.h>
 #include <linux/page_idle.h>
 #include <linux/shmem_fs.h>
+#include <linux/oom.h>
 
 #include <asm/tlb.h>
 #include <asm/pgalloc.h>
@@ -550,6 +551,7 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
        struct mem_cgroup *memcg;
        pgtable_t pgtable;
        unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
+       int ret = 0;
 
        VM_BUG_ON_PAGE(!PageCompound(page), page);
 
@@ -561,9 +563,8 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
 
        pgtable = pte_alloc_one(vma->vm_mm, haddr);
        if (unlikely(!pgtable)) {
-               mem_cgroup_cancel_charge(page, memcg, true);
-               put_page(page);
-               return VM_FAULT_OOM;
+               ret = VM_FAULT_OOM;
+               goto release;
        }
 
        clear_huge_page(page, haddr, HPAGE_PMD_NR);
@@ -576,13 +577,14 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
 
        vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
        if (unlikely(!pmd_none(*vmf->pmd))) {
-               spin_unlock(vmf->ptl);
-               mem_cgroup_cancel_charge(page, memcg, true);
-               put_page(page);
-               pte_free(vma->vm_mm, pgtable);
+               goto unlock_release;
        } else {
                pmd_t entry;
 
+               ret = check_stable_address_space(vma->vm_mm);
+               if (ret)
+                       goto unlock_release;
+
                /* Deliver the page fault to userland */
                if (userfaultfd_missing(vma)) {
                        int ret;
@@ -610,6 +612,15 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
        }
 
        return 0;
+unlock_release:
+       spin_unlock(vmf->ptl);
+release:
+       if (pgtable)
+               pte_free(vma->vm_mm, pgtable);
+       mem_cgroup_cancel_charge(page, memcg, true);
+       put_page(page);
+       return ret;
+
 }
 
 /*
@@ -688,7 +699,10 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf)
                ret = 0;
                set = false;
                if (pmd_none(*vmf->pmd)) {
-                       if (userfaultfd_missing(vma)) {
+                       ret = check_stable_address_space(vma->vm_mm);
+                       if (ret) {
+                               spin_unlock(vmf->ptl);
+                       } else if (userfaultfd_missing(vma)) {
                                spin_unlock(vmf->ptl);
                                ret = handle_userfault(vmf, VM_UFFD_MISSING);
                                VM_BUG_ON(ret & VM_FAULT_FALLBACK);
index 47d8d8a25eae49604f81bcffe40e45ef9b8e4c6c..23ed525bc2bc1367dde306cd6a1fd24a5d6b5bae 100644 (file)
@@ -368,8 +368,8 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
                                pte_offset_map_lock(mm, pmd, addr, &ptl);
                                goto out;
                        }
-                       put_page(page);
                        unlock_page(page);
+                       put_page(page);
                        pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
                        pte--;
                        addr -= PAGE_SIZE;
index 2cb25fe4452c279c5ff6ff74cbbfee64128d820e..91205780e6b151f8239574c5f97b8d5ebc89b59f 100644 (file)
@@ -285,31 +285,27 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
 }
 
 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
-
-phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
-                                       phys_addr_t *addr)
-{
-       if (memblock.reserved.regions == memblock_reserved_init_regions)
-               return 0;
-
-       *addr = __pa(memblock.reserved.regions);
-
-       return PAGE_ALIGN(sizeof(struct memblock_region) *
-                         memblock.reserved.max);
-}
-
-phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
-                                       phys_addr_t *addr)
+/**
+ * Discard memory and reserved arrays if they were allocated
+ */
+void __init memblock_discard(void)
 {
-       if (memblock.memory.regions == memblock_memory_init_regions)
-               return 0;
+       phys_addr_t addr, size;
 
-       *addr = __pa(memblock.memory.regions);
+       if (memblock.reserved.regions != memblock_reserved_init_regions) {
+               addr = __pa(memblock.reserved.regions);
+               size = PAGE_ALIGN(sizeof(struct memblock_region) *
+                                 memblock.reserved.max);
+               __memblock_free_late(addr, size);
+       }
 
-       return PAGE_ALIGN(sizeof(struct memblock_region) *
-                         memblock.memory.max);
+       if (memblock.memory.regions != memblock_memory_init_regions) {
+               addr = __pa(memblock.memory.regions);
+               size = PAGE_ALIGN(sizeof(struct memblock_region) *
+                                 memblock.memory.max);
+               __memblock_free_late(addr, size);
+       }
 }
-
 #endif
 
 /**
index 3df3c04d73ab08e3bbb663f25b2e195b396d2149..e09741af816f8a6d5343546ebd23eb7f25f8ab54 100644 (file)
@@ -1611,9 +1611,13 @@ cleanup:
  * @page: the page
  *
  * This function protects unlocked LRU pages from being moved to
- * another cgroup and stabilizes their page->mem_cgroup binding.
+ * another cgroup.
+ *
+ * It ensures lifetime of the returned memcg. Caller is responsible
+ * for the lifetime of the page; __unlock_page_memcg() is available
+ * when @page might get freed inside the locked section.
  */
-void lock_page_memcg(struct page *page)
+struct mem_cgroup *lock_page_memcg(struct page *page)
 {
        struct mem_cgroup *memcg;
        unsigned long flags;
@@ -1622,18 +1626,24 @@ void lock_page_memcg(struct page *page)
         * The RCU lock is held throughout the transaction.  The fast
         * path can get away without acquiring the memcg->move_lock
         * because page moving starts with an RCU grace period.
-        */
+        *
+        * The RCU lock also protects the memcg from being freed when
+        * the page state that is going to change is the only thing
+        * preventing the page itself from being freed. E.g. writeback
+        * doesn't hold a page reference and relies on PG_writeback to
+        * keep off truncation, migration and so forth.
+         */
        rcu_read_lock();
 
        if (mem_cgroup_disabled())
-               return;
+               return NULL;
 again:
        memcg = page->mem_cgroup;
        if (unlikely(!memcg))
-               return;
+               return NULL;
 
        if (atomic_read(&memcg->moving_account) <= 0)
-               return;
+               return memcg;
 
        spin_lock_irqsave(&memcg->move_lock, flags);
        if (memcg != page->mem_cgroup) {
@@ -1649,18 +1659,18 @@ again:
        memcg->move_lock_task = current;
        memcg->move_lock_flags = flags;
 
-       return;
+       return memcg;
 }
 EXPORT_SYMBOL(lock_page_memcg);
 
 /**
- * unlock_page_memcg - unlock a page->mem_cgroup binding
- * @page: the page
+ * __unlock_page_memcg - unlock and unpin a memcg
+ * @memcg: the memcg
+ *
+ * Unlock and unpin a memcg returned by lock_page_memcg().
  */
-void unlock_page_memcg(struct page *page)
+void __unlock_page_memcg(struct mem_cgroup *memcg)
 {
-       struct mem_cgroup *memcg = page->mem_cgroup;
-
        if (memcg && memcg->move_lock_task == current) {
                unsigned long flags = memcg->move_lock_flags;
 
@@ -1672,6 +1682,15 @@ void unlock_page_memcg(struct page *page)
 
        rcu_read_unlock();
 }
+
+/**
+ * unlock_page_memcg - unlock a page->mem_cgroup binding
+ * @page: the page
+ */
+void unlock_page_memcg(struct page *page)
+{
+       __unlock_page_memcg(page->mem_cgroup);
+}
 EXPORT_SYMBOL(unlock_page_memcg);
 
 /*
index e158f7ac67300b10b8827fe6825667506095f550..fe2fba27ded2fab229d0ef7a4908551343d31b89 100644 (file)
@@ -68,6 +68,7 @@
 #include <linux/debugfs.h>
 #include <linux/userfaultfd_k.h>
 #include <linux/dax.h>
+#include <linux/oom.h>
 
 #include <asm/io.h>
 #include <asm/mmu_context.h>
@@ -2893,6 +2894,7 @@ static int do_anonymous_page(struct vm_fault *vmf)
        struct vm_area_struct *vma = vmf->vma;
        struct mem_cgroup *memcg;
        struct page *page;
+       int ret = 0;
        pte_t entry;
 
        /* File mapping without ->vm_ops ? */
@@ -2925,6 +2927,9 @@ static int do_anonymous_page(struct vm_fault *vmf)
                                vmf->address, &vmf->ptl);
                if (!pte_none(*vmf->pte))
                        goto unlock;
+               ret = check_stable_address_space(vma->vm_mm);
+               if (ret)
+                       goto unlock;
                /* Deliver the page fault to userland, check inside PT lock */
                if (userfaultfd_missing(vma)) {
                        pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -2959,6 +2964,10 @@ static int do_anonymous_page(struct vm_fault *vmf)
        if (!pte_none(*vmf->pte))
                goto release;
 
+       ret = check_stable_address_space(vma->vm_mm);
+       if (ret)
+               goto release;
+
        /* Deliver the page fault to userland, check inside PT lock */
        if (userfaultfd_missing(vma)) {
                pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -2978,7 +2987,7 @@ setpte:
        update_mmu_cache(vma, vmf->address, vmf->pte);
 unlock:
        pte_unmap_unlock(vmf->pte, vmf->ptl);
-       return 0;
+       return ret;
 release:
        mem_cgroup_cancel_charge(page, memcg, false);
        put_page(page);
@@ -3252,7 +3261,7 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
 int finish_fault(struct vm_fault *vmf)
 {
        struct page *page;
-       int ret;
+       int ret = 0;
 
        /* Did we COW the page? */
        if ((vmf->flags & FAULT_FLAG_WRITE) &&
@@ -3260,7 +3269,15 @@ int finish_fault(struct vm_fault *vmf)
                page = vmf->cow_page;
        else
                page = vmf->page;
-       ret = alloc_set_pte(vmf, vmf->memcg, page);
+
+       /*
+        * check even for read faults because we might have lost our CoWed
+        * page
+        */
+       if (!(vmf->vma->vm_flags & VM_SHARED))
+               ret = check_stable_address_space(vmf->vma->vm_mm);
+       if (!ret)
+               ret = alloc_set_pte(vmf, vmf->memcg, page);
        if (vmf->pte)
                pte_unmap_unlock(vmf->pte, vmf->ptl);
        return ret;
@@ -3900,19 +3917,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
                        mem_cgroup_oom_synchronize(false);
        }
 
-       /*
-        * This mm has been already reaped by the oom reaper and so the
-        * refault cannot be trusted in general. Anonymous refaults would
-        * lose data and give a zero page instead e.g. This is especially
-        * problem for use_mm() because regular tasks will just die and
-        * the corrupted data will not be visible anywhere while kthread
-        * will outlive the oom victim and potentially propagate the date
-        * further.
-        */
-       if (unlikely((current->flags & PF_KTHREAD) && !(ret & VM_FAULT_ERROR)
-                               && test_bit(MMF_UNSTABLE, &vma->vm_mm->flags)))
-               ret = VM_FAULT_SIGBUS;
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(handle_mm_fault);
index d911fa5cb2a73fe464042a59e1c2676c1129239d..618ab125228baec0810146a0638ce80ce4d50284 100644 (file)
@@ -861,11 +861,6 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
                *policy |= (pol->flags & MPOL_MODE_FLAGS);
        }
 
-       if (vma) {
-               up_read(&current->mm->mmap_sem);
-               vma = NULL;
-       }
-
        err = 0;
        if (nmask) {
                if (mpol_store_user_nodemask(pol)) {
index d68a41da6abb0743d6b09cc49c5c9524463715c3..e84eeb4e43566c7b1ee85e3759b1b60b72c1c532 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/page_idle.h>
 #include <linux/page_owner.h>
 #include <linux/sched/mm.h>
+#include <linux/ptrace.h>
 
 #include <asm/tlbflush.h>
 
@@ -1652,7 +1653,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
                const int __user *, nodes,
                int __user *, status, int, flags)
 {
-       const struct cred *cred = current_cred(), *tcred;
        struct task_struct *task;
        struct mm_struct *mm;
        int err;
@@ -1676,14 +1676,9 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
 
        /*
         * Check if this process has the right to modify the specified
-        * process. The right exists if the process has administrative
-        * capabilities, superuser privileges or the same
-        * userid as the target process.
+        * process. Use the regular "ptrace_may_access()" checks.
         */
-       tcred = __task_cred(task);
-       if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
-           !uid_eq(cred->uid,  tcred->suid) && !uid_eq(cred->uid,  tcred->uid) &&
-           !capable(CAP_SYS_NICE)) {
+       if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
                rcu_read_unlock();
                err = -EPERM;
                goto out;
index 36454d0f96ee6b91383554c83015a2b47e66f038..3637809a18d04f9c20d1b00d70687ae1eb00b282 100644 (file)
@@ -146,22 +146,6 @@ static unsigned long __init free_low_memory_core_early(void)
                                NULL)
                count += __free_memory_core(start, end);
 
-#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
-       {
-               phys_addr_t size;
-
-               /* Free memblock.reserved array if it was allocated */
-               size = get_allocated_memblock_reserved_regions_info(&start);
-               if (size)
-                       count += __free_memory_core(start, start + size);
-
-               /* Free memblock.memory array if it was allocated */
-               size = get_allocated_memblock_memory_regions_info(&start);
-               if (size)
-                       count += __free_memory_core(start, start + size);
-       }
-#endif
-
        return count;
 }
 
index 96e93b214d317baf4fb4ffbb5fcbe726e110980d..bf050ab025b76a268cd09a37173eac4f86febcb8 100644 (file)
@@ -2724,9 +2724,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io);
 int test_clear_page_writeback(struct page *page)
 {
        struct address_space *mapping = page_mapping(page);
+       struct mem_cgroup *memcg;
+       struct lruvec *lruvec;
        int ret;
 
-       lock_page_memcg(page);
+       memcg = lock_page_memcg(page);
+       lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page));
        if (mapping && mapping_use_writeback_tags(mapping)) {
                struct inode *inode = mapping->host;
                struct backing_dev_info *bdi = inode_to_bdi(inode);
@@ -2754,12 +2757,18 @@ int test_clear_page_writeback(struct page *page)
        } else {
                ret = TestClearPageWriteback(page);
        }
+       /*
+        * NOTE: Page might be free now! Writeback doesn't hold a page
+        * reference on its own, it relies on truncation to wait for
+        * the clearing of PG_writeback. The below can only access
+        * page state that is static across allocation cycles.
+        */
        if (ret) {
-               dec_lruvec_page_state(page, NR_WRITEBACK);
+               dec_lruvec_state(lruvec, NR_WRITEBACK);
                dec_zone_page_state(page, NR_ZONE_WRITE_PENDING);
                inc_node_page_state(page, NR_WRITTEN);
        }
-       unlock_page_memcg(page);
+       __unlock_page_memcg(memcg);
        return ret;
 }
 
index 6d00f746c2fd96452661fde3f704289eed7f1f70..7a58eb5757e3bd61d9dadfd8d851b9641454552d 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/kthread.h>
 #include <linux/memcontrol.h>
 #include <linux/ftrace.h>
+#include <linux/nmi.h>
 
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
@@ -1584,6 +1585,10 @@ void __init page_alloc_init_late(void)
        /* Reinit limits that are based on free pages after the kernel is up */
        files_maxfiles_init();
 #endif
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
+       /* Discard memblock private memory */
+       memblock_discard();
+#endif
 
        for_each_populated_zone(zone)
                set_zone_contiguous(zone);
@@ -2531,9 +2536,14 @@ void drain_all_pages(struct zone *zone)
 
 #ifdef CONFIG_HIBERNATION
 
+/*
+ * Touch the watchdog for every WD_PAGE_COUNT pages.
+ */
+#define WD_PAGE_COUNT  (128*1024)
+
 void mark_free_pages(struct zone *zone)
 {
-       unsigned long pfn, max_zone_pfn;
+       unsigned long pfn, max_zone_pfn, page_count = WD_PAGE_COUNT;
        unsigned long flags;
        unsigned int order, t;
        struct page *page;
@@ -2548,6 +2558,11 @@ void mark_free_pages(struct zone *zone)
                if (pfn_valid(pfn)) {
                        page = pfn_to_page(pfn);
 
+                       if (!--page_count) {
+                               touch_nmi_watchdog();
+                               page_count = WD_PAGE_COUNT;
+                       }
+
                        if (page_zone(page) != zone)
                                continue;
 
@@ -2561,8 +2576,13 @@ void mark_free_pages(struct zone *zone)
                        unsigned long i;
 
                        pfn = page_to_pfn(page);
-                       for (i = 0; i < (1UL << order); i++)
+                       for (i = 0; i < (1UL << order); i++) {
+                               if (!--page_count) {
+                                       touch_nmi_watchdog();
+                                       page_count = WD_PAGE_COUNT;
+                               }
                                swsusp_set_page_free(pfn_to_page(pfn + i));
+                       }
                }
        }
        spin_unlock_irqrestore(&zone->lock, flags);
index 6540e598244412023db650412062604b704b58b3..fbcb3c96a186e8bcf9758189e4d1f17f1bc00cdd 100644 (file)
@@ -3967,7 +3967,7 @@ int __init shmem_init(void)
        }
 
 #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
-       if (has_transparent_hugepage() && shmem_huge < SHMEM_HUGE_DENY)
+       if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY)
                SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
        else
                shmem_huge = 0; /* just in case it was patched */
@@ -4028,7 +4028,7 @@ static ssize_t shmem_enabled_store(struct kobject *kobj,
                return -EINVAL;
 
        shmem_huge = huge;
-       if (shmem_huge < SHMEM_HUGE_DENY)
+       if (shmem_huge > SHMEM_HUGE_DENY)
                SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
        return count;
 }
index 1d3f9835f4eabe91494f48d8ace08a5e42a895f9..e8b4e31162cae8c4d8e473ae2d78769aaa55089e 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5642,13 +5642,14 @@ static void sysfs_slab_remove_workfn(struct work_struct *work)
                 * A cache is never shut down before deactivation is
                 * complete, so no need to worry about synchronization.
                 */
-               return;
+               goto out;
 
 #ifdef CONFIG_MEMCG
        kset_unregister(s->memcg_kset);
 #endif
        kobject_uevent(&s->kobj, KOBJ_REMOVE);
        kobject_del(&s->kobj);
+out:
        kobject_put(&s->kobj);
 }
 
index 8698c1c86c4dbed685269eae1ecded2f5e714368..a47e3894c775646cd636c3f48bcb75fd4b8771d6 100644 (file)
@@ -1671,7 +1671,10 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
        struct page **pages;
        unsigned int nr_pages, array_size, i;
        const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
-       const gfp_t alloc_mask = gfp_mask | __GFP_HIGHMEM | __GFP_NOWARN;
+       const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
+       const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
+                                       0 :
+                                       __GFP_HIGHMEM;
 
        nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
        array_size = (nr_pages * sizeof(struct page *));
@@ -1679,7 +1682,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
        area->nr_pages = nr_pages;
        /* Please note that the recursion is strictly bounded. */
        if (array_size > PAGE_SIZE) {
-               pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,
+               pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
                                PAGE_KERNEL, node, area->caller);
        } else {
                pages = kmalloc_node(array_size, nested_gfp, node);
@@ -1700,9 +1703,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                }
 
                if (node == NUMA_NO_NODE)
-                       page = alloc_page(alloc_mask);
+                       page = alloc_page(alloc_mask|highmem_mask);
                else
-                       page = alloc_pages_node(node, alloc_mask, 0);
+                       page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
 
                if (unlikely(!page)) {
                        /* Successfully allocated i pages, free them in __vunmap() */
@@ -1710,7 +1713,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                        goto fail;
                }
                area->pages[i] = page;
-               if (gfpflags_allow_blocking(gfp_mask))
+               if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
                        cond_resched();
        }
 
index ee5647bd91b3f3a864dccdc46098b30e8561377d..a21ca8dee5eadca0d9ab7c78a939ac90bb3963b0 100644 (file)
@@ -169,14 +169,20 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
                                          int *peeked, int *off, int *err,
                                          struct sk_buff **last)
 {
+       bool peek_at_off = false;
        struct sk_buff *skb;
-       int _off = *off;
+       int _off = 0;
+
+       if (unlikely(flags & MSG_PEEK && *off >= 0)) {
+               peek_at_off = true;
+               _off = *off;
+       }
 
        *last = queue->prev;
        skb_queue_walk(queue, skb) {
                if (flags & MSG_PEEK) {
-                       if (_off >= skb->len && (skb->len || _off ||
-                                                skb->peeked)) {
+                       if (peek_at_off && _off >= skb->len &&
+                           (_off || skb->peeked)) {
                                _off -= skb->len;
                                continue;
                        }
index f44fc22fd45aca4941c618abf97eb48494a67c16..6280a602604c2e0e05c57d0c2104b5f4791f6928 100644 (file)
@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
                                              bpf_target_off(struct sk_buff, tc_index, 2,
                                                             target_size));
 #else
+               *target_size = 2;
                if (type == BPF_WRITE)
                        *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
                else
@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
                *insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
                *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 #else
+               *target_size = 4;
                *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 #endif
                break;
index 9fe25bf6329691ecf0acdc35df7278b074d446c1..b68168fcc06aa1981258eca4857511329af62f9a 100644 (file)
@@ -24,6 +24,7 @@
 #include <net/checksum.h>
 
 #include <net/inet_sock.h>
+#include <net/inet_common.h>
 #include <net/sock.h>
 #include <net/xfrm.h>
 
@@ -170,6 +171,15 @@ const char *dccp_packet_name(const int type)
 
 EXPORT_SYMBOL_GPL(dccp_packet_name);
 
+static void dccp_sk_destruct(struct sock *sk)
+{
+       struct dccp_sock *dp = dccp_sk(sk);
+
+       ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
+       dp->dccps_hc_tx_ccid = NULL;
+       inet_sock_destruct(sk);
+}
+
 int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
 {
        struct dccp_sock *dp = dccp_sk(sk);
@@ -179,6 +189,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
        icsk->icsk_syn_retries  = sysctl_dccp_request_retries;
        sk->sk_state            = DCCP_CLOSED;
        sk->sk_write_space      = dccp_write_space;
+       sk->sk_destruct         = dccp_sk_destruct;
        icsk->icsk_sync_mss     = dccp_sync_mss;
        dp->dccps_mss_cache     = 536;
        dp->dccps_rate_last     = jiffies;
@@ -201,10 +212,7 @@ void dccp_destroy_sock(struct sock *sk)
 {
        struct dccp_sock *dp = dccp_sk(sk);
 
-       /*
-        * DCCP doesn't use sk_write_queue, just sk_send_head
-        * for retransmissions
-        */
+       __skb_queue_purge(&sk->sk_write_queue);
        if (sk->sk_send_head != NULL) {
                kfree_skb(sk->sk_send_head);
                sk->sk_send_head = NULL;
@@ -222,8 +230,7 @@ void dccp_destroy_sock(struct sock *sk)
                dp->dccps_hc_rx_ackvec = NULL;
        }
        ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
-       ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
-       dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
+       dp->dccps_hc_rx_ccid = NULL;
 
        /* clean up feature negotiation state */
        dccp_feat_list_purge(&dp->dccps_featneg);
index fab41de8e9837b512709b3c853ffb4831fe08317..de66ca8e620177693e55b54492404d8d3ee52197 100644 (file)
@@ -42,6 +42,9 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
        padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
 
        if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
+               if (skb_put_padto(skb, skb->len + padlen))
+                       return NULL;
+
                nskb = skb;
        } else {
                nskb = alloc_skb(NET_IP_ALIGN + skb->len +
@@ -56,13 +59,15 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
                skb_set_transport_header(nskb,
                                         skb_transport_header(skb) - skb->head);
                skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
+
+               if (skb_put_padto(nskb, nskb->len + padlen)) {
+                       kfree_skb(nskb);
+                       return NULL;
+               }
+
                kfree_skb(skb);
        }
 
-       /* skb is freed when it fails */
-       if (skb_put_padto(nskb, nskb->len + padlen))
-               return NULL;
-
        tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
        tag[0] = 0;
        tag[1] = 1 << p->dp->index; /* destination port */
index b8d18171cca33ab5dab67408c3cd11ad57f25b83..ec3a9ce281a6ffb86b62e21f7284fd7c801668f0 100644 (file)
@@ -1083,15 +1083,17 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
        fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
        if (!fi)
                goto failure;
-       fib_info_cnt++;
        if (cfg->fc_mx) {
                fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL);
-               if (!fi->fib_metrics)
-                       goto failure;
+               if (unlikely(!fi->fib_metrics)) {
+                       kfree(fi);
+                       return ERR_PTR(err);
+               }
                atomic_set(&fi->fib_metrics->refcnt, 1);
-       } else
+       } else {
                fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
-
+       }
+       fib_info_cnt++;
        fi->fib_net = net;
        fi->fib_protocol = cfg->fc_protocol;
        fi->fib_scope = cfg->fc_scope;
index 498706b072fb70e1ffe6b5dba817816db5a4cfa7..caf2f1101d027b7b6e8d9683887e16c7bd4a8438 100644 (file)
@@ -1007,10 +1007,18 @@ int igmp_rcv(struct sk_buff *skb)
 {
        /* This basically follows the spec line by line -- see RFC1112 */
        struct igmphdr *ih;
-       struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
+       struct net_device *dev = skb->dev;
+       struct in_device *in_dev;
        int len = skb->len;
        bool dropped = true;
 
+       if (netif_is_l3_master(dev)) {
+               dev = dev_get_by_index_rcu(dev_net(dev), IPCB(skb)->iif);
+               if (!dev)
+                       goto drop;
+       }
+
+       in_dev = __in_dev_get_rcu(dev);
        if (!in_dev)
                goto drop;
 
index 0383e66f59bcef3bd6b8627edae9aa2d34139f5d..2331de20ca505d7f25fe9d93d5320e9e39af6c39 100644 (file)
@@ -1267,7 +1267,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
        if (mtu)
                return mtu;
 
-       mtu = dst->dev->mtu;
+       mtu = READ_ONCE(dst->dev->mtu);
 
        if (unlikely(dst_metric_locked(dst, RTAX_MTU))) {
                if (rt->rt_uses_gateway && mtu > 576)
@@ -2750,26 +2750,34 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
                err = 0;
                if (IS_ERR(rt))
                        err = PTR_ERR(rt);
+               else
+                       skb_dst_set(skb, &rt->dst);
        }
 
        if (err)
                goto errout_free;
 
-       skb_dst_set(skb, &rt->dst);
        if (rtm->rtm_flags & RTM_F_NOTIFY)
                rt->rt_flags |= RTCF_NOTIFY;
 
        if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE)
                table_id = rt->rt_table_id;
 
-       if (rtm->rtm_flags & RTM_F_FIB_MATCH)
+       if (rtm->rtm_flags & RTM_F_FIB_MATCH) {
+               if (!res.fi) {
+                       err = fib_props[res.type].error;
+                       if (!err)
+                               err = -EHOSTUNREACH;
+                       goto errout_free;
+               }
                err = fib_dump_info(skb, NETLINK_CB(in_skb).portid,
                                    nlh->nlmsg_seq, RTM_NEWROUTE, table_id,
                                    rt->rt_type, res.prefix, res.prefixlen,
                                    fl4.flowi4_tos, res.fi, 0);
-       else
+       } else {
                err = rt_fill_info(net, dst, src, table_id, &fl4, skb,
                                   NETLINK_CB(in_skb).portid, nlh->nlmsg_seq);
+       }
        if (err < 0)
                goto errout_free;
 
index 53de1424c13cda5d1fec826b97cacf4f95adc99a..bab7f0493098c6521f445923d721d296f326f7e1 100644 (file)
@@ -3009,8 +3009,7 @@ void tcp_rearm_rto(struct sock *sk)
                        /* delta_us may not be positive if the socket is locked
                         * when the retrans timer fires and is rescheduled.
                         */
-                       if (delta_us > 0)
-                               rto = usecs_to_jiffies(delta_us);
+                       rto = usecs_to_jiffies(max_t(int, delta_us, 1));
                }
                inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto,
                                          TCP_RTO_MAX);
index a20e7f03d5f7d81ccf7e92de9bfbbcc3e2df6718..e9252c7df8091a8e0d2fc9d7e5722e9fd605a857 100644 (file)
@@ -1722,6 +1722,8 @@ process:
                 */
                sock_hold(sk);
                refcounted = true;
+               if (tcp_filter(sk, skb))
+                       goto discard_and_relse;
                nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
@@ -1729,8 +1731,6 @@ process:
                }
                if (nsk == sk) {
                        reqsk_put(req);
-               } else if (tcp_filter(sk, skb)) {
-                       goto discard_and_relse;
                } else if (tcp_child_process(sk, nsk, skb)) {
                        tcp_v4_send_reset(nsk, skb);
                        goto discard_and_relse;
index 2417f55374c593c89b2aeb1ec4f6e6e74bb1395f..6bb9e14c710a7e2bfa58ee63ff6e02461a22cbec 100644 (file)
@@ -122,14 +122,14 @@ int tcp_set_ulp(struct sock *sk, const char *name)
 
        ulp_ops = __tcp_ulp_find_autoload(name);
        if (!ulp_ops)
-               err = -ENOENT;
-       else
-               err = ulp_ops->init(sk);
+               return -ENOENT;
 
-       if (err)
-               goto out;
+       err = ulp_ops->init(sk);
+       if (err) {
+               module_put(ulp_ops->owner);
+               return err;
+       }
 
        icsk->icsk_ulp_ops = ulp_ops;
- out:
-       return err;
+       return 0;
 }
index a7c804f73990a0610bc85c02fc2dd76858973c22..cd1d044a7fa580f315af0fd81eb1bf425fd1f38c 100644 (file)
@@ -1574,7 +1574,8 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
                return ip_recv_error(sk, msg, len, addr_len);
 
 try_again:
-       peeking = off = sk_peek_offset(sk, flags);
+       peeking = flags & MSG_PEEK;
+       off = sk_peek_offset(sk, flags);
        skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err);
        if (!skb)
                return err;
index ebb299cf72b7e81b77999d43d2e7f83212386f73..5cc0ea0381981b0539d5d6e67401d962a6f6a230 100644 (file)
@@ -914,6 +914,8 @@ add:
                }
                nsiblings = iter->rt6i_nsiblings;
                fib6_purge_rt(iter, fn, info->nl_net);
+               if (fn->rr_ptr == iter)
+                       fn->rr_ptr = NULL;
                rt6_release(iter);
 
                if (nsiblings) {
@@ -926,6 +928,8 @@ add:
                                if (rt6_qualify_for_ecmp(iter)) {
                                        *ins = iter->dst.rt6_next;
                                        fib6_purge_rt(iter, fn, info->nl_net);
+                                       if (fn->rr_ptr == iter)
+                                               fn->rr_ptr = NULL;
                                        rt6_release(iter);
                                        nsiblings--;
                                } else {
@@ -1014,7 +1018,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
                        /* Create subtree root node */
                        sfn = node_alloc();
                        if (!sfn)
-                               goto st_failure;
+                               goto failure;
 
                        sfn->leaf = info->nl_net->ipv6.ip6_null_entry;
                        atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref);
@@ -1031,12 +1035,12 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
 
                        if (IS_ERR(sn)) {
                                /* If it is failed, discard just allocated
-                                  root, and then (in st_failure) stale node
+                                  root, and then (in failure) stale node
                                   in main tree.
                                 */
                                node_free(sfn);
                                err = PTR_ERR(sn);
-                               goto st_failure;
+                               goto failure;
                        }
 
                        /* Now link new subtree to main tree */
@@ -1051,7 +1055,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
 
                        if (IS_ERR(sn)) {
                                err = PTR_ERR(sn);
-                               goto st_failure;
+                               goto failure;
                        }
                }
 
@@ -1092,18 +1096,17 @@ out:
                        atomic_inc(&pn->leaf->rt6i_ref);
                }
 #endif
-               /* Always release dst as dst->__refcnt is guaranteed
-                * to be taken before entering this function
-                */
-               dst_release_immediate(&rt->dst);
+               goto failure;
        }
        return err;
 
-#ifdef CONFIG_IPV6_SUBTREES
-       /* Subtree creation failed, probably main tree node
-          is orphan. If it is, shoot it.
+failure:
+       /* fn->leaf could be NULL if fn is an intermediate node and we
+        * failed to add the new route to it in both subtree creation
+        * failure and fib6_add_rt2node() failure case.
+        * In both cases, fib6_repair_tree() should be called to fix
+        * fn->leaf.
         */
-st_failure:
        if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT)))
                fib6_repair_tree(info->nl_net, fn);
        /* Always release dst as dst->__refcnt is guaranteed
@@ -1111,7 +1114,6 @@ st_failure:
         */
        dst_release_immediate(&rt->dst);
        return err;
-#endif
 }
 
 /*
index a640fbcba15dbf246e419d3e03da8eca0fa6901a..94d6a13d47f0e9ec5ff4cbc50b90d4cd9ca3f38a 100644 (file)
@@ -417,14 +417,11 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
        struct net_device *loopback_dev =
                dev_net(dev)->loopback_dev;
 
-       if (dev != loopback_dev) {
-               if (idev && idev->dev == dev) {
-                       struct inet6_dev *loopback_idev =
-                               in6_dev_get(loopback_dev);
-                       if (loopback_idev) {
-                               rt->rt6i_idev = loopback_idev;
-                               in6_dev_put(idev);
-                       }
+       if (idev && idev->dev != loopback_dev) {
+               struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev);
+               if (loopback_idev) {
+                       rt->rt6i_idev = loopback_idev;
+                       in6_dev_put(idev);
                }
        }
 }
@@ -3724,10 +3721,10 @@ static int ip6_route_dev_notify(struct notifier_block *this,
                /* NETDEV_UNREGISTER could be fired for multiple times by
                 * netdev_wait_allrefs(). Make sure we only call this once.
                 */
-               in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev);
+               in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev);
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
-               in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev);
-               in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev);
+               in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev);
+               in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev);
 #endif
        }
 
index 2521690d62d6e591af594c3629f71f004240ed68..206210125fd71d129a9ed2ead51a536749ab62b8 100644 (file)
@@ -1456,6 +1456,8 @@ process:
                }
                sock_hold(sk);
                refcounted = true;
+               if (tcp_filter(sk, skb))
+                       goto discard_and_relse;
                nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
@@ -1464,8 +1466,6 @@ process:
                if (nsk == sk) {
                        reqsk_put(req);
                        tcp_v6_restore_cb(skb);
-               } else if (tcp_filter(sk, skb)) {
-                       goto discard_and_relse;
                } else if (tcp_child_process(sk, nsk, skb)) {
                        tcp_v6_send_reset(nsk, skb);
                        goto discard_and_relse;
index 578142b7ca3e6e91e528b8c81addec812bb6a5ca..20039c8501eb9729619f4337a2757a2954163614 100644 (file)
@@ -362,7 +362,8 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
                return ipv6_recv_rxpmtu(sk, msg, len, addr_len);
 
 try_again:
-       peeking = off = sk_peek_offset(sk, flags);
+       peeking = flags & MSG_PEEK;
+       off = sk_peek_offset(sk, flags);
        skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err);
        if (!skb)
                return err;
index 2e6990f8b80b6b4cc1d59665b0154a81790e1788..23fa7c8b09a5861e2acc042775830cc2dac4e0f4 100644 (file)
@@ -2213,7 +2213,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
 {
        struct sock *sk = sock->sk;
        struct irda_sock *self = irda_sk(sk);
-       struct irda_device_list list;
+       struct irda_device_list list = { 0 };
        struct irda_device_info *discoveries;
        struct irda_ias_set *   ias_opt;        /* IAS get/query params */
        struct ias_object *     ias_obj;        /* Object in IAS */
index ca9d3ae665e76ea847a4ce03b4d275f80d7705bc..98f4d8211b9a9d9bc26e7d9979c5c2bf27c1b344 100644 (file)
@@ -228,7 +228,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
 #define BROADCAST_ONE          1
 #define BROADCAST_REGISTERED   2
 #define BROADCAST_PROMISC_ONLY 4
-static int pfkey_broadcast(struct sk_buff *skb,
+static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
                           int broadcast_flags, struct sock *one_sk,
                           struct net *net)
 {
@@ -278,7 +278,7 @@ static int pfkey_broadcast(struct sk_buff *skb,
        rcu_read_unlock();
 
        if (one_sk != NULL)
-               err = pfkey_broadcast_one(skb, &skb2, GFP_KERNEL, one_sk);
+               err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);
 
        kfree_skb(skb2);
        kfree_skb(skb);
@@ -311,7 +311,7 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
                hdr = (struct sadb_msg *) pfk->dump.skb->data;
                hdr->sadb_msg_seq = 0;
                hdr->sadb_msg_errno = rc;
-               pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+               pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
                                &pfk->sk, sock_net(&pfk->sk));
                pfk->dump.skb = NULL;
        }
@@ -355,7 +355,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk)
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) /
                             sizeof(uint64_t));
 
-       pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+       pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk));
 
        return 0;
 }
@@ -1389,7 +1389,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, const struct sadb_
 
        xfrm_state_put(x);
 
-       pfkey_broadcast(resp_skb, BROADCAST_ONE, sk, net);
+       pfkey_broadcast(resp_skb, GFP_KERNEL, BROADCAST_ONE, sk, net);
 
        return 0;
 }
@@ -1476,7 +1476,7 @@ static int key_notify_sa(struct xfrm_state *x, const struct km_event *c)
        hdr->sadb_msg_seq = c->seq;
        hdr->sadb_msg_pid = c->portid;
 
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, xs_net(x));
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x));
 
        return 0;
 }
@@ -1589,7 +1589,7 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, const struct sadb_msg
        out_hdr->sadb_msg_reserved = 0;
        out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
        out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-       pfkey_broadcast(out_skb, BROADCAST_ONE, sk, sock_net(sk));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, sock_net(sk));
 
        return 0;
 }
@@ -1694,8 +1694,8 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad
                return -ENOBUFS;
        }
 
-       pfkey_broadcast(supp_skb, BROADCAST_REGISTERED, sk, sock_net(sk));
-
+       pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk,
+                       sock_net(sk));
        return 0;
 }
 
@@ -1712,7 +1712,8 @@ static int unicast_flush_resp(struct sock *sk, const struct sadb_msg *ihdr)
        hdr->sadb_msg_errno = (uint8_t) 0;
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 
-       return pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+       return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ONE, sk,
+                              sock_net(sk));
 }
 
 static int key_notify_sa_flush(const struct km_event *c)
@@ -1733,7 +1734,7 @@ static int key_notify_sa_flush(const struct km_event *c)
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
        hdr->sadb_msg_reserved = 0;
 
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, c->net);
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
 
        return 0;
 }
@@ -1790,7 +1791,7 @@ static int dump_sa(struct xfrm_state *x, int count, void *ptr)
        out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
        if (pfk->dump.skb)
-               pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+               pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
                                &pfk->sk, sock_net(&pfk->sk));
        pfk->dump.skb = out_skb;
 
@@ -1878,7 +1879,7 @@ static int pfkey_promisc(struct sock *sk, struct sk_buff *skb, const struct sadb
                new_hdr->sadb_msg_errno = 0;
        }
 
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, sock_net(sk));
+       pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ALL, NULL, sock_net(sk));
        return 0;
 }
 
@@ -2206,7 +2207,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
        out_hdr->sadb_msg_errno = 0;
        out_hdr->sadb_msg_seq = c->seq;
        out_hdr->sadb_msg_pid = c->portid;
-       pfkey_broadcast(out_skb, BROADCAST_ALL, NULL, xp_net(xp));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
        return 0;
 
 }
@@ -2426,7 +2427,7 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struc
        out_hdr->sadb_msg_errno = 0;
        out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
        out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-       pfkey_broadcast(out_skb, BROADCAST_ONE, sk, xp_net(xp));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp));
        err = 0;
 
 out:
@@ -2682,7 +2683,7 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
        out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
        if (pfk->dump.skb)
-               pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+               pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
                                &pfk->sk, sock_net(&pfk->sk));
        pfk->dump.skb = out_skb;
 
@@ -2739,7 +2740,7 @@ static int key_notify_policy_flush(const struct km_event *c)
        hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
        hdr->sadb_msg_reserved = 0;
-       pfkey_broadcast(skb_out, BROADCAST_ALL, NULL, c->net);
+       pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
        return 0;
 
 }
@@ -2803,7 +2804,7 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb
        void *ext_hdrs[SADB_EXT_MAX];
        int err;
 
-       pfkey_broadcast(skb_clone(skb, GFP_KERNEL),
+       pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
                        BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
 
        memset(ext_hdrs, 0, sizeof(ext_hdrs));
@@ -3024,7 +3025,8 @@ static int key_notify_sa_expire(struct xfrm_state *x, const struct km_event *c)
        out_hdr->sadb_msg_seq = 0;
        out_hdr->sadb_msg_pid = 0;
 
-       pfkey_broadcast(out_skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+                       xs_net(x));
        return 0;
 }
 
@@ -3212,7 +3214,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
                       xfrm_ctx->ctx_len);
        }
 
-       return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+       return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+                              xs_net(x));
 }
 
 static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
@@ -3408,7 +3411,8 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
        n_port->sadb_x_nat_t_port_port = sport;
        n_port->sadb_x_nat_t_port_reserved = 0;
 
-       return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+       return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+                              xs_net(x));
 }
 
 #ifdef CONFIG_NET_KEY_MIGRATE
@@ -3599,7 +3603,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
        }
 
        /* broadcast migrate message to sockets */
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, &init_net);
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net);
 
        return 0;
 
index 8708cbe8af5bbcabc5c7ea295c6a0abd15a8eb84..2b36eff5d97ea7c1cef117033c66dd35058ac4e7 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
  * Copyright 2007-2010, Intel Corporation
- * Copyright(c) 2015 Intel Deutschland GmbH
+ * Copyright(c) 2015-2017 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -466,3 +466,23 @@ void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif,
        rcu_read_unlock();
 }
 EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl);
+
+void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
+                                  const u8 *addr, unsigned int tid)
+{
+       struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+       struct ieee80211_local *local = sdata->local;
+       struct sta_info *sta;
+
+       rcu_read_lock();
+       sta = sta_info_get_bss(sdata, addr);
+       if (!sta)
+               goto unlock;
+
+       set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
+       ieee80211_queue_work(&local->hw, &sta->ampdu_mlme.work);
+
+ unlock:
+       rcu_read_unlock();
+}
+EXPORT_SYMBOL(ieee80211_rx_ba_timer_expired);
index e4610676299bcdac626db1a30cd4da44ccc62c0b..a54a556fcdb57d95b4a4a6606016ead527b93d64 100644 (file)
@@ -1337,6 +1337,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
                goto out;
        }
 
+       OVS_CB(skb)->acts_origlen = acts->orig_len;
        err = do_execute_actions(dp, skb, key,
                                 acts->actions, acts->actions_len);
 
index 45fe8c8a884df36100bc0cf26d279cb92e51bdf8..6b44fe4052825a87b373bafb58ca014e3ec99015 100644 (file)
@@ -381,7 +381,7 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
 }
 
 static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
-                             unsigned int hdrlen)
+                             unsigned int hdrlen, int actions_attrlen)
 {
        size_t size = NLMSG_ALIGN(sizeof(struct ovs_header))
                + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */
@@ -398,7 +398,7 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
 
        /* OVS_PACKET_ATTR_ACTIONS */
        if (upcall_info->actions_len)
-               size += nla_total_size(upcall_info->actions_len);
+               size += nla_total_size(actions_attrlen);
 
        /* OVS_PACKET_ATTR_MRU */
        if (upcall_info->mru)
@@ -465,7 +465,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
        else
                hlen = skb->len;
 
-       len = upcall_msg_size(upcall_info, hlen - cutlen);
+       len = upcall_msg_size(upcall_info, hlen - cutlen,
+                             OVS_CB(skb)->acts_origlen);
        user_skb = genlmsg_new(len, GFP_ATOMIC);
        if (!user_skb) {
                err = -ENOMEM;
index 5d8dcd88815f0622a48a54f14eaf5b5b9c53b18c..480600649d0b03a185f73b587181a3136d75e9b2 100644 (file)
@@ -99,11 +99,13 @@ struct datapath {
  * when a packet is received by OVS.
  * @mru: The maximum received fragement size; 0 if the packet is not
  * fragmented.
+ * @acts_origlen: The netlink size of the flow actions applied to this skb.
  * @cutlen: The number of bytes from the packet end to be removed.
  */
 struct ovs_skb_cb {
        struct vport            *input_vport;
        u16                     mru;
+       u16                     acts_origlen;
        u32                     cutlen;
 };
 #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
index dd30d74824b0de42d1866f4449300f89c83d6724..ec3383f97d4c3e863c7fe77af8d3ed3ba5ea039f 100644 (file)
@@ -223,6 +223,7 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx)
        tail = b->call_backlog_tail;
        while (CIRC_CNT(head, tail, size) > 0) {
                struct rxrpc_call *call = b->call_backlog[tail];
+               call->socket = rx;
                if (rx->discard_new_call) {
                        _debug("discard %lx", call->user_call_ID);
                        rx->discard_new_call(call, call->user_call_ID);
index d516ba8178b8099f5e8e180f2e60e7a61de37811..541707802a2380e83a96821dd20eb5946824cfe5 100644 (file)
@@ -41,6 +41,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t,
 {
        struct xt_tgchk_param par;
        struct xt_target *target;
+       struct ipt_entry e = {};
        int ret = 0;
 
        target = xt_request_find_target(AF_INET, t->u.user.name,
@@ -52,6 +53,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t,
        memset(&par, 0, sizeof(par));
        par.net       = net;
        par.table     = table;
+       par.entryinfo = &e;
        par.target    = target;
        par.targinfo  = t->data;
        par.hook_mask = hook;
index 39da0c5801c908e28c4e258319adefde836c6b0c..9fd44c22134783edf3db4f62ff1e8184c455cbd7 100644 (file)
@@ -205,7 +205,7 @@ static void tcf_chain_flush(struct tcf_chain *chain)
 {
        struct tcf_proto *tp;
 
-       if (*chain->p_filter_chain)
+       if (chain->p_filter_chain)
                RCU_INIT_POINTER(*chain->p_filter_chain, NULL);
        while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) {
                RCU_INIT_POINTER(chain->filter_chain, tp->next);
index bd24a550e0f9f114598f4a398d6efd4c72672f50..a3fa144b864871088209386fd573bded1886432f 100644 (file)
@@ -286,9 +286,6 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle)
 void qdisc_hash_add(struct Qdisc *q, bool invisible)
 {
        if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) {
-               struct Qdisc *root = qdisc_dev(q)->qdisc;
-
-               WARN_ON_ONCE(root == &noop_qdisc);
                ASSERT_RTNL();
                hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle);
                if (invisible)
index 572fe2584e48c81dbf58d90ce9d6a4ae68d2a385..c403c87aff7a44bccfdd5f07e2e00ea0698a5c90 100644 (file)
@@ -572,8 +572,10 @@ static void atm_tc_destroy(struct Qdisc *sch)
        struct atm_flow_data *flow, *tmp;
 
        pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p);
-       list_for_each_entry(flow, &p->flows, list)
+       list_for_each_entry(flow, &p->flows, list) {
                tcf_block_put(flow->block);
+               flow->block = NULL;
+       }
 
        list_for_each_entry_safe(flow, tmp, &p->flows, list) {
                if (flow->ref > 1)
index 481036f6b54e4730ee27fae6236277c64d3eaa1a..780db43300b16284192b24006b0ae8677adbe505 100644 (file)
@@ -1431,8 +1431,10 @@ static void cbq_destroy(struct Qdisc *sch)
         * be bound to classes which have been destroyed already. --TGR '04
         */
        for (h = 0; h < q->clhash.hashsize; h++) {
-               hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode)
+               hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
                        tcf_block_put(cl->block);
+                       cl->block = NULL;
+               }
        }
        for (h = 0; h < q->clhash.hashsize; h++) {
                hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h],
index b52f74610dc7539fd7804403a6ff41b690243df7..fd15200f86273add7d6c8c4a18aaef912aba7411 100644 (file)
@@ -1428,6 +1428,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
                return err;
        q->eligible = RB_ROOT;
 
+       err = tcf_block_get(&q->root.block, &q->root.filter_list);
+       if (err)
+               goto err_tcf;
+
        q->root.cl_common.classid = sch->handle;
        q->root.refcnt  = 1;
        q->root.sched   = q;
@@ -1447,6 +1451,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
        qdisc_watchdog_init(&q->watchdog, sch);
 
        return 0;
+
+err_tcf:
+       qdisc_class_hash_destroy(&q->clhash);
+       return err;
 }
 
 static int
@@ -1522,8 +1530,10 @@ hfsc_destroy_qdisc(struct Qdisc *sch)
        unsigned int i;
 
        for (i = 0; i < q->clhash.hashsize; i++) {
-               hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode)
+               hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode) {
                        tcf_block_put(cl->block);
+                       cl->block = NULL;
+               }
        }
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
index 203286ab442799a07808bd8f73af9f07b0482cbd..5d65ec5207e91202d501a83c983793f2e923f075 100644 (file)
@@ -1258,8 +1258,10 @@ static void htb_destroy(struct Qdisc *sch)
        tcf_block_put(q->block);
 
        for (i = 0; i < q->clhash.hashsize; i++) {
-               hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode)
+               hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
                        tcf_block_put(cl->block);
+                       cl->block = NULL;
+               }
        }
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
index f80ea2cc5f1f4bdee2452c930e3650f79397f3a1..82469ef9655eb65431477215bb2df0fb2737f905 100644 (file)
@@ -437,6 +437,7 @@ congestion_drop:
                qdisc_drop(head, sch, to_free);
 
                slot_queue_add(slot, skb);
+               qdisc_tree_reduce_backlog(sch, 0, delta);
                return NET_XMIT_CN;
        }
 
@@ -468,8 +469,10 @@ enqueue:
        /* Return Congestion Notification only if we dropped a packet
         * from this flow.
         */
-       if (qlen != slot->qlen)
+       if (qlen != slot->qlen) {
+               qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb));
                return NET_XMIT_CN;
+       }
 
        /* As we dropped a packet, better let upper stack know this */
        qdisc_tree_reduce_backlog(sch, 1, dropped);
index 2a186b201ad2c20594169633b241dacd0cc971c0..a4b6ffb6149541b78e39aceae859224d13487106 100644 (file)
@@ -512,7 +512,9 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr,
 {
        addr->sa.sa_family = AF_INET6;
        addr->v6.sin6_port = port;
+       addr->v6.sin6_flowinfo = 0;
        addr->v6.sin6_addr = *saddr;
+       addr->v6.sin6_scope_id = 0;
 }
 
 /* Compare addresses exactly.
index 2b720fa35c4ff7c2ae906e9e76d13d27a2b2f008..e18500151236ed3b162cebcf24966957e58be484 100644 (file)
@@ -421,6 +421,9 @@ static void svc_data_ready(struct sock *sk)
                dprintk("svc: socket %p(inet %p), busy=%d\n",
                        svsk, sk,
                        test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
+
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_odata(sk);
                if (!test_and_set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags))
                        svc_xprt_enqueue(&svsk->sk_xprt);
@@ -437,6 +440,9 @@ static void svc_write_space(struct sock *sk)
        if (svsk) {
                dprintk("svc: socket %p(inet %p), write_space busy=%d\n",
                        svsk, sk, test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
+
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_owspace(sk);
                svc_xprt_enqueue(&svsk->sk_xprt);
        }
@@ -760,8 +766,12 @@ static void svc_tcp_listen_data_ready(struct sock *sk)
        dprintk("svc: socket %p TCP (listen) state change %d\n",
                sk, sk->sk_state);
 
-       if (svsk)
+       if (svsk) {
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_odata(sk);
+       }
+
        /*
         * This callback may called twice when a new connection
         * is established as a child socket inherits everything
@@ -794,6 +804,8 @@ static void svc_tcp_state_change(struct sock *sk)
        if (!svsk)
                printk("svc: socket %p: no user data\n", sk);
        else {
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_ostate(sk);
                if (sk->sk_state != TCP_ESTABLISHED) {
                        set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
@@ -1381,12 +1393,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
                return ERR_PTR(err);
        }
 
-       inet->sk_user_data = svsk;
        svsk->sk_sock = sock;
        svsk->sk_sk = inet;
        svsk->sk_ostate = inet->sk_state_change;
        svsk->sk_odata = inet->sk_data_ready;
        svsk->sk_owspace = inet->sk_write_space;
+       /*
+        * This barrier is necessary in order to prevent race condition
+        * with svc_data_ready(), svc_listen_data_ready() and others
+        * when calling callbacks above.
+        */
+       wmb();
+       inet->sk_user_data = svsk;
 
        /* Initialize the socket */
        if (sock->type == SOCK_DGRAM)
index d174ee3254eecb523dbc86061d80a1e812dcc305..767e0537dde5a8d0cfac97f6b11ee1d568ef87ed 100644 (file)
@@ -596,7 +596,7 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,
        rcu_read_lock();
        b = rcu_dereference_rtnl(dev->tipc_ptr);
        if (likely(b && test_bit(0, &b->up) &&
-                  (skb->pkt_type <= PACKET_BROADCAST))) {
+                  (skb->pkt_type <= PACKET_MULTICAST))) {
                skb->next = NULL;
                tipc_rcv(dev_net(dev), skb, b);
                rcu_read_unlock();
index ab3087687a32446ffa3bbfaccf206028886e6945..dcd90e6fa7c39c962eb6f6684cc31dd2b2443e4a 100644 (file)
@@ -513,6 +513,7 @@ bool tipc_msg_reverse(u32 own_node,  struct sk_buff **skb, int err)
 
        /* Now reverse the concerned fields */
        msg_set_errcode(hdr, err);
+       msg_set_non_seq(hdr, 0);
        msg_set_origport(hdr, msg_destport(&ohdr));
        msg_set_destport(hdr, msg_origport(&ohdr));
        msg_set_destnode(hdr, msg_prevnode(&ohdr));
index 9bfe886ab33080f653ec1c39e0255b15709d0b76..750949dfc1d7d9bc81c55de55f0e7dafb4023a2c 100644 (file)
@@ -258,13 +258,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
        arg = nlmsg_new(0, GFP_KERNEL);
        if (!arg) {
                kfree_skb(msg->rep);
+               msg->rep = NULL;
                return -ENOMEM;
        }
 
        err = __tipc_nl_compat_dumpit(cmd, msg, arg);
-       if (err)
+       if (err) {
                kfree_skb(msg->rep);
-
+               msg->rep = NULL;
+       }
        kfree_skb(arg);
 
        return err;
index 7b52a380d710d238c440293b6d3b8973fc30c90c..be8982b4f8c00be8bb95748c1c33a76e13079dff 100644 (file)
@@ -2304,10 +2304,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state,
         */
        mutex_lock(&u->iolock);
 
-       if (flags & MSG_PEEK)
-               skip = sk_peek_offset(sk, flags);
-       else
-               skip = 0;
+       skip = max(sk_peek_offset(sk, flags), 0);
 
        do {
                int chunk;
index dd8e2dde0b34b3759fe6061eb5c2887f4ecd21fd..9ffd3dda3889c56a7a72229bed21ff5c49d62856 100644 (file)
@@ -85,8 +85,8 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
 
 # try-run
 # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
-# Exit code chooses option. "$$TMP" is can be used as temporary file and
-# is automatically cleaned up.
+# Exit code chooses option. "$$TMP" serves as a temporary file and is
+# automatically cleaned up.
 try-run = $(shell set -e;              \
        TMP="$(TMPOUT).$$$$.tmp";       \
        TMPO="$(TMPOUT).$$$$.o";        \
@@ -261,7 +261,6 @@ make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
 any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 
 # Execute command if command has changed or prerequisite(s) are updated.
-#
 if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
        @set -e;                                                             \
        $(echo-cmd) $(cmd_$(1));                                             \
@@ -315,7 +314,7 @@ if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
        $(rule_$(1)), @:)
 
 ###
-# why - tell why a a target got build
+# why - tell why a target got built
 #       enabled by make V=2
 #       Output (listed in the order they are checked):
 #          (1) - due to target is PHONY
index 95f7d80901524a4c966505397af6931f3e3316f3..a6c8c17808551aa146102ccb4132f8f5605ea74d 100644 (file)
@@ -1,9 +1,9 @@
 # include/asm-generic contains a lot of files that are used
 # verbatim by several architectures.
 #
-# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild
 # and for each file listed in this file with generic-y creates
-# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src))
 
 kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
 -include $(kbuild-file)
index 4a9a2cec0a1b52d601f9f057eb8fbb515e69de50..f6152c70f7f417ca234da77c8a503a6c974bcec2 100644 (file)
@@ -229,8 +229,8 @@ ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
 endif
 # Due to recursion, we must skip empty.o.
 # The empty.o file is created in the make process in order to determine
-#  the target endianness and word size. It is made before all other C
-#  files, including recordmcount.
+# the target endianness and word size. It is made before all other C
+# files, including recordmcount.
 sub_cmd_record_mcount =                                        \
        if [ $(@) != "scripts/mod/empty.o" ]; then      \
                $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)";   \
@@ -245,13 +245,13 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH
        "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
        "$(if $(part-of-module),1,0)" "$(@)";
 recordmcount_source := $(srctree)/scripts/recordmcount.pl
-endif
+endif # BUILD_C_RECORDMCOUNT
 cmd_record_mcount =                                            \
        if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" =   \
             "$(CC_FLAGS_FTRACE)" ]; then                       \
                $(sub_cmd_record_mcount)                        \
        fi;
-endif
+endif # CONFIG_FTRACE_MCOUNT_RECORD
 
 ifdef CONFIG_STACK_VALIDATION
 ifneq ($(SKIP_STACK_VALIDATION),1)
index 34614a48b717eafa2c15f418e6e6769905e32ec1..993fb85982df2df2a7f8e20780d0cfbe3cb732e8 100644 (file)
@@ -14,7 +14,7 @@ src := $(obj)
 PHONY := __dtbs_install
 __dtbs_install:
 
-export dtbinst-root ?= $(obj)
+export dtbinst_root ?= $(obj)
 
 include include/config/auto.conf
 include scripts/Kbuild.include
@@ -27,7 +27,7 @@ dtbinst-dirs  := $(dts-dirs)
 quiet_cmd_dtb_install =        INSTALL $<
       cmd_dtb_install =        mkdir -p $(2); cp $< $(2)
 
-install-dir = $(patsubst $(dtbinst-root)%,$(INSTALL_DTBS_PATH)%,$(obj))
+install-dir = $(patsubst $(dtbinst_root)%,$(INSTALL_DTBS_PATH)%,$(obj))
 
 $(dtbinst-files): %.dtb: $(obj)/%.dtb
        $(call cmd,dtb_install,$(install-dir))
index ec10d9345bc2d9b978d8cae4d85bf2fd89ab121c..0372b33febe52f74978420c2c559adef5e815374 100644 (file)
@@ -1,5 +1,5 @@
 ###
-# Makefile.basic lists the most basic programs used during the build process.
+# This Makefile lists the most basic programs used during the build process.
 # The programs listed herein are what are needed to do the basic stuff,
 # such as fix file dependencies.
 # This initial step is needed to avoid files to be recompiled
index fff818b92acb7e3e469ce06cc722f3ab0f275171..bbf62cb1f8190917e930d7003eddbf20f0fececc 100644 (file)
@@ -25,7 +25,7 @@
  *
  * So we play the same trick that "mkdep" played before. We replace
  * the dependency on autoconf.h by a dependency on every config
- * option which is mentioned in any of the listed prequisites.
+ * option which is mentioned in any of the listed prerequisites.
  *
  * kconfig populates a tree in include/config/ with an empty file
  * for each config symbol and when the configuration is updated
@@ -34,7 +34,7 @@
  * the config symbols are rebuilt.
  *
  * So if the user changes his CONFIG_HIS_DRIVER option, only the objects
- * which depend on "include/linux/config/his/driver.h" will be rebuilt,
+ * which depend on "include/config/his/driver.h" will be rebuilt,
  * so most likely only his driver ;-)
  *
  * The idea above dates, by the way, back to Michael E Chastain, AFAIK.
@@ -75,7 +75,7 @@
  * and then basically copies the .<target>.d file to stdout, in the
  * process filtering out the dependency on autoconf.h and adding
  * dependencies on include/config/my/option.h for every
- * CONFIG_MY_OPTION encountered in any of the prequisites.
+ * CONFIG_MY_OPTION encountered in any of the prerequisites.
  *
  * It will also filter out all the dependencies on *.ver. We need
  * to make sure that the generated version checksum are globally up
index 3c6be1452e35dfc48e74ad23e1668c633ce57b24..4525e127afd904e62f34af00e26ccee52252b460 100644 (file)
@@ -1137,7 +1137,7 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
                mutex_lock(&ue->card->user_ctl_lock);
                change = ue->tlv_data_size != size;
                if (!change)
-                       change = memcmp(ue->tlv_data, new_data, size);
+                       change = memcmp(ue->tlv_data, new_data, size) != 0;
                kfree(ue->tlv_data);
                ue->tlv_data = new_data;
                ue->tlv_data_size = size;
index a536760a94c26521a04cbe4233b1d5fa4b69e625..45c1336c6597f1b49a343b8629613fb979b0ef8b 100644 (file)
@@ -47,10 +47,10 @@ config SND_SEQ_HRTIMER_DEFAULT
          timer.
 
 config SND_SEQ_MIDI_EVENT
-       def_tristate SND_RAWMIDI
+       tristate
 
 config SND_SEQ_MIDI
-       tristate
+       def_tristate SND_RAWMIDI
        select SND_SEQ_MIDI_EVENT
 
 config SND_SEQ_MIDI_EMUL
index 272c55fe17c88aec700a7552da4473349c4ce359..ea2d0ae85bd367d5ea70068ee74d925a349789c3 100644 (file)
@@ -1502,16 +1502,11 @@ static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client,
 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
 {
        struct snd_seq_queue_info *info = arg;
-       int result;
        struct snd_seq_queue *q;
 
-       result = snd_seq_queue_alloc(client->number, info->locked, info->flags);
-       if (result < 0)
-               return result;
-
-       q = queueptr(result);
-       if (q == NULL)
-               return -EINVAL;
+       q = snd_seq_queue_alloc(client->number, info->locked, info->flags);
+       if (IS_ERR(q))
+               return PTR_ERR(q);
 
        info->queue = q->queue;
        info->locked = q->locked;
@@ -1521,7 +1516,7 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
        if (!info->name[0])
                snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue);
        strlcpy(q->name, info->name, sizeof(q->name));
-       queuefree(q);
+       snd_use_lock_free(&q->use_lock);
 
        return 0;
 }
index 450c5187eecb6bb083736d2d2a1aad43b98c7c3f..79e0c5604ef806d62eca084293e66222b8fe6828 100644 (file)
@@ -184,22 +184,26 @@ void __exit snd_seq_queues_delete(void)
 static void queue_use(struct snd_seq_queue *queue, int client, int use);
 
 /* allocate a new queue -
- * return queue index value or negative value for error
+ * return pointer to new queue or ERR_PTR(-errno) for error
+ * The new queue's use_lock is set to 1. It is the caller's responsibility to
+ * call snd_use_lock_free(&q->use_lock).
  */
-int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
+struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
 {
        struct snd_seq_queue *q;
 
        q = queue_new(client, locked);
        if (q == NULL)
-               return -ENOMEM;
+               return ERR_PTR(-ENOMEM);
        q->info_flags = info_flags;
        queue_use(q, client, 1);
+       snd_use_lock_use(&q->use_lock);
        if (queue_list_add(q) < 0) {
+               snd_use_lock_free(&q->use_lock);
                queue_delete(q);
-               return -ENOMEM;
+               return ERR_PTR(-ENOMEM);
        }
-       return q->queue;
+       return q;
 }
 
 /* delete a queue - queue must be owned by the client */
index 30c8111477f61ed26987dc03abbe9670b36db221..719093489a2c4eec57fed70d4ba2b862cb64a9cf 100644 (file)
@@ -71,7 +71,7 @@ void snd_seq_queues_delete(void);
 
 
 /* create new queue (constructor) */
-int snd_seq_queue_alloc(int client, int locked, unsigned int flags);
+struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags);
 
 /* delete queue (destructor) */
 int snd_seq_queue_delete(int client, int queueid);
index f0e4d502d60482ae8374cf9f830b739eb9e38753..066b5df666f42d2259b40ee5d21492f9165e4470 100644 (file)
@@ -210,9 +210,14 @@ EXPORT_SYMBOL(fw_iso_resources_update);
  */
 void fw_iso_resources_free(struct fw_iso_resources *r)
 {
-       struct fw_card *card = fw_parent_device(r->unit)->card;
+       struct fw_card *card;
        int bandwidth, channel;
 
+       /* Not initialized. */
+       if (r->unit == NULL)
+               return;
+       card = fw_parent_device(r->unit)->card;
+
        mutex_lock(&r->mutex);
 
        if (r->allocated) {
index bf779cfeef0dfaea62ea5684997314a9fe02d4c0..59a270406353d71563f2473ff1675116729acda9 100644 (file)
@@ -128,6 +128,7 @@ static void do_registration(struct work_struct *work)
        return;
 error:
        snd_motu_transaction_unregister(motu);
+       snd_motu_stream_destroy_duplex(motu);
        snd_card_free(motu->card);
        dev_info(&motu->unit->device,
                 "Sound card registration failed: %d\n", err);
index dc585959ca32c8cfbfa3aff0557a4e20c7ec1430..a2b56b188be4d90d9c51547e5fd8a7013700b14f 100644 (file)
@@ -698,10 +698,18 @@ static int copy_gctl(struct snd_emu10k1 *emu,
 {
        struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
 
-       if (emu->support_tlv)
-               return copy_from_user(gctl, &_gctl[idx], sizeof(*gctl));
+       if (emu->support_tlv) {
+               if (in_kernel)
+                       memcpy(gctl, (void *)&_gctl[idx], sizeof(*gctl));
+               else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)))
+                       return -EFAULT;
+               return 0;
+       }
+
        octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
-       if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
+       if (in_kernel)
+               memcpy(gctl, (void *)&octl[idx], sizeof(*octl));
+       else if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
                return -EFAULT;
        gctl->tlv = NULL;
        return 0;
index 8c1289963c802b34783a8a8b4af42ed55bbcd71c..a81aacf684b26341ec9257366d7c83a47962a16d 100644 (file)
@@ -947,6 +947,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
        SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
+       SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
        SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
index a91a9ef00c40611db8f19ffcd14d414cd7d42d71..217bb582aff16a6ec428311fddc53370e0355288 100644 (file)
@@ -6647,7 +6647,6 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
        SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
                ALC225_STANDARD_PINS,
                {0x12, 0xb7a60130},
-               {0x13, 0xb8a61140},
                {0x17, 0x90170110}),
        {}
 };
index 36e530a36c8241d5005c8e8f5f933f2a405c3434..6f629278d982d23e53baf1bd7819e2103e7e02b7 100644 (file)
@@ -5021,6 +5021,7 @@ static const struct regmap_config rt5677_regmap = {
 static const struct i2c_device_id rt5677_i2c_id[] = {
        { "rt5677", RT5677 },
        { "rt5676", RT5676 },
+       { "RT5677CE:00", RT5677 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
index 082736c539bc14eec73a1afad11e2a3cd5577d89..e630813c5008627d50e41637e03eeaf8ef2bf0c3 100644 (file)
@@ -542,6 +542,8 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
 
        if (size < sizeof(scale))
                return -ENOMEM;
+       if (cval->min_mute)
+               scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE;
        scale[2] = cval->dBmin;
        scale[3] = cval->dBmax;
        if (copy_to_user(_tlv, scale, sizeof(scale)))
index 3417ef347e40432482b84de271a3bb98c8724297..2b4b067646ab099653fe7ea79d9af1570e2971f6 100644 (file)
@@ -64,6 +64,7 @@ struct usb_mixer_elem_info {
        int cached;
        int cache_val[MAX_CHANNELS];
        u8 initialized;
+       u8 min_mute;
        void *private_data;
 };
 
index e3d1dec48ee49f21d4efe4627fc3c264d76fcfe2..e1e7ce9ab217f6f716fc95da5d1544279c0d1b75 100644 (file)
@@ -1878,6 +1878,12 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
                if (unitid == 7 && cval->control == UAC_FU_VOLUME)
                        snd_dragonfly_quirk_db_scale(mixer, cval, kctl);
                break;
+       /* lowest playback value is muted on C-Media devices */
+       case USB_ID(0x0d8c, 0x000c):
+       case USB_ID(0x0d8c, 0x0014):
+               if (strstr(kctl->id.name, "Playback"))
+                       cval->min_mute = 1;
+               break;
        }
 }
 
index d7b0b0a3a2db55617a908e2fe4a8a2af90082e02..5d2a63248b1d4e77b1bf3edde93ba86710d08f38 100644 (file)
@@ -1142,6 +1142,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
        case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
        case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
        case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
+       case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */
        case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
        case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */
        case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
@@ -1308,10 +1309,13 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
            && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(20);
 
-       /* Zoom R16/24 needs a tiny delay here, otherwise requests like
-        * get/set frequency return as failed despite actually succeeding.
+       /* Zoom R16/24, Logitech H650e, Jabra 550a 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) &&
+       if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
+            chip->usb_id == USB_ID(0x046d, 0x0a46) ||
+            chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
            (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(1);
 }
@@ -1374,6 +1378,10 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
                        }
                }
                break;
+       case USB_ID(0x16d0, 0x0a23):
+               if (fp->altsetting == 2)
+                       return SNDRV_PCM_FMTBIT_DSD_U32_BE;
+               break;
 
        default:
                break;
index 1a2c07eb7795bb4fb43e4a97bdc721d7cbc7f3b8..8c67a90dbd8229062fe1c0a9ae317fd5f3c1689b 100644 (file)
@@ -879,7 +879,8 @@ bpf_object__create_maps(struct bpf_object *obj)
                        size_t j;
                        int err = *pfd;
 
-                       pr_warning("failed to create map: %s\n",
+                       pr_warning("failed to create map (name: '%s'): %s\n",
+                                  obj->maps[i].name,
                                   strerror(errno));
                        for (j = 0; j < i; j++)
                                zclose(obj->maps[j].fd);
index a36c2eba64e7729347e46175a11f89ff5fe8ebbe..4559a21a8de2d788b5242bc4e8df92c484a10764 100644 (file)
@@ -271,7 +271,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
        case 0x8d:
                if (rex == 0x48 && modrm == 0x65) {
 
-                       /* lea -disp(%rbp), %rsp */
+                       /* lea disp(%rbp), %rsp */
                        *type = INSN_STACK;
                        op->src.type = OP_SRC_ADD;
                        op->src.reg = CFI_BP;
@@ -281,6 +281,30 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
                        break;
                }
 
+               if (rex == 0x48 && (modrm == 0xa4 || modrm == 0x64) &&
+                   sib == 0x24) {
+
+                       /* lea disp(%rsp), %rsp */
+                       *type = INSN_STACK;
+                       op->src.type = OP_SRC_ADD;
+                       op->src.reg = CFI_SP;
+                       op->src.offset = insn.displacement.value;
+                       op->dest.type = OP_DEST_REG;
+                       op->dest.reg = CFI_SP;
+                       break;
+               }
+
+               if (rex == 0x48 && modrm == 0x2c && sib == 0x24) {
+
+                       /* lea (%rsp), %rbp */
+                       *type = INSN_STACK;
+                       op->src.type = OP_SRC_REG;
+                       op->src.reg = CFI_SP;
+                       op->dest.type = OP_DEST_REG;
+                       op->dest.reg = CFI_BP;
+                       break;
+               }
+
                if (rex == 0x4c && modrm == 0x54 && sib == 0x24 &&
                    insn.displacement.value == 8) {
 
index e2fbb890aef9549281318a4241a2e5a8ad68b9d1..7c647f619d63faf3eff4c135c1b302565b7f78d5 100644 (file)
@@ -14,7 +14,7 @@ all:
        done
 
 override define RUN_TESTS
-       @if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi
+       $(OUTPUT)/run.sh
 endef
 
 override define INSTALL_RULE
old mode 100644 (file)
new mode 100755 (executable)
index 8cecae9..7956ea3
@@ -473,8 +473,8 @@ usage()
        echo "    all     Runs all tests (default)"
        echo "    -t      Run test ID the number amount of times is recommended"
        echo "    -w      Watch test ID run until it runs into an error"
-       echo "    -c      Run test ID once"
-       echo "    -s      Run test ID x test-count number of times"
+       echo "    -s      Run test ID once"
+       echo "    -c      Run test ID x test-count number of times"
        echo "    -l      List all test ID list"
        echo " -h|--help  Help"
        echo
index 1c12b5855e4f929c75706a4adf0d117931e29dec..5fc7ad359e2195ed45588091df4b0a439f15551c 100755 (executable)
@@ -333,6 +333,10 @@ function ntb_tool_tests()
        link_test $LOCAL_TOOL $REMOTE_TOOL
        link_test $REMOTE_TOOL $LOCAL_TOOL
 
+       #Ensure the link is up on both sides before continuing
+       write_file Y $LOCAL_TOOL/link_event
+       write_file Y $REMOTE_TOOL/link_event
+
        for PEER_TRANS in $(ls $LOCAL_TOOL/peer_trans*); do
                PT=$(basename $PEER_TRANS)
                write_file $MW_SIZE $LOCAL_TOOL/$PT
old mode 100644 (file)
new mode 100755 (executable)
index e8c61830825a4ba1fedc9b4949561f5c61b185a5..22312eb4c9419a5fc3ee7054b4a0b604f7cdafce 100644 (file)
@@ -229,10 +229,9 @@ static void init_test(void)
        printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t",
               1e9 * precision);
 
-       if (precision > MAX_PRECISION) {
-               printf("[SKIP]\n");
-               ksft_exit_skip();
-       }
+       if (precision > MAX_PRECISION)
+               ksft_exit_skip("precision: %.0f ns > MAX_PRECISION: %.0f ns\n",
+                               1e9 * precision, 1e9 * MAX_PRECISION);
 
        printf("[OK]\n");
        srand(ts.tv_sec ^ ts.tv_nsec);