aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2016-05-27 11:16:53 -0400
committerTakashi Iwai <tiwai@suse.de>2016-05-27 11:16:53 -0400
commiteb4606e64a7d548f5d60a9583baa8104890b2c6e (patch)
tree2dc8e587fc79c207dab2fb74830963cc84dcf801
parent86c72d1ce91d804e4fa8d90b316a89597dd220f1 (diff)
parentbf65921380cd50b87618df550398e06581f4a361 (diff)
Merge tag 'asoc-v4.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v4.7 part 2 Really sorry about this late pull request. It looks like at the time I sent my pull request for v4.7 there was some conflict or other issue which caused my script to stop merging the ASoC branches at some point after the HDMI changes. It's all specific driver updates, including: - New drivers for MAX98371 and TAS5720. - SPI support for TLV320AIC32x4. - TDM support for STI Uniperf IPs. This code should all have been in -next prior to the merge window apart from some fixes, it dropped out on the 18th.
-rw-r--r--Documentation/devicetree/bindings/regmap/regmap.txt59
-rw-r--r--Documentation/devicetree/bindings/sound/max98371.txt17
-rw-r--r--Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt5
-rw-r--r--Documentation/devicetree/bindings/sound/mt8173-rt5650.txt10
-rw-r--r--Documentation/devicetree/bindings/sound/st,sti-asoc-card.txt48
-rw-r--r--Documentation/devicetree/bindings/sound/tas571x.txt10
-rw-r--r--Documentation/devicetree/bindings/sound/tas5720.txt25
-rw-r--r--Documentation/networking/checksum-offloads.txt14
-rw-r--r--Documentation/sysctl/kernel.txt2
-rw-r--r--MAINTAINERS14
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/at91sam9x5.dtsi2
-rw-r--r--arch/arm/boot/dts/sama5d2.dtsi2
-rw-r--r--arch/arm64/Kconfig.platforms1
-rw-r--r--arch/arm64/net/bpf_jit_comp.c1
-rw-r--r--arch/x86/configs/kvm_guest.config3
-rw-r--r--arch/x86/entry/syscalls/syscall_32.tbl4
-rw-r--r--arch/x86/events/intel/core.c2
-rw-r--r--arch/x86/events/intel/pt.c2
-rw-r--r--arch/x86/events/intel/uncore_snbep.c7
-rw-r--r--arch/x86/events/msr.c2
-rw-r--r--arch/x86/include/asm/uaccess.h8
-rw-r--r--arch/x86/kernel/cpu/intel.c2
-rw-r--r--arch/x86/kernel/smpboot.c5
-rw-r--r--arch/x86/kvm/emulate.c6
-rw-r--r--block/blk-map.c47
-rw-r--r--crypto/Kconfig1
-rw-r--r--crypto/ahash.c3
-rw-r--r--crypto/testmgr.c27
-rw-r--r--drivers/base/regmap/internal.h1
-rw-r--r--drivers/base/regmap/regmap-mmio.c5
-rw-r--r--drivers/base/regmap/regmap-spmi.c2
-rw-r--r--drivers/crypto/qat/qat_common/adf_common_drv.h11
-rw-r--r--drivers/crypto/qat/qat_common/adf_ctl_drv.c6
-rw-r--r--drivers/crypto/qat/qat_common/adf_sriov.c26
-rw-r--r--drivers/gpu/drm/amd/amdgpu/atombios_dp.c4
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c16
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h2
-rw-r--r--drivers/gpu/drm/i915/intel_audio.c9
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c8
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c24
-rw-r--r--drivers/gpu/drm/i915/intel_display.c5
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c22
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c4
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c6
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c10
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_auxch.c2
-rw-r--r--drivers/input/misc/max8997_haptic.c6
-rw-r--r--drivers/input/misc/twl6040-vibra.c1
-rw-r--r--drivers/input/mouse/byd.c4
-rw-r--r--drivers/media/v4l2-core/videobuf2-v4l2.c6
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_cle.c11
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_cle.h2
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.c19
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.h8
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.c82
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.h18
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c86
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.h2
-rw-r--r--drivers/net/ethernet/cavium/thunder/nicvf_queues.c4
-rw-r--r--drivers/net/ethernet/ezchip/nps_enet.c30
-rw-r--r--drivers/net/ethernet/ezchip/nps_enet.h2
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c10
-rw-r--r--drivers/net/ethernet/marvell/Kconfig2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Kconfig8
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Makefile3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/vxlan.h11
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c8
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c14
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c3
-rw-r--r--drivers/net/ethernet/qlogic/qede/qede_main.c8
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c8
-rw-r--r--drivers/net/ethernet/renesas/ravb_main.c2
-rw-r--r--drivers/net/geneve.c5
-rw-r--r--drivers/net/macsec.c19
-rw-r--r--drivers/net/macvtap.c2
-rw-r--r--drivers/net/phy/phy.c8
-rw-r--r--drivers/net/vxlan.c5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tx.c83
-rw-r--r--drivers/net/xen-netback/netback.c1
-rw-r--r--drivers/nvdimm/pmem.c4
-rw-r--r--drivers/pci/bus.c6
-rw-r--r--drivers/pinctrl/pinctrl-at91-pio4.c2
-rw-r--r--drivers/regulator/axp20x-regulator.c12
-rw-r--r--drivers/regulator/da9063-regulator.c2
-rw-r--r--drivers/regulator/gpio-regulator.c2
-rw-r--r--drivers/regulator/s2mps11.c28
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c1
-rw-r--r--drivers/scsi/qla1280.c2
-rw-r--r--drivers/spi/spi-ep93xx.c2
-rw-r--r--drivers/spi/spi-fsl-dspi.c4
-rw-r--r--drivers/spi/spi-omap2-mcspi.c62
-rw-r--r--drivers/spi/spi-pxa2xx.c2
-rw-r--r--drivers/spi/spi-ti-qspi.c45
-rw-r--r--fs/ecryptfs/file.c71
-rw-r--r--fs/isofs/rock.c13
-rw-r--r--fs/kernfs/dir.c6
-rw-r--r--fs/kernfs/mount.c15
-rw-r--r--fs/namei.c59
-rw-r--r--fs/ocfs2/acl.c87
-rw-r--r--fs/ocfs2/acl.h5
-rw-r--r--fs/ocfs2/file.c4
-rw-r--r--fs/ocfs2/namei.c23
-rw-r--r--fs/ocfs2/refcounttree.c17
-rw-r--r--fs/ocfs2/xattr.c14
-rw-r--r--fs/ocfs2/xattr.h4
-rw-r--r--fs/open.c12
-rw-r--r--fs/overlayfs/super.c4
-rw-r--r--fs/proc/base.c2
-rw-r--r--fs/splice.c3
-rw-r--r--include/linux/compiler-gcc.h2
-rw-r--r--include/linux/dcache.h12
-rw-r--r--include/linux/kernfs.h2
-rw-r--r--include/linux/mfd/samsung/s2mps11.h2
-rw-r--r--include/linux/mfd/twl6040.h1
-rw-r--r--include/linux/mm.h9
-rw-r--r--include/linux/namei.h2
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--include/linux/swap.h6
-rw-r--r--include/linux/uio.h1
-rw-r--r--include/net/netns/xfrm.h1
-rw-r--r--include/net/udp_tunnel.h9
-rw-r--r--include/uapi/linux/if.h28
-rw-r--r--include/uapi/linux/if_macsec.h4
-rw-r--r--include/uapi/linux/libc-compat.h44
-rw-r--r--include/uapi/linux/tc_act/Kbuild1
-rw-r--r--include/uapi/sound/asoc.h44
-rw-r--r--kernel/cgroup.c63
-rw-r--r--kernel/events/core.c2
-rw-r--r--kernel/events/ring_buffer.c10
-rw-r--r--kernel/sched/deadline.c1
-rw-r--r--kernel/sched/fair.c29
-rw-r--r--kernel/sched/rt.c1
-rw-r--r--kernel/workqueue.c11
-rw-r--r--lib/asn1_decoder.c16
-rw-r--r--lib/iov_iter.c19
-rw-r--r--mm/huge_memory.c71
-rw-r--r--mm/ksm.c15
-rw-r--r--mm/memory.c22
-rw-r--r--mm/swapfile.c13
-rw-r--r--mm/zsmalloc.c7
-rw-r--r--net/bridge/br_ioctl.c5
-rw-r--r--net/bridge/br_multicast.c12
-rw-r--r--net/core/flow.c14
-rw-r--r--net/core/rtnetlink.c18
-rw-r--r--net/ipv4/fib_semantics.c2
-rw-r--r--net/ipv4/fou.c6
-rw-r--r--net/ipv4/ip_gre.c7
-rw-r--r--net/ipv4/ip_vti.c18
-rw-r--r--net/ipv4/tcp_output.c6
-rw-r--r--net/ipv4/udp_offload.c8
-rw-r--r--net/ipv6/icmp.c5
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/llc/af_llc.c1
-rw-r--r--net/netfilter/nf_conntrack_core.c6
-rw-r--r--net/netfilter/nfnetlink_acct.c2
-rw-r--r--net/netfilter/xt_IDLETIMER.c1
-rw-r--r--net/openvswitch/conntrack.c13
-rw-r--r--net/sched/act_ife.c14
-rw-r--r--net/sched/act_ipt.c19
-rw-r--r--net/sched/act_mirred.c19
-rw-r--r--net/sched/act_simple.c18
-rw-r--r--net/sched/act_skbedit.c18
-rw-r--r--net/sched/act_vlan.c22
-rw-r--r--net/vmw_vsock/af_vsock.c21
-rw-r--r--net/x25/x25_facilities.c1
-rw-r--r--net/xfrm/xfrm_output.c3
-rw-r--r--sound/soc/codecs/Kconfig38
-rw-r--r--sound/soc/codecs/Makefile11
-rw-r--r--sound/soc/codecs/ak4642.c3
-rw-r--r--sound/soc/codecs/max98371.c441
-rw-r--r--sound/soc/codecs/max98371.h67
-rw-r--r--sound/soc/codecs/rt298.c51
-rw-r--r--sound/soc/codecs/rt298.h2
-rw-r--r--sound/soc/codecs/rt5677.c24
-rw-r--r--sound/soc/codecs/tas571x.c141
-rw-r--r--sound/soc/codecs/tas571x.h22
-rw-r--r--sound/soc/codecs/tas5720.c620
-rw-r--r--sound/soc/codecs/tas5720.h90
-rw-r--r--sound/soc/codecs/tlv320aic31xx.c10
-rw-r--r--sound/soc/codecs/tlv320aic32x4-i2c.c74
-rw-r--r--sound/soc/codecs/tlv320aic32x4-spi.c76
-rw-r--r--sound/soc/codecs/tlv320aic32x4.c279
-rw-r--r--sound/soc/codecs/tlv320aic32x4.h7
-rw-r--r--sound/soc/codecs/twl6040.c16
-rw-r--r--sound/soc/codecs/wm8962.c9
-rw-r--r--sound/soc/codecs/wm8962.h6
-rw-r--r--sound/soc/generic/simple-card.c1
-rw-r--r--sound/soc/kirkwood/Kconfig1
-rw-r--r--sound/soc/mediatek/Kconfig1
-rw-r--r--sound/soc/mediatek/mt8173-rt5650-rt5676.c27
-rw-r--r--sound/soc/mediatek/mt8173-rt5650.c50
-rw-r--r--sound/soc/mediatek/mtk-afe-pcm.c2
-rw-r--r--sound/soc/omap/mcbsp.c8
-rw-r--r--sound/soc/omap/omap-pcm.c2
-rw-r--r--sound/soc/pxa/brownstone.c1
-rw-r--r--sound/soc/pxa/mioa701_wm9713.c1
-rw-r--r--sound/soc/pxa/mmp-pcm.c1
-rw-r--r--sound/soc/pxa/mmp-sspa.c1
-rw-r--r--sound/soc/pxa/palm27x.c1
-rw-r--r--sound/soc/pxa/pxa-ssp.c1
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.c1
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c1
-rw-r--r--sound/soc/qcom/lpass-platform.c8
-rw-r--r--sound/soc/sh/rcar/adg.c8
-rw-r--r--sound/soc/sh/rcar/dma.c12
-rw-r--r--sound/soc/sh/rcar/rsnd.h13
-rw-r--r--sound/soc/sh/rcar/src.c4
-rw-r--r--sound/soc/soc-topology.c48
-rw-r--r--sound/soc/sti/sti_uniperif.c144
-rw-r--r--sound/soc/sti/uniperif.h220
-rw-r--r--sound/soc/sti/uniperif_player.c182
-rw-r--r--sound/soc/sti/uniperif_reader.c229
-rw-r--r--tools/build/Makefile.feature2
-rw-r--r--tools/build/feature/Makefile4
-rw-r--r--tools/build/feature/test-all.c5
-rw-r--r--tools/build/feature/test-dwarf_getlocations.c12
-rw-r--r--tools/lib/traceevent/parse-filter.c4
-rw-r--r--tools/net/bpf_jit_disasm.c3
-rw-r--r--tools/perf/arch/x86/util/dwarf-regs.c8
-rw-r--r--tools/perf/builtin-script.c70
-rw-r--r--tools/perf/builtin-stat.c7
-rw-r--r--tools/perf/config/Makefile6
-rw-r--r--tools/perf/util/dwarf-aux.c9
-rw-r--r--tools/perf/util/event.c12
-rw-r--r--tools/perf/util/evsel.c23
-rw-r--r--tools/perf/util/parse-events.c60
-rw-r--r--tools/perf/util/sort.c3
-rw-r--r--tools/perf/util/thread_map.c8
237 files changed, 4366 insertions, 1052 deletions
diff --git a/Documentation/devicetree/bindings/regmap/regmap.txt b/Documentation/devicetree/bindings/regmap/regmap.txt
index e98a9652ccc8..0127be360fe8 100644
--- a/Documentation/devicetree/bindings/regmap/regmap.txt
+++ b/Documentation/devicetree/bindings/regmap/regmap.txt
@@ -1,50 +1,29 @@
1Device-Tree binding for regmap 1Devicetree binding for regmap
2
3The endianness mode of CPU & Device scenarios:
4Index Device Endianness properties
5---------------------------------------------------
61 BE 'big-endian'
72 LE 'little-endian'
83 Native 'native-endian'
9
10For one device driver, which will run in different scenarios above
11on different SoCs using the devicetree, we need one way to simplify
12this.
13 2
14Optional properties: 3Optional properties:
15- {big,little,native}-endian: these are boolean properties, if absent
16 then the implementation will choose a default based on the device
17 being controlled. These properties are for register values and all
18 the buffers only. Native endian means that the CPU and device have
19 the same endianness.
20 4
21Examples: 5 little-endian,
22Scenario 1 : CPU in LE mode & device in LE mode. 6 big-endian,
23dev: dev@40031000 { 7 native-endian: See common-properties.txt for a definition
24 compatible = "name";
25 reg = <0x40031000 0x1000>;
26 ...
27};
28 8
29Scenario 2 : CPU in LE mode & device in BE mode. 9Note:
30dev: dev@40031000 { 10Regmap defaults to little-endian register access on MMIO based
31 compatible = "name"; 11devices, this is by far the most common setting. On CPU
32 reg = <0x40031000 0x1000>; 12architectures that typically run big-endian operating systems
33 ... 13(e.g. PowerPC), registers can be defined as big-endian and must
34 big-endian; 14be marked that way in the devicetree.
35};
36 15
37Scenario 3 : CPU in BE mode & device in BE mode. 16On SoCs that can be operated in both big-endian and little-endian
38dev: dev@40031000 { 17modes, with a single hardware switch controlling both the endianess
39 compatible = "name"; 18of the CPU and a byteswap for MMIO registers (e.g. many Broadcom MIPS
40 reg = <0x40031000 0x1000>; 19chips), "native-endian" is used to allow using the same device tree
41 ... 20blob in both cases.
42};
43 21
44Scenario 4 : CPU in BE mode & device in LE mode. 22Examples:
23Scenario 1 : a register set in big-endian mode.
45dev: dev@40031000 { 24dev: dev@40031000 {
46 compatible = "name"; 25 compatible = "syscon";
47 reg = <0x40031000 0x1000>; 26 reg = <0x40031000 0x1000>;
27 big-endian;
48 ... 28 ...
49 little-endian;
50}; 29};
diff --git a/Documentation/devicetree/bindings/sound/max98371.txt b/Documentation/devicetree/bindings/sound/max98371.txt
new file mode 100644
index 000000000000..6c285235e64b
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/max98371.txt
@@ -0,0 +1,17 @@
1max98371 codec
2
3This device supports I2C mode only.
4
5Required properties:
6
7- compatible : "maxim,max98371"
8- reg : The chip select number on the I2C bus
9
10Example:
11
12&i2c {
13 max98371: max98371@0x31 {
14 compatible = "maxim,max98371";
15 reg = <0x31>;
16 };
17};
diff --git a/Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt b/Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt
index f205ce9e31dd..ac28cdb4910e 100644
--- a/Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt
+++ b/Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt
@@ -1,15 +1,16 @@
1MT8173 with RT5650 RT5676 CODECS 1MT8173 with RT5650 RT5676 CODECS and HDMI via I2S
2 2
3Required properties: 3Required properties:
4- compatible : "mediatek,mt8173-rt5650-rt5676" 4- compatible : "mediatek,mt8173-rt5650-rt5676"
5- mediatek,audio-codec: the phandles of rt5650 and rt5676 codecs 5- mediatek,audio-codec: the phandles of rt5650 and rt5676 codecs
6 and of the hdmi encoder node
6- mediatek,platform: the phandle of MT8173 ASoC platform 7- mediatek,platform: the phandle of MT8173 ASoC platform
7 8
8Example: 9Example:
9 10
10 sound { 11 sound {
11 compatible = "mediatek,mt8173-rt5650-rt5676"; 12 compatible = "mediatek,mt8173-rt5650-rt5676";
12 mediatek,audio-codec = <&rt5650 &rt5676>; 13 mediatek,audio-codec = <&rt5650 &rt5676 &hdmi0>;
13 mediatek,platform = <&afe>; 14 mediatek,platform = <&afe>;
14 }; 15 };
15 16
diff --git a/Documentation/devicetree/bindings/sound/mt8173-rt5650.txt b/Documentation/devicetree/bindings/sound/mt8173-rt5650.txt
index fe5a5ef1714d..5bfa6b60530b 100644
--- a/Documentation/devicetree/bindings/sound/mt8173-rt5650.txt
+++ b/Documentation/devicetree/bindings/sound/mt8173-rt5650.txt
@@ -5,11 +5,21 @@ Required properties:
5- mediatek,audio-codec: the phandles of rt5650 codecs 5- mediatek,audio-codec: the phandles of rt5650 codecs
6- mediatek,platform: the phandle of MT8173 ASoC platform 6- mediatek,platform: the phandle of MT8173 ASoC platform
7 7
8Optional subnodes:
9- codec-capture : the subnode of rt5650 codec capture
10Required codec-capture subnode properties:
11- sound-dai: audio codec dai name on capture path
12 <&rt5650 0> : Default setting. Connect rt5650 I2S1 for capture. (dai_name = rt5645-aif1)
13 <&rt5650 1> : Connect rt5650 I2S2 for capture. (dai_name = rt5645-aif2)
14
8Example: 15Example:
9 16
10 sound { 17 sound {
11 compatible = "mediatek,mt8173-rt5650"; 18 compatible = "mediatek,mt8173-rt5650";
12 mediatek,audio-codec = <&rt5650>; 19 mediatek,audio-codec = <&rt5650>;
13 mediatek,platform = <&afe>; 20 mediatek,platform = <&afe>;
21 codec-capture {
22 sound-dai = <&rt5650 1>;
23 };
14 }; 24 };
15 25
diff --git a/Documentation/devicetree/bindings/sound/st,sti-asoc-card.txt b/Documentation/devicetree/bindings/sound/st,sti-asoc-card.txt
index 028fa1c82f50..4d9a83d9a017 100644
--- a/Documentation/devicetree/bindings/sound/st,sti-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/st,sti-asoc-card.txt
@@ -37,17 +37,18 @@ Required properties:
37 37
38 - dai-name: DAI name that describes the IP. 38 - dai-name: DAI name that describes the IP.
39 39
40 - IP mode: IP working mode depending on associated codec.
41 "HDMI" connected to HDMI codec and support IEC HDMI formats (player only).
42 "SPDIF" connected to SPDIF codec and support SPDIF formats (player only).
43 "PCM" PCM standard mode for I2S or TDM bus.
44 "TDM" TDM mode for TDM bus.
45
40Required properties ("st,sti-uni-player" compatibility only): 46Required properties ("st,sti-uni-player" compatibility only):
41 - clocks: CPU_DAI IP clock source, listed in the same order than the 47 - clocks: CPU_DAI IP clock source, listed in the same order than the
42 CPU_DAI properties. 48 CPU_DAI properties.
43 49
44 - uniperiph-id: internal SOC IP instance ID. 50 - uniperiph-id: internal SOC IP instance ID.
45 51
46 - IP mode: IP working mode depending on associated codec.
47 "HDMI" connected to HDMI codec IP and IEC HDMI formats.
48 "SPDIF"connected to SPDIF codec and support SPDIF formats.
49 "PCM" PCM standard mode for I2S or TDM bus.
50
51Optional properties: 52Optional properties:
52 - pinctrl-0: defined for CPU_DAI@1 and CPU_DAI@4 to describe I2S PIOs for 53 - pinctrl-0: defined for CPU_DAI@1 and CPU_DAI@4 to describe I2S PIOs for
53 external codecs connection. 54 external codecs connection.
@@ -56,6 +57,22 @@ Optional properties:
56 57
57Example: 58Example:
58 59
60 sti_uni_player1: sti-uni-player@1 {
61 compatible = "st,sti-uni-player";
62 status = "okay";
63 #sound-dai-cells = <0>;
64 st,syscfg = <&syscfg_core>;
65 clocks = <&clk_s_d0_flexgen CLK_PCM_1>;
66 reg = <0x8D81000 0x158>;
67 interrupts = <GIC_SPI 85 IRQ_TYPE_NONE>;
68 dmas = <&fdma0 3 0 1>;
69 st,dai-name = "Uni Player #1 (I2S)";
70 dma-names = "tx";
71 st,uniperiph-id = <1>;
72 st,version = <5>;
73 st,mode = "TDM";
74 };
75
59 sti_uni_player2: sti-uni-player@2 { 76 sti_uni_player2: sti-uni-player@2 {
60 compatible = "st,sti-uni-player"; 77 compatible = "st,sti-uni-player";
61 status = "okay"; 78 status = "okay";
@@ -65,7 +82,7 @@ Example:
65 reg = <0x8D82000 0x158>; 82 reg = <0x8D82000 0x158>;
66 interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>; 83 interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>;
67 dmas = <&fdma0 4 0 1>; 84 dmas = <&fdma0 4 0 1>;
68 dai-name = "Uni Player #1 (DAC)"; 85 dai-name = "Uni Player #2 (DAC)";
69 dma-names = "tx"; 86 dma-names = "tx";
70 uniperiph-id = <2>; 87 uniperiph-id = <2>;
71 version = <5>; 88 version = <5>;
@@ -82,7 +99,7 @@ Example:
82 interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>; 99 interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>;
83 dmas = <&fdma0 7 0 1>; 100 dmas = <&fdma0 7 0 1>;
84 dma-names = "tx"; 101 dma-names = "tx";
85 dai-name = "Uni Player #1 (PIO)"; 102 dai-name = "Uni Player #3 (SPDIF)";
86 uniperiph-id = <3>; 103 uniperiph-id = <3>;
87 version = <5>; 104 version = <5>;
88 mode = "SPDIF"; 105 mode = "SPDIF";
@@ -99,6 +116,7 @@ Example:
99 dma-names = "rx"; 116 dma-names = "rx";
100 dai-name = "Uni Reader #1 (HDMI RX)"; 117 dai-name = "Uni Reader #1 (HDMI RX)";
101 version = <3>; 118 version = <3>;
119 st,mode = "PCM";
102 }; 120 };
103 121
1042) sti-sas-codec: internal audio codec IPs driver 1222) sti-sas-codec: internal audio codec IPs driver
@@ -152,4 +170,20 @@ Example of audio card declaration:
152 sound-dai = <&sti_sasg_codec 0>; 170 sound-dai = <&sti_sasg_codec 0>;
153 }; 171 };
154 }; 172 };
173 simple-audio-card,dai-link@2 {
174 /* TDM playback */
175 format = "left_j";
176 frame-inversion = <1>;
177 cpu {
178 sound-dai = <&sti_uni_player1>;
179 dai-tdm-slot-num = <16>;
180 dai-tdm-slot-width = <16>;
181 dai-tdm-slot-tx-mask =
182 <1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 1>;
183 };
184
185 codec {
186 sound-dai = <&sti_sasg_codec 3>;
187 };
188 };
155 }; 189 };
diff --git a/Documentation/devicetree/bindings/sound/tas571x.txt b/Documentation/devicetree/bindings/sound/tas571x.txt
index 0ac31d8d5ac4..b4959f10b74b 100644
--- a/Documentation/devicetree/bindings/sound/tas571x.txt
+++ b/Documentation/devicetree/bindings/sound/tas571x.txt
@@ -1,4 +1,4 @@
1Texas Instruments TAS5711/TAS5717/TAS5719 stereo power amplifiers 1Texas Instruments TAS5711/TAS5717/TAS5719/TAS5721 stereo power amplifiers
2 2
3The codec is controlled through an I2C interface. It also has two other 3The codec is controlled through an I2C interface. It also has two other
4signals that can be wired up to GPIOs: reset (strongly recommended), and 4signals that can be wired up to GPIOs: reset (strongly recommended), and
@@ -6,7 +6,11 @@ powerdown (optional).
6 6
7Required properties: 7Required properties:
8 8
9- compatible: "ti,tas5711", "ti,tas5717", or "ti,tas5719" 9- compatible: should be one of the following:
10 - "ti,tas5711",
11 - "ti,tas5717",
12 - "ti,tas5719",
13 - "ti,tas5721"
10- reg: The I2C address of the device 14- reg: The I2C address of the device
11- #sound-dai-cells: must be equal to 0 15- #sound-dai-cells: must be equal to 0
12 16
@@ -25,6 +29,8 @@ Optional properties:
25- PVDD_B-supply: regulator phandle for the PVDD_B supply (5711) 29- PVDD_B-supply: regulator phandle for the PVDD_B supply (5711)
26- PVDD_C-supply: regulator phandle for the PVDD_C supply (5711) 30- PVDD_C-supply: regulator phandle for the PVDD_C supply (5711)
27- PVDD_D-supply: regulator phandle for the PVDD_D supply (5711) 31- PVDD_D-supply: regulator phandle for the PVDD_D supply (5711)
32- DRVDD-supply: regulator phandle for the DRVDD supply (5721)
33- PVDD-supply: regulator phandle for the PVDD supply (5721)
28 34
29Example: 35Example:
30 36
diff --git a/Documentation/devicetree/bindings/sound/tas5720.txt b/Documentation/devicetree/bindings/sound/tas5720.txt
new file mode 100644
index 000000000000..806ea7381483
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tas5720.txt
@@ -0,0 +1,25 @@
1Texas Instruments TAS5720 Mono Audio amplifier
2
3The TAS5720 serial control bus communicates through the I2C protocol only. The
4serial bus is also used for periodic codec fault checking/reporting during
5audio playback. For more product information please see the links below:
6
7http://www.ti.com/product/TAS5720L
8http://www.ti.com/product/TAS5720M
9
10Required properties:
11
12- compatible : "ti,tas5720"
13- reg : I2C slave address
14- dvdd-supply : phandle to a 3.3-V supply for the digital circuitry
15- pvdd-supply : phandle to a supply used for the Class-D amp and the analog
16
17Example:
18
19tas5720: tas5720@6c {
20 status = "okay";
21 compatible = "ti,tas5720";
22 reg = <0x6c>;
23 dvdd-supply = <&vdd_3v3_reg>;
24 pvdd-supply = <&amp_supply_reg>;
25};
diff --git a/Documentation/networking/checksum-offloads.txt b/Documentation/networking/checksum-offloads.txt
index de2a327766a7..56e36861245f 100644
--- a/Documentation/networking/checksum-offloads.txt
+++ b/Documentation/networking/checksum-offloads.txt
@@ -69,18 +69,18 @@ LCO: Local Checksum Offload
69LCO is a technique for efficiently computing the outer checksum of an 69LCO is a technique for efficiently computing the outer checksum of an
70 encapsulated datagram when the inner checksum is due to be offloaded. 70 encapsulated datagram when the inner checksum is due to be offloaded.
71The ones-complement sum of a correctly checksummed TCP or UDP packet is 71The ones-complement sum of a correctly checksummed TCP or UDP packet is
72 equal to the sum of the pseudo header, because everything else gets 72 equal to the complement of the sum of the pseudo header, because everything
73 'cancelled out' by the checksum field. This is because the sum was 73 else gets 'cancelled out' by the checksum field. This is because the sum was
74 complemented before being written to the checksum field. 74 complemented before being written to the checksum field.
75More generally, this holds in any case where the 'IP-style' ones complement 75More generally, this holds in any case where the 'IP-style' ones complement
76 checksum is used, and thus any checksum that TX Checksum Offload supports. 76 checksum is used, and thus any checksum that TX Checksum Offload supports.
77That is, if we have set up TX Checksum Offload with a start/offset pair, we 77That is, if we have set up TX Checksum Offload with a start/offset pair, we
78 know that _after the device has filled in that checksum_, the ones 78 know that after the device has filled in that checksum, the ones
79 complement sum from csum_start to the end of the packet will be equal to 79 complement sum from csum_start to the end of the packet will be equal to
80 _whatever value we put in the checksum field beforehand_. This allows us 80 the complement of whatever value we put in the checksum field beforehand.
81 to compute the outer checksum without looking at the payload: we simply 81 This allows us to compute the outer checksum without looking at the payload:
82 stop summing when we get to csum_start, then add the 16-bit word at 82 we simply stop summing when we get to csum_start, then add the complement of
83 (csum_start + csum_offset). 83 the 16-bit word at (csum_start + csum_offset).
84Then, when the true inner checksum is filled in (either by hardware or by 84Then, when the true inner checksum is filled in (either by hardware or by
85 skb_checksum_help()), the outer checksum will become correct by virtue of 85 skb_checksum_help()), the outer checksum will become correct by virtue of
86 the arithmetic. 86 the arithmetic.
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 57653a44b128..fcddfd5ded99 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -645,7 +645,7 @@ allowed to execute.
645perf_event_paranoid: 645perf_event_paranoid:
646 646
647Controls use of the performance events system by unprivileged 647Controls use of the performance events system by unprivileged
648users (without CAP_SYS_ADMIN). The default value is 1. 648users (without CAP_SYS_ADMIN). The default value is 2.
649 649
650 -1: Allow use of (almost) all events by all users 650 -1: Allow use of (almost) all events by all users
651>=0: Disallow raw tracepoint access by users without CAP_IOC_LOCK 651>=0: Disallow raw tracepoint access by users without CAP_IOC_LOCK
diff --git a/MAINTAINERS b/MAINTAINERS
index 09a9cf1e0a8a..8e325edbf62c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11319,6 +11319,20 @@ F: include/trace/
11319F: kernel/trace/ 11319F: kernel/trace/
11320F: tools/testing/selftests/ftrace/ 11320F: tools/testing/selftests/ftrace/
11321 11321
11322TRACING MMIO ACCESSES (MMIOTRACE)
11323M: Steven Rostedt <rostedt@goodmis.org>
11324M: Ingo Molnar <mingo@kernel.org>
11325R: Karol Herbst <karolherbst@gmail.com>
11326R: Pekka Paalanen <ppaalanen@gmail.com>
11327S: Maintained
11328L: linux-kernel@vger.kernel.org
11329L: nouveau@lists.freedesktop.org
11330F: kernel/trace/trace_mmiotrace.c
11331F: include/linux/mmiotrace.h
11332F: arch/x86/mm/kmmio.c
11333F: arch/x86/mm/mmio-mod.c
11334F: arch/x86/mm/testmmiotrace.c
11335
11322TRIVIAL PATCHES 11336TRIVIAL PATCHES
11323M: Jiri Kosina <trivial@kernel.org> 11337M: Jiri Kosina <trivial@kernel.org>
11324T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git 11338T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
diff --git a/Makefile b/Makefile
index acf6155421cc..0f9cb36d45c2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc7 4EXTRAVERSION =
5NAME = Charred Weasel 5NAME = Charred Weasel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 0827d594b1f0..cd0cd5fd09a3 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -106,7 +106,7 @@
106 106
107 pmc: pmc@fffffc00 { 107 pmc: pmc@fffffc00 {
108 compatible = "atmel,at91sam9x5-pmc", "syscon"; 108 compatible = "atmel,at91sam9x5-pmc", "syscon";
109 reg = <0xfffffc00 0x100>; 109 reg = <0xfffffc00 0x200>;
110 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>; 110 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
111 interrupt-controller; 111 interrupt-controller;
112 #address-cells = <1>; 112 #address-cells = <1>;
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 78996bdbd3df..9817090c1b73 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -280,7 +280,7 @@
280 status = "disabled"; 280 status = "disabled";
281 281
282 nfc@c0000000 { 282 nfc@c0000000 {
283 compatible = "atmel,sama5d4-nfc"; 283 compatible = "atmel,sama5d3-nfc";
284 #address-cells = <1>; 284 #address-cells = <1>;
285 #size-cells = <1>; 285 #size-cells = <1>;
286 reg = < /* NFC Command Registers */ 286 reg = < /* NFC Command Registers */
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index efa77c146415..521b1ec59157 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -2,6 +2,7 @@ menu "Platform selection"
2 2
3config ARCH_SUNXI 3config ARCH_SUNXI
4 bool "Allwinner sunxi 64-bit SoC Family" 4 bool "Allwinner sunxi 64-bit SoC Family"
5 select GENERIC_IRQ_CHIP
5 help 6 help
6 This enables support for Allwinner sunxi based SoCs like the A64. 7 This enables support for Allwinner sunxi based SoCs like the A64.
7 8
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index a34420a5df9a..b405bbb54431 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -476,6 +476,7 @@ emit_cond_jmp:
476 case BPF_JGE: 476 case BPF_JGE:
477 jmp_cond = A64_COND_CS; 477 jmp_cond = A64_COND_CS;
478 break; 478 break;
479 case BPF_JSET:
479 case BPF_JNE: 480 case BPF_JNE:
480 jmp_cond = A64_COND_NE; 481 jmp_cond = A64_COND_NE;
481 break; 482 break;
diff --git a/arch/x86/configs/kvm_guest.config b/arch/x86/configs/kvm_guest.config
index f9affcc3b9f1..9906505c998a 100644
--- a/arch/x86/configs/kvm_guest.config
+++ b/arch/x86/configs/kvm_guest.config
@@ -26,3 +26,6 @@ CONFIG_VIRTIO_NET=y
26CONFIG_9P_FS=y 26CONFIG_9P_FS=y
27CONFIG_NET_9P=y 27CONFIG_NET_9P=y
28CONFIG_NET_9P_VIRTIO=y 28CONFIG_NET_9P_VIRTIO=y
29CONFIG_SCSI_LOWLEVEL=y
30CONFIG_SCSI_VIRTIO=y
31CONFIG_VIRTIO_INPUT=y
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index b30dd8154cc2..4cddd17153fb 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -384,5 +384,5 @@
384375 i386 membarrier sys_membarrier 384375 i386 membarrier sys_membarrier
385376 i386 mlock2 sys_mlock2 385376 i386 mlock2 sys_mlock2
386377 i386 copy_file_range sys_copy_file_range 386377 i386 copy_file_range sys_copy_file_range
387378 i386 preadv2 sys_preadv2 387378 i386 preadv2 sys_preadv2 compat_sys_preadv2
388379 i386 pwritev2 sys_pwritev2 388379 i386 pwritev2 sys_pwritev2 compat_sys_pwritev2
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index a6fd4dbcf820..5210eaa4aa62 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3708,7 +3708,7 @@ __init int intel_pmu_init(void)
3708 c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1; 3708 c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1;
3709 } 3709 }
3710 c->idxmsk64 &= 3710 c->idxmsk64 &=
3711 ~(~0UL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed)); 3711 ~(~0ULL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed));
3712 c->weight = hweight64(c->idxmsk64); 3712 c->weight = hweight64(c->idxmsk64);
3713 } 3713 }
3714 } 3714 }
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 09a77dbc73c9..7377814de30b 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -709,6 +709,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
709 709
710 /* clear STOP and INT from current entry */ 710 /* clear STOP and INT from current entry */
711 buf->topa_index[buf->stop_pos]->stop = 0; 711 buf->topa_index[buf->stop_pos]->stop = 0;
712 buf->topa_index[buf->stop_pos]->intr = 0;
712 buf->topa_index[buf->intr_pos]->intr = 0; 713 buf->topa_index[buf->intr_pos]->intr = 0;
713 714
714 /* how many pages till the STOP marker */ 715 /* how many pages till the STOP marker */
@@ -733,6 +734,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf,
733 buf->intr_pos = idx; 734 buf->intr_pos = idx;
734 735
735 buf->topa_index[buf->stop_pos]->stop = 1; 736 buf->topa_index[buf->stop_pos]->stop = 1;
737 buf->topa_index[buf->stop_pos]->intr = 1;
736 buf->topa_index[buf->intr_pos]->intr = 1; 738 buf->topa_index[buf->intr_pos]->intr = 1;
737 739
738 return 0; 740 return 0;
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index ab2bcaaebe38..b2625867ebd1 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -219,6 +219,9 @@
219#define KNL_CHA_MSR_PMON_BOX_FILTER_TID 0x1ff 219#define KNL_CHA_MSR_PMON_BOX_FILTER_TID 0x1ff
220#define KNL_CHA_MSR_PMON_BOX_FILTER_STATE (7 << 18) 220#define KNL_CHA_MSR_PMON_BOX_FILTER_STATE (7 << 18)
221#define KNL_CHA_MSR_PMON_BOX_FILTER_OP (0xfffffe2aULL << 32) 221#define KNL_CHA_MSR_PMON_BOX_FILTER_OP (0xfffffe2aULL << 32)
222#define KNL_CHA_MSR_PMON_BOX_FILTER_REMOTE_NODE (0x1ULL << 32)
223#define KNL_CHA_MSR_PMON_BOX_FILTER_LOCAL_NODE (0x1ULL << 33)
224#define KNL_CHA_MSR_PMON_BOX_FILTER_NNC (0x1ULL << 37)
222 225
223/* KNL EDC/MC UCLK */ 226/* KNL EDC/MC UCLK */
224#define KNL_UCLK_MSR_PMON_CTR0_LOW 0x400 227#define KNL_UCLK_MSR_PMON_CTR0_LOW 0x400
@@ -1902,6 +1905,10 @@ static int knl_cha_hw_config(struct intel_uncore_box *box,
1902 reg1->reg = HSWEP_C0_MSR_PMON_BOX_FILTER0 + 1905 reg1->reg = HSWEP_C0_MSR_PMON_BOX_FILTER0 +
1903 KNL_CHA_MSR_OFFSET * box->pmu->pmu_idx; 1906 KNL_CHA_MSR_OFFSET * box->pmu->pmu_idx;
1904 reg1->config = event->attr.config1 & knl_cha_filter_mask(idx); 1907 reg1->config = event->attr.config1 & knl_cha_filter_mask(idx);
1908
1909 reg1->config |= KNL_CHA_MSR_PMON_BOX_FILTER_REMOTE_NODE;
1910 reg1->config |= KNL_CHA_MSR_PMON_BOX_FILTER_LOCAL_NODE;
1911 reg1->config |= KNL_CHA_MSR_PMON_BOX_FILTER_NNC;
1905 reg1->idx = idx; 1912 reg1->idx = idx;
1906 } 1913 }
1907 return 0; 1914 return 0;
diff --git a/arch/x86/events/msr.c b/arch/x86/events/msr.c
index ec863b9a9f78..8bef19f098d4 100644
--- a/arch/x86/events/msr.c
+++ b/arch/x86/events/msr.c
@@ -166,7 +166,7 @@ again:
166 if (unlikely(event->hw.event_base == MSR_SMI_COUNT)) 166 if (unlikely(event->hw.event_base == MSR_SMI_COUNT))
167 delta = sign_extend64(delta, 31); 167 delta = sign_extend64(delta, 31);
168 168
169 local64_add(now - prev, &event->count); 169 local64_add(delta, &event->count);
170} 170}
171 171
172static void msr_event_start(struct perf_event *event, int flags) 172static void msr_event_start(struct perf_event *event, int flags)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index a969ae607be8..2e7513d1f1f4 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -108,6 +108,14 @@ struct exception_table_entry {
108 108
109#define ARCH_HAS_RELATIVE_EXTABLE 109#define ARCH_HAS_RELATIVE_EXTABLE
110 110
111#define swap_ex_entry_fixup(a, b, tmp, delta) \
112 do { \
113 (a)->fixup = (b)->fixup + (delta); \
114 (b)->fixup = (tmp).fixup - (delta); \
115 (a)->handler = (b)->handler + (delta); \
116 (b)->handler = (tmp).handler - (delta); \
117 } while (0)
118
111extern int fixup_exception(struct pt_regs *regs, int trapnr); 119extern int fixup_exception(struct pt_regs *regs, int trapnr);
112extern bool ex_has_fault_handler(unsigned long ip); 120extern bool ex_has_fault_handler(unsigned long ip);
113extern int early_fixup_exception(unsigned long *ip); 121extern int early_fixup_exception(unsigned long *ip);
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1f7fdb91a818..e4393bfc7f0d 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -336,7 +336,7 @@ static int intel_num_cpu_cores(struct cpuinfo_x86 *c)
336{ 336{
337 unsigned int eax, ebx, ecx, edx; 337 unsigned int eax, ebx, ecx, edx;
338 338
339 if (c->cpuid_level < 4) 339 if (!IS_ENABLED(CONFIG_SMP) || c->cpuid_level < 4)
340 return 1; 340 return 1;
341 341
342 /* Intel has a non-standard dependency on %ecx for this CPUID level. */ 342 /* Intel has a non-standard dependency on %ecx for this CPUID level. */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index a2065d3b3b39..0e4329ed91ef 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -332,6 +332,11 @@ static void __init smp_init_package_map(void)
332 * primary cores. 332 * primary cores.
333 */ 333 */
334 ncpus = boot_cpu_data.x86_max_cores; 334 ncpus = boot_cpu_data.x86_max_cores;
335 if (!ncpus) {
336 pr_warn("x86_max_cores == zero !?!?");
337 ncpus = 1;
338 }
339
335 __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus); 340 __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
336 341
337 /* 342 /*
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 0f6294376fbd..a2f24af3c999 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -5110,13 +5110,17 @@ static void fetch_possible_mmx_operand(struct x86_emulate_ctxt *ctxt,
5110 5110
5111static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)) 5111static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))
5112{ 5112{
5113 register void *__sp asm(_ASM_SP);
5113 ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF; 5114 ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF;
5115
5114 if (!(ctxt->d & ByteOp)) 5116 if (!(ctxt->d & ByteOp))
5115 fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE; 5117 fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE;
5118
5116 asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n" 5119 asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n"
5117 : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags), 5120 : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags),
5118 [fastop]"+S"(fop) 5121 [fastop]"+S"(fop), "+r"(__sp)
5119 : "c"(ctxt->src2.val)); 5122 : "c"(ctxt->src2.val));
5123
5120 ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK); 5124 ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK);
5121 if (!fop) /* exception is returned in fop variable */ 5125 if (!fop) /* exception is returned in fop variable */
5122 return emulate_de(ctxt); 5126 return emulate_de(ctxt);
diff --git a/block/blk-map.c b/block/blk-map.c
index a54f0543b956..b9f88b7751fb 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -9,24 +9,6 @@
9 9
10#include "blk.h" 10#include "blk.h"
11 11
12static bool iovec_gap_to_prv(struct request_queue *q,
13 struct iovec *prv, struct iovec *cur)
14{
15 unsigned long prev_end;
16
17 if (!queue_virt_boundary(q))
18 return false;
19
20 if (prv->iov_base == NULL && prv->iov_len == 0)
21 /* prv is not set - don't check */
22 return false;
23
24 prev_end = (unsigned long)(prv->iov_base + prv->iov_len);
25
26 return (((unsigned long)cur->iov_base & queue_virt_boundary(q)) ||
27 prev_end & queue_virt_boundary(q));
28}
29
30int blk_rq_append_bio(struct request_queue *q, struct request *rq, 12int blk_rq_append_bio(struct request_queue *q, struct request *rq,
31 struct bio *bio) 13 struct bio *bio)
32{ 14{
@@ -125,31 +107,18 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
125 struct rq_map_data *map_data, 107 struct rq_map_data *map_data,
126 const struct iov_iter *iter, gfp_t gfp_mask) 108 const struct iov_iter *iter, gfp_t gfp_mask)
127{ 109{
128 struct iovec iov, prv = {.iov_base = NULL, .iov_len = 0}; 110 bool copy = false;
129 bool copy = (q->dma_pad_mask & iter->count) || map_data; 111 unsigned long align = q->dma_pad_mask | queue_dma_alignment(q);
130 struct bio *bio = NULL; 112 struct bio *bio = NULL;
131 struct iov_iter i; 113 struct iov_iter i;
132 int ret; 114 int ret;
133 115
134 if (!iter || !iter->count) 116 if (map_data)
135 return -EINVAL; 117 copy = true;
136 118 else if (iov_iter_alignment(iter) & align)
137 iov_for_each(iov, i, *iter) { 119 copy = true;
138 unsigned long uaddr = (unsigned long) iov.iov_base; 120 else if (queue_virt_boundary(q))
139 121 copy = queue_virt_boundary(q) & iov_iter_gap_alignment(iter);
140 if (!iov.iov_len)
141 return -EINVAL;
142
143 /*
144 * Keep going so we check length of all segments
145 */
146 if ((uaddr & queue_dma_alignment(q)) ||
147 iovec_gap_to_prv(q, &prv, &iov))
148 copy = true;
149
150 prv.iov_base = iov.iov_base;
151 prv.iov_len = iov.iov_len;
152 }
153 122
154 i = *iter; 123 i = *iter;
155 do { 124 do {
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 93a1fdc1feee..1d33beb6a1ae 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -96,6 +96,7 @@ config CRYPTO_AKCIPHER
96config CRYPTO_RSA 96config CRYPTO_RSA
97 tristate "RSA algorithm" 97 tristate "RSA algorithm"
98 select CRYPTO_AKCIPHER 98 select CRYPTO_AKCIPHER
99 select CRYPTO_MANAGER
99 select MPILIB 100 select MPILIB
100 select ASN1 101 select ASN1
101 help 102 help
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 5fc1f172963d..3887a98abcc3 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -69,8 +69,9 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
69 struct scatterlist *sg; 69 struct scatterlist *sg;
70 70
71 sg = walk->sg; 71 sg = walk->sg;
72 walk->pg = sg_page(sg);
73 walk->offset = sg->offset; 72 walk->offset = sg->offset;
73 walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
74 walk->offset = offset_in_page(walk->offset);
74 walk->entrylen = sg->length; 75 walk->entrylen = sg->length;
75 76
76 if (walk->entrylen > walk->total) 77 if (walk->entrylen > walk->total)
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index b86883aedca1..7d4acc449233 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1776,6 +1776,7 @@ static int alg_test_drbg(const struct alg_test_desc *desc, const char *driver,
1776static int do_test_rsa(struct crypto_akcipher *tfm, 1776static int do_test_rsa(struct crypto_akcipher *tfm,
1777 struct akcipher_testvec *vecs) 1777 struct akcipher_testvec *vecs)
1778{ 1778{
1779 char *xbuf[XBUFSIZE];
1779 struct akcipher_request *req; 1780 struct akcipher_request *req;
1780 void *outbuf_enc = NULL; 1781 void *outbuf_enc = NULL;
1781 void *outbuf_dec = NULL; 1782 void *outbuf_dec = NULL;
@@ -1784,9 +1785,12 @@ static int do_test_rsa(struct crypto_akcipher *tfm,
1784 int err = -ENOMEM; 1785 int err = -ENOMEM;
1785 struct scatterlist src, dst, src_tab[2]; 1786 struct scatterlist src, dst, src_tab[2];
1786 1787
1788 if (testmgr_alloc_buf(xbuf))
1789 return err;
1790
1787 req = akcipher_request_alloc(tfm, GFP_KERNEL); 1791 req = akcipher_request_alloc(tfm, GFP_KERNEL);
1788 if (!req) 1792 if (!req)
1789 return err; 1793 goto free_xbuf;
1790 1794
1791 init_completion(&result.completion); 1795 init_completion(&result.completion);
1792 1796
@@ -1804,9 +1808,14 @@ static int do_test_rsa(struct crypto_akcipher *tfm,
1804 if (!outbuf_enc) 1808 if (!outbuf_enc)
1805 goto free_req; 1809 goto free_req;
1806 1810
1811 if (WARN_ON(vecs->m_size > PAGE_SIZE))
1812 goto free_all;
1813
1814 memcpy(xbuf[0], vecs->m, vecs->m_size);
1815
1807 sg_init_table(src_tab, 2); 1816 sg_init_table(src_tab, 2);
1808 sg_set_buf(&src_tab[0], vecs->m, 8); 1817 sg_set_buf(&src_tab[0], xbuf[0], 8);
1809 sg_set_buf(&src_tab[1], vecs->m + 8, vecs->m_size - 8); 1818 sg_set_buf(&src_tab[1], xbuf[0] + 8, vecs->m_size - 8);
1810 sg_init_one(&dst, outbuf_enc, out_len_max); 1819 sg_init_one(&dst, outbuf_enc, out_len_max);
1811 akcipher_request_set_crypt(req, src_tab, &dst, vecs->m_size, 1820 akcipher_request_set_crypt(req, src_tab, &dst, vecs->m_size,
1812 out_len_max); 1821 out_len_max);
@@ -1825,7 +1834,7 @@ static int do_test_rsa(struct crypto_akcipher *tfm,
1825 goto free_all; 1834 goto free_all;
1826 } 1835 }
1827 /* verify that encrypted message is equal to expected */ 1836 /* verify that encrypted message is equal to expected */
1828 if (memcmp(vecs->c, sg_virt(req->dst), vecs->c_size)) { 1837 if (memcmp(vecs->c, outbuf_enc, vecs->c_size)) {
1829 pr_err("alg: rsa: encrypt test failed. Invalid output\n"); 1838 pr_err("alg: rsa: encrypt test failed. Invalid output\n");
1830 err = -EINVAL; 1839 err = -EINVAL;
1831 goto free_all; 1840 goto free_all;
@@ -1840,7 +1849,13 @@ static int do_test_rsa(struct crypto_akcipher *tfm,
1840 err = -ENOMEM; 1849 err = -ENOMEM;
1841 goto free_all; 1850 goto free_all;
1842 } 1851 }
1843 sg_init_one(&src, vecs->c, vecs->c_size); 1852
1853 if (WARN_ON(vecs->c_size > PAGE_SIZE))
1854 goto free_all;
1855
1856 memcpy(xbuf[0], vecs->c, vecs->c_size);
1857
1858 sg_init_one(&src, xbuf[0], vecs->c_size);
1844 sg_init_one(&dst, outbuf_dec, out_len_max); 1859 sg_init_one(&dst, outbuf_dec, out_len_max);
1845 init_completion(&result.completion); 1860 init_completion(&result.completion);
1846 akcipher_request_set_crypt(req, &src, &dst, vecs->c_size, out_len_max); 1861 akcipher_request_set_crypt(req, &src, &dst, vecs->c_size, out_len_max);
@@ -1867,6 +1882,8 @@ free_all:
1867 kfree(outbuf_enc); 1882 kfree(outbuf_enc);
1868free_req: 1883free_req:
1869 akcipher_request_free(req); 1884 akcipher_request_free(req);
1885free_xbuf:
1886 testmgr_free_buf(xbuf);
1870 return err; 1887 return err;
1871} 1888}
1872 1889
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 5c79526245c2..a0380338946a 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -13,6 +13,7 @@
13#ifndef _REGMAP_INTERNAL_H 13#ifndef _REGMAP_INTERNAL_H
14#define _REGMAP_INTERNAL_H 14#define _REGMAP_INTERNAL_H
15 15
16#include <linux/device.h>
16#include <linux/regmap.h> 17#include <linux/regmap.h>
17#include <linux/fs.h> 18#include <linux/fs.h>
18#include <linux/list.h> 19#include <linux/list.h>
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 7526906ca080..5189fd6182f6 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -23,6 +23,8 @@
23#include <linux/regmap.h> 23#include <linux/regmap.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25 25
26#include "internal.h"
27
26struct regmap_mmio_context { 28struct regmap_mmio_context {
27 void __iomem *regs; 29 void __iomem *regs;
28 unsigned val_bytes; 30 unsigned val_bytes;
@@ -212,6 +214,7 @@ static const struct regmap_bus regmap_mmio = {
212 .reg_write = regmap_mmio_write, 214 .reg_write = regmap_mmio_write,
213 .reg_read = regmap_mmio_read, 215 .reg_read = regmap_mmio_read,
214 .free_context = regmap_mmio_free_context, 216 .free_context = regmap_mmio_free_context,
217 .val_format_endian_default = REGMAP_ENDIAN_LITTLE,
215}; 218};
216 219
217static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, 220static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
@@ -245,7 +248,7 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
245 ctx->val_bytes = config->val_bits / 8; 248 ctx->val_bytes = config->val_bits / 8;
246 ctx->clk = ERR_PTR(-ENODEV); 249 ctx->clk = ERR_PTR(-ENODEV);
247 250
248 switch (config->reg_format_endian) { 251 switch (regmap_get_val_endian(dev, &regmap_mmio, config)) {
249 case REGMAP_ENDIAN_DEFAULT: 252 case REGMAP_ENDIAN_DEFAULT:
250 case REGMAP_ENDIAN_LITTLE: 253 case REGMAP_ENDIAN_LITTLE:
251#ifdef __LITTLE_ENDIAN 254#ifdef __LITTLE_ENDIAN
diff --git a/drivers/base/regmap/regmap-spmi.c b/drivers/base/regmap/regmap-spmi.c
index 7e58f6560399..4a36e415e938 100644
--- a/drivers/base/regmap/regmap-spmi.c
+++ b/drivers/base/regmap/regmap-spmi.c
@@ -142,7 +142,7 @@ static int regmap_spmi_ext_read(void *context,
142 while (val_size) { 142 while (val_size) {
143 len = min_t(size_t, val_size, 8); 143 len = min_t(size_t, val_size, 8);
144 144
145 err = spmi_ext_register_readl(context, addr, val, val_size); 145 err = spmi_ext_register_readl(context, addr, val, len);
146 if (err) 146 if (err)
147 goto err_out; 147 goto err_out;
148 148
diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
index 0e82ce3c383e..976b01e58afb 100644
--- a/drivers/crypto/qat/qat_common/adf_common_drv.h
+++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
@@ -236,6 +236,8 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
236 uint32_t vf_mask); 236 uint32_t vf_mask);
237void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); 237void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
238void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); 238void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
239int adf_init_pf_wq(void);
240void adf_exit_pf_wq(void);
239#else 241#else
240static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs) 242static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
241{ 243{
@@ -253,5 +255,14 @@ static inline void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
253static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) 255static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
254{ 256{
255} 257}
258
259static inline int adf_init_pf_wq(void)
260{
261 return 0;
262}
263
264static inline void adf_exit_pf_wq(void)
265{
266}
256#endif 267#endif
257#endif 268#endif
diff --git a/drivers/crypto/qat/qat_common/adf_ctl_drv.c b/drivers/crypto/qat/qat_common/adf_ctl_drv.c
index 5c897e6e7994..3c3f948290ca 100644
--- a/drivers/crypto/qat/qat_common/adf_ctl_drv.c
+++ b/drivers/crypto/qat/qat_common/adf_ctl_drv.c
@@ -462,12 +462,17 @@ static int __init adf_register_ctl_device_driver(void)
462 if (adf_init_aer()) 462 if (adf_init_aer())
463 goto err_aer; 463 goto err_aer;
464 464
465 if (adf_init_pf_wq())
466 goto err_pf_wq;
467
465 if (qat_crypto_register()) 468 if (qat_crypto_register())
466 goto err_crypto_register; 469 goto err_crypto_register;
467 470
468 return 0; 471 return 0;
469 472
470err_crypto_register: 473err_crypto_register:
474 adf_exit_pf_wq();
475err_pf_wq:
471 adf_exit_aer(); 476 adf_exit_aer();
472err_aer: 477err_aer:
473 adf_chr_drv_destroy(); 478 adf_chr_drv_destroy();
@@ -480,6 +485,7 @@ static void __exit adf_unregister_ctl_device_driver(void)
480{ 485{
481 adf_chr_drv_destroy(); 486 adf_chr_drv_destroy();
482 adf_exit_aer(); 487 adf_exit_aer();
488 adf_exit_pf_wq();
483 qat_crypto_unregister(); 489 qat_crypto_unregister();
484 adf_clean_vf_map(false); 490 adf_clean_vf_map(false);
485 mutex_destroy(&adf_ctl_lock); 491 mutex_destroy(&adf_ctl_lock);
diff --git a/drivers/crypto/qat/qat_common/adf_sriov.c b/drivers/crypto/qat/qat_common/adf_sriov.c
index 1117a8b58280..38a0415e767d 100644
--- a/drivers/crypto/qat/qat_common/adf_sriov.c
+++ b/drivers/crypto/qat/qat_common/adf_sriov.c
@@ -119,11 +119,6 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev)
119 int i; 119 int i;
120 u32 reg; 120 u32 reg;
121 121
122 /* Workqueue for PF2VF responses */
123 pf2vf_resp_wq = create_workqueue("qat_pf2vf_resp_wq");
124 if (!pf2vf_resp_wq)
125 return -ENOMEM;
126
127 for (i = 0, vf_info = accel_dev->pf.vf_info; i < totalvfs; 122 for (i = 0, vf_info = accel_dev->pf.vf_info; i < totalvfs;
128 i++, vf_info++) { 123 i++, vf_info++) {
129 /* This ptr will be populated when VFs will be created */ 124 /* This ptr will be populated when VFs will be created */
@@ -216,11 +211,6 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)
216 211
217 kfree(accel_dev->pf.vf_info); 212 kfree(accel_dev->pf.vf_info);
218 accel_dev->pf.vf_info = NULL; 213 accel_dev->pf.vf_info = NULL;
219
220 if (pf2vf_resp_wq) {
221 destroy_workqueue(pf2vf_resp_wq);
222 pf2vf_resp_wq = NULL;
223 }
224} 214}
225EXPORT_SYMBOL_GPL(adf_disable_sriov); 215EXPORT_SYMBOL_GPL(adf_disable_sriov);
226 216
@@ -304,3 +294,19 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
304 return numvfs; 294 return numvfs;
305} 295}
306EXPORT_SYMBOL_GPL(adf_sriov_configure); 296EXPORT_SYMBOL_GPL(adf_sriov_configure);
297
298int __init adf_init_pf_wq(void)
299{
300 /* Workqueue for PF2VF responses */
301 pf2vf_resp_wq = create_workqueue("qat_pf2vf_resp_wq");
302
303 return !pf2vf_resp_wq ? -ENOMEM : 0;
304}
305
306void adf_exit_pf_wq(void)
307{
308 if (pf2vf_resp_wq) {
309 destroy_workqueue(pf2vf_resp_wq);
310 pf2vf_resp_wq = NULL;
311 }
312}
diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_dp.c b/drivers/gpu/drm/amd/amdgpu/atombios_dp.c
index bf731e9f643e..7f85c2c1d681 100644
--- a/drivers/gpu/drm/amd/amdgpu/atombios_dp.c
+++ b/drivers/gpu/drm/amd/amdgpu/atombios_dp.c
@@ -276,8 +276,8 @@ static int amdgpu_atombios_dp_get_dp_link_config(struct drm_connector *connector
276 } 276 }
277 } 277 }
278 } else { 278 } else {
279 for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) { 279 for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) {
280 for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) { 280 for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
281 max_pix_clock = (lane_num * link_rates[i] * 8) / bpp; 281 max_pix_clock = (lane_num * link_rates[i] * 8) / bpp;
282 if (max_pix_clock >= pix_clock) { 282 if (max_pix_clock >= pix_clock) {
283 *dp_lanes = lane_num; 283 *dp_lanes = lane_num;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index a0f1bd711b53..e3f4c725a1c6 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2872,20 +2872,6 @@ static void intel_dp_info(struct seq_file *m,
2872 intel_panel_info(m, &intel_connector->panel); 2872 intel_panel_info(m, &intel_connector->panel);
2873} 2873}
2874 2874
2875static void intel_dp_mst_info(struct seq_file *m,
2876 struct intel_connector *intel_connector)
2877{
2878 struct intel_encoder *intel_encoder = intel_connector->encoder;
2879 struct intel_dp_mst_encoder *intel_mst =
2880 enc_to_mst(&intel_encoder->base);
2881 struct intel_digital_port *intel_dig_port = intel_mst->primary;
2882 struct intel_dp *intel_dp = &intel_dig_port->dp;
2883 bool has_audio = drm_dp_mst_port_has_audio(&intel_dp->mst_mgr,
2884 intel_connector->port);
2885
2886 seq_printf(m, "\taudio support: %s\n", yesno(has_audio));
2887}
2888
2889static void intel_hdmi_info(struct seq_file *m, 2875static void intel_hdmi_info(struct seq_file *m,
2890 struct intel_connector *intel_connector) 2876 struct intel_connector *intel_connector)
2891{ 2877{
@@ -2929,8 +2915,6 @@ static void intel_connector_info(struct seq_file *m,
2929 intel_hdmi_info(m, intel_connector); 2915 intel_hdmi_info(m, intel_connector);
2930 else if (intel_encoder->type == INTEL_OUTPUT_LVDS) 2916 else if (intel_encoder->type == INTEL_OUTPUT_LVDS)
2931 intel_lvds_info(m, intel_connector); 2917 intel_lvds_info(m, intel_connector);
2932 else if (intel_encoder->type == INTEL_OUTPUT_DP_MST)
2933 intel_dp_mst_info(m, intel_connector);
2934 } 2918 }
2935 2919
2936 seq_printf(m, "\tmodes:\n"); 2920 seq_printf(m, "\tmodes:\n");
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index fffdac801d3b..363bd79dea2e 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -7444,6 +7444,8 @@ enum skl_disp_power_wells {
7444#define TRANS_CLK_SEL_DISABLED (0x0<<29) 7444#define TRANS_CLK_SEL_DISABLED (0x0<<29)
7445#define TRANS_CLK_SEL_PORT(x) (((x)+1)<<29) 7445#define TRANS_CLK_SEL_PORT(x) (((x)+1)<<29)
7446 7446
7447#define CDCLK_FREQ _MMIO(0x46200)
7448
7447#define _TRANSA_MSA_MISC 0x60410 7449#define _TRANSA_MSA_MISC 0x60410
7448#define _TRANSB_MSA_MISC 0x61410 7450#define _TRANSB_MSA_MISC 0x61410
7449#define _TRANSC_MSA_MISC 0x62410 7451#define _TRANSC_MSA_MISC 0x62410
diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
index 30f921421b0c..7d281b40064a 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -262,8 +262,7 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder)
262 tmp |= AUD_CONFIG_N_PROG_ENABLE; 262 tmp |= AUD_CONFIG_N_PROG_ENABLE;
263 tmp &= ~AUD_CONFIG_UPPER_N_MASK; 263 tmp &= ~AUD_CONFIG_UPPER_N_MASK;
264 tmp &= ~AUD_CONFIG_LOWER_N_MASK; 264 tmp &= ~AUD_CONFIG_LOWER_N_MASK;
265 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT) || 265 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
266 intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DP_MST))
267 tmp |= AUD_CONFIG_N_VALUE_INDEX; 266 tmp |= AUD_CONFIG_N_VALUE_INDEX;
268 I915_WRITE(HSW_AUD_CFG(pipe), tmp); 267 I915_WRITE(HSW_AUD_CFG(pipe), tmp);
269 268
@@ -476,8 +475,7 @@ static void ilk_audio_codec_enable(struct drm_connector *connector,
476 tmp &= ~AUD_CONFIG_N_VALUE_INDEX; 475 tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
477 tmp &= ~AUD_CONFIG_N_PROG_ENABLE; 476 tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
478 tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK; 477 tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
479 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT) || 478 if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
480 intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DP_MST))
481 tmp |= AUD_CONFIG_N_VALUE_INDEX; 479 tmp |= AUD_CONFIG_N_VALUE_INDEX;
482 else 480 else
483 tmp |= audio_config_hdmi_pixel_clock(adjusted_mode); 481 tmp |= audio_config_hdmi_pixel_clock(adjusted_mode);
@@ -515,8 +513,7 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder)
515 513
516 /* ELD Conn_Type */ 514 /* ELD Conn_Type */
517 connector->eld[5] &= ~(3 << 2); 515 connector->eld[5] &= ~(3 << 2);
518 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT) || 516 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT))
519 intel_pipe_has_type(crtc, INTEL_OUTPUT_DP_MST))
520 connector->eld[5] |= (1 << 2); 517 connector->eld[5] |= (1 << 2);
521 518
522 connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2; 519 connector->eld[6] = drm_av_sync_delay(connector, adjusted_mode) / 2;
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 505fc5cf26f8..0364292367b1 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -257,8 +257,14 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
257 pipe_config->has_pch_encoder = true; 257 pipe_config->has_pch_encoder = true;
258 258
259 /* LPT FDI RX only supports 8bpc. */ 259 /* LPT FDI RX only supports 8bpc. */
260 if (HAS_PCH_LPT(dev)) 260 if (HAS_PCH_LPT(dev)) {
261 if (pipe_config->bw_constrained && pipe_config->pipe_bpp < 24) {
262 DRM_DEBUG_KMS("LPT only supports 24bpp\n");
263 return false;
264 }
265
261 pipe_config->pipe_bpp = 24; 266 pipe_config->pipe_bpp = 24;
267 }
262 268
263 /* FDI must always be 2.7 GHz */ 269 /* FDI must always be 2.7 GHz */
264 if (HAS_DDI(dev)) { 270 if (HAS_DDI(dev)) {
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 3b57bf06abe8..96ffcc541e17 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -3106,23 +3106,6 @@ void intel_ddi_fdi_disable(struct drm_crtc *crtc)
3106 I915_WRITE(FDI_RX_CTL(PIPE_A), val); 3106 I915_WRITE(FDI_RX_CTL(PIPE_A), val);
3107} 3107}
3108 3108
3109bool intel_ddi_is_audio_enabled(struct drm_i915_private *dev_priv,
3110 struct intel_crtc *intel_crtc)
3111{
3112 u32 temp;
3113
3114 if (intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_AUDIO)) {
3115 temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
3116
3117 intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
3118
3119 if (temp & AUDIO_OUTPUT_ENABLE(intel_crtc->pipe))
3120 return true;
3121 }
3122
3123 return false;
3124}
3125
3126void intel_ddi_get_config(struct intel_encoder *encoder, 3109void intel_ddi_get_config(struct intel_encoder *encoder,
3127 struct intel_crtc_state *pipe_config) 3110 struct intel_crtc_state *pipe_config)
3128{ 3111{
@@ -3183,8 +3166,11 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
3183 break; 3166 break;
3184 } 3167 }
3185 3168
3186 pipe_config->has_audio = 3169 if (intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_AUDIO)) {
3187 intel_ddi_is_audio_enabled(dev_priv, intel_crtc); 3170 temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
3171 if (temp & AUDIO_OUTPUT_ENABLE(intel_crtc->pipe))
3172 pipe_config->has_audio = true;
3173 }
3188 3174
3189 if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp_bpp && 3175 if (encoder->type == INTEL_OUTPUT_EDP && dev_priv->vbt.edp_bpp &&
3190 pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) { 3176 pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) {
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 182f84937345..0104a06d01fd 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7988,9 +7988,6 @@ static void i9xx_get_pfit_config(struct intel_crtc *crtc,
7988 7988
7989 pipe_config->gmch_pfit.control = tmp; 7989 pipe_config->gmch_pfit.control = tmp;
7990 pipe_config->gmch_pfit.pgm_ratios = I915_READ(PFIT_PGM_RATIOS); 7990 pipe_config->gmch_pfit.pgm_ratios = I915_READ(PFIT_PGM_RATIOS);
7991 if (INTEL_INFO(dev)->gen < 5)
7992 pipe_config->gmch_pfit.lvds_border_bits =
7993 I915_READ(LVDS) & LVDS_BORDER_ENABLE;
7994} 7991}
7995 7992
7996static void vlv_crtc_clock_get(struct intel_crtc *crtc, 7993static void vlv_crtc_clock_get(struct intel_crtc *crtc,
@@ -9752,6 +9749,8 @@ static void broadwell_set_cdclk(struct drm_device *dev, int cdclk)
9752 sandybridge_pcode_write(dev_priv, HSW_PCODE_DE_WRITE_FREQ_REQ, data); 9749 sandybridge_pcode_write(dev_priv, HSW_PCODE_DE_WRITE_FREQ_REQ, data);
9753 mutex_unlock(&dev_priv->rps.hw_lock); 9750 mutex_unlock(&dev_priv->rps.hw_lock);
9754 9751
9752 I915_WRITE(CDCLK_FREQ, DIV_ROUND_CLOSEST(cdclk, 1000) - 1);
9753
9755 intel_update_cdclk(dev); 9754 intel_update_cdclk(dev);
9756 9755
9757 WARN(cdclk != dev_priv->cdclk_freq, 9756 WARN(cdclk != dev_priv->cdclk_freq,
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index 937e77228466..2c999725b3d4 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -78,8 +78,6 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
78 return false; 78 return false;
79 } 79 }
80 80
81 if (drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, found->port))
82 pipe_config->has_audio = true;
83 mst_pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock, bpp); 81 mst_pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock, bpp);
84 82
85 pipe_config->pbn = mst_pbn; 83 pipe_config->pbn = mst_pbn;
@@ -104,11 +102,6 @@ static void intel_mst_disable_dp(struct intel_encoder *encoder)
104 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base); 102 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
105 struct intel_digital_port *intel_dig_port = intel_mst->primary; 103 struct intel_digital_port *intel_dig_port = intel_mst->primary;
106 struct intel_dp *intel_dp = &intel_dig_port->dp; 104 struct intel_dp *intel_dp = &intel_dig_port->dp;
107 struct drm_device *dev = encoder->base.dev;
108 struct drm_i915_private *dev_priv = dev->dev_private;
109 struct drm_crtc *crtc = encoder->base.crtc;
110 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
111
112 int ret; 105 int ret;
113 106
114 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links); 107 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
@@ -119,10 +112,6 @@ static void intel_mst_disable_dp(struct intel_encoder *encoder)
119 if (ret) { 112 if (ret) {
120 DRM_ERROR("failed to update payload %d\n", ret); 113 DRM_ERROR("failed to update payload %d\n", ret);
121 } 114 }
122 if (intel_crtc->config->has_audio) {
123 intel_audio_codec_disable(encoder);
124 intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
125 }
126} 115}
127 116
128static void intel_mst_post_disable_dp(struct intel_encoder *encoder) 117static void intel_mst_post_disable_dp(struct intel_encoder *encoder)
@@ -221,7 +210,6 @@ static void intel_mst_enable_dp(struct intel_encoder *encoder)
221 struct intel_dp *intel_dp = &intel_dig_port->dp; 210 struct intel_dp *intel_dp = &intel_dig_port->dp;
222 struct drm_device *dev = intel_dig_port->base.base.dev; 211 struct drm_device *dev = intel_dig_port->base.base.dev;
223 struct drm_i915_private *dev_priv = dev->dev_private; 212 struct drm_i915_private *dev_priv = dev->dev_private;
224 struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
225 enum port port = intel_dig_port->port; 213 enum port port = intel_dig_port->port;
226 int ret; 214 int ret;
227 215
@@ -234,13 +222,6 @@ static void intel_mst_enable_dp(struct intel_encoder *encoder)
234 ret = drm_dp_check_act_status(&intel_dp->mst_mgr); 222 ret = drm_dp_check_act_status(&intel_dp->mst_mgr);
235 223
236 ret = drm_dp_update_payload_part2(&intel_dp->mst_mgr); 224 ret = drm_dp_update_payload_part2(&intel_dp->mst_mgr);
237
238 if (crtc->config->has_audio) {
239 DRM_DEBUG_DRIVER("Enabling DP audio on pipe %c\n",
240 pipe_name(crtc->pipe));
241 intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO);
242 intel_audio_codec_enable(encoder);
243 }
244} 225}
245 226
246static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder, 227static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
@@ -266,9 +247,6 @@ static void intel_dp_mst_enc_get_config(struct intel_encoder *encoder,
266 247
267 pipe_config->has_dp_encoder = true; 248 pipe_config->has_dp_encoder = true;
268 249
269 pipe_config->has_audio =
270 intel_ddi_is_audio_enabled(dev_priv, crtc);
271
272 temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder)); 250 temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
273 if (temp & TRANS_DDI_PHSYNC) 251 if (temp & TRANS_DDI_PHSYNC)
274 flags |= DRM_MODE_FLAG_PHSYNC; 252 flags |= DRM_MODE_FLAG_PHSYNC;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 7d3af3a72abe..9d0770c23fde 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1019,8 +1019,6 @@ void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
1019void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp); 1019void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
1020bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector); 1020bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
1021void intel_ddi_fdi_disable(struct drm_crtc *crtc); 1021void intel_ddi_fdi_disable(struct drm_crtc *crtc);
1022bool intel_ddi_is_audio_enabled(struct drm_i915_private *dev_priv,
1023 struct intel_crtc *intel_crtc);
1024void intel_ddi_get_config(struct intel_encoder *encoder, 1022void intel_ddi_get_config(struct intel_encoder *encoder,
1025 struct intel_crtc_state *pipe_config); 1023 struct intel_crtc_state *pipe_config);
1026struct intel_encoder * 1024struct intel_encoder *
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index cd9fe609aefb..10dc3517b63b 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -123,6 +123,10 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
123 123
124 pipe_config->base.adjusted_mode.flags |= flags; 124 pipe_config->base.adjusted_mode.flags |= flags;
125 125
126 if (INTEL_INFO(dev)->gen < 5)
127 pipe_config->gmch_pfit.lvds_border_bits =
128 tmp & LVDS_BORDER_ENABLE;
129
126 /* gen2/3 store dither state in pfit control, needs to match */ 130 /* gen2/3 store dither state in pfit control, needs to match */
127 if (INTEL_INFO(dev)->gen < 4) { 131 if (INTEL_INFO(dev)->gen < 4) {
128 tmp = I915_READ(PFIT_CONTROL); 132 tmp = I915_READ(PFIT_CONTROL);
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 8ed3cf34f82d..3425d8e737b3 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -6646,6 +6646,12 @@ static void broadwell_init_clock_gating(struct drm_device *dev)
6646 misccpctl = I915_READ(GEN7_MISCCPCTL); 6646 misccpctl = I915_READ(GEN7_MISCCPCTL);
6647 I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE); 6647 I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE);
6648 I915_WRITE(GEN8_L3SQCREG1, BDW_WA_L3SQCREG1_DEFAULT); 6648 I915_WRITE(GEN8_L3SQCREG1, BDW_WA_L3SQCREG1_DEFAULT);
6649 /*
6650 * Wait at least 100 clocks before re-enabling clock gating. See
6651 * the definition of L3SQCREG1 in BSpec.
6652 */
6653 POSTING_READ(GEN8_L3SQCREG1);
6654 udelay(1);
6649 I915_WRITE(GEN7_MISCCPCTL, misccpctl); 6655 I915_WRITE(GEN7_MISCCPCTL, misccpctl);
6650 6656
6651 /* 6657 /*
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index b80b08f71cb4..532127c55de6 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1742,6 +1742,7 @@ static u32 radeon_get_pll_use_mask(struct drm_crtc *crtc)
1742static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc) 1742static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
1743{ 1743{
1744 struct drm_device *dev = crtc->dev; 1744 struct drm_device *dev = crtc->dev;
1745 struct radeon_device *rdev = dev->dev_private;
1745 struct drm_crtc *test_crtc; 1746 struct drm_crtc *test_crtc;
1746 struct radeon_crtc *test_radeon_crtc; 1747 struct radeon_crtc *test_radeon_crtc;
1747 1748
@@ -1751,6 +1752,10 @@ static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
1751 test_radeon_crtc = to_radeon_crtc(test_crtc); 1752 test_radeon_crtc = to_radeon_crtc(test_crtc);
1752 if (test_radeon_crtc->encoder && 1753 if (test_radeon_crtc->encoder &&
1753 ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_radeon_crtc->encoder))) { 1754 ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_radeon_crtc->encoder))) {
1755 /* PPLL2 is exclusive to UNIPHYA on DCE61 */
1756 if (ASIC_IS_DCE61(rdev) && !ASIC_IS_DCE8(rdev) &&
1757 test_radeon_crtc->pll_id == ATOM_PPLL2)
1758 continue;
1754 /* for DP use the same PLL for all */ 1759 /* for DP use the same PLL for all */
1755 if (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID) 1760 if (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID)
1756 return test_radeon_crtc->pll_id; 1761 return test_radeon_crtc->pll_id;
@@ -1772,6 +1777,7 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc)
1772{ 1777{
1773 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1778 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
1774 struct drm_device *dev = crtc->dev; 1779 struct drm_device *dev = crtc->dev;
1780 struct radeon_device *rdev = dev->dev_private;
1775 struct drm_crtc *test_crtc; 1781 struct drm_crtc *test_crtc;
1776 struct radeon_crtc *test_radeon_crtc; 1782 struct radeon_crtc *test_radeon_crtc;
1777 u32 adjusted_clock, test_adjusted_clock; 1783 u32 adjusted_clock, test_adjusted_clock;
@@ -1787,6 +1793,10 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc)
1787 test_radeon_crtc = to_radeon_crtc(test_crtc); 1793 test_radeon_crtc = to_radeon_crtc(test_crtc);
1788 if (test_radeon_crtc->encoder && 1794 if (test_radeon_crtc->encoder &&
1789 !ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_radeon_crtc->encoder))) { 1795 !ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_radeon_crtc->encoder))) {
1796 /* PPLL2 is exclusive to UNIPHYA on DCE61 */
1797 if (ASIC_IS_DCE61(rdev) && !ASIC_IS_DCE8(rdev) &&
1798 test_radeon_crtc->pll_id == ATOM_PPLL2)
1799 continue;
1790 /* check if we are already driving this connector with another crtc */ 1800 /* check if we are already driving this connector with another crtc */
1791 if (test_radeon_crtc->connector == radeon_crtc->connector) { 1801 if (test_radeon_crtc->connector == radeon_crtc->connector) {
1792 /* if we are, return that pll */ 1802 /* if we are, return that pll */
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index afa9db1dc0e3..cead089a9e7d 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -326,8 +326,8 @@ int radeon_dp_get_dp_link_config(struct drm_connector *connector,
326 } 326 }
327 } 327 }
328 } else { 328 } else {
329 for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) { 329 for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) {
330 for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) { 330 for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
331 max_pix_clock = (lane_num * link_rates[i] * 8) / bpp; 331 max_pix_clock = (lane_num * link_rates[i] * 8) / bpp;
332 if (max_pix_clock >= pix_clock) { 332 if (max_pix_clock >= pix_clock) {
333 *dp_lanes = lane_num; 333 *dp_lanes = lane_num;
diff --git a/drivers/gpu/drm/radeon/radeon_dp_auxch.c b/drivers/gpu/drm/radeon/radeon_dp_auxch.c
index 3b0c229d7dcd..db64e0062689 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_auxch.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_auxch.c
@@ -105,7 +105,7 @@ radeon_dp_aux_transfer_native(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg
105 105
106 tmp &= AUX_HPD_SEL(0x7); 106 tmp &= AUX_HPD_SEL(0x7);
107 tmp |= AUX_HPD_SEL(chan->rec.hpd); 107 tmp |= AUX_HPD_SEL(chan->rec.hpd);
108 tmp |= AUX_EN | AUX_LS_READ_EN; 108 tmp |= AUX_EN | AUX_LS_READ_EN | AUX_HPD_DISCON(0x1);
109 109
110 WREG32(AUX_CONTROL + aux_offset[instance], tmp); 110 WREG32(AUX_CONTROL + aux_offset[instance], tmp);
111 111
diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c
index a806ba3818f7..8d6326d7e7be 100644
--- a/drivers/input/misc/max8997_haptic.c
+++ b/drivers/input/misc/max8997_haptic.c
@@ -255,12 +255,14 @@ static int max8997_haptic_probe(struct platform_device *pdev)
255 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 255 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
256 const struct max8997_platform_data *pdata = 256 const struct max8997_platform_data *pdata =
257 dev_get_platdata(iodev->dev); 257 dev_get_platdata(iodev->dev);
258 const struct max8997_haptic_platform_data *haptic_pdata = 258 const struct max8997_haptic_platform_data *haptic_pdata = NULL;
259 pdata->haptic_pdata;
260 struct max8997_haptic *chip; 259 struct max8997_haptic *chip;
261 struct input_dev *input_dev; 260 struct input_dev *input_dev;
262 int error; 261 int error;
263 262
263 if (pdata)
264 haptic_pdata = pdata->haptic_pdata;
265
264 if (!haptic_pdata) { 266 if (!haptic_pdata) {
265 dev_err(&pdev->dev, "no haptic platform data\n"); 267 dev_err(&pdev->dev, "no haptic platform data\n");
266 return -EINVAL; 268 return -EINVAL;
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index df3581f60628..42de34b92996 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -257,6 +257,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
257 int vddvibr_uV = 0; 257 int vddvibr_uV = 0;
258 int error; 258 int error;
259 259
260 of_node_get(twl6040_core_dev->of_node);
260 twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node, 261 twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node,
261 "vibra"); 262 "vibra");
262 if (!twl6040_core_node) { 263 if (!twl6040_core_node) {
diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
index fdc243ca93ed..e583f8b50454 100644
--- a/drivers/input/mouse/byd.c
+++ b/drivers/input/mouse/byd.c
@@ -2,6 +2,10 @@
2 * BYD TouchPad PS/2 mouse driver 2 * BYD TouchPad PS/2 mouse driver
3 * 3 *
4 * Copyright (C) 2015 Chris Diamand <chris@diamand.org> 4 * Copyright (C) 2015 Chris Diamand <chris@diamand.org>
5 * Copyright (C) 2015 Richard Pospesel
6 * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood
7 * Copyright (C) 2015 Martin Wimpress
8 * Copyright (C) 2015 Jay Kuri
5 * 9 *
6 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by 11 * under the terms of the GNU General Public License version 2 as published by
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 7f366f1b0377..0b1b8c7b6ce5 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -74,11 +74,6 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer
74 return 0; 74 return 0;
75} 75}
76 76
77static int __verify_planes_array_core(struct vb2_buffer *vb, const void *pb)
78{
79 return __verify_planes_array(vb, pb);
80}
81
82/** 77/**
83 * __verify_length() - Verify that the bytesused value for each plane fits in 78 * __verify_length() - Verify that the bytesused value for each plane fits in
84 * the plane length and that the data offset doesn't exceed the bytesused value. 79 * the plane length and that the data offset doesn't exceed the bytesused value.
@@ -442,7 +437,6 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
442} 437}
443 438
444static const struct vb2_buf_ops v4l2_buf_ops = { 439static const struct vb2_buf_ops v4l2_buf_ops = {
445 .verify_planes_array = __verify_planes_array_core,
446 .fill_user_buffer = __fill_v4l2_buffer, 440 .fill_user_buffer = __fill_v4l2_buffer,
447 .fill_vb2_buffer = __fill_vb2_buffer, 441 .fill_vb2_buffer = __fill_vb2_buffer,
448 .copy_timestamp = __copy_timestamp, 442 .copy_timestamp = __copy_timestamp,
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
index b212488606da..11be8044e0d7 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.c
@@ -43,6 +43,7 @@ static void xgene_cle_idt_to_hw(u32 dstqid, u32 fpsel,
43static void xgene_cle_dbptr_to_hw(struct xgene_enet_pdata *pdata, 43static void xgene_cle_dbptr_to_hw(struct xgene_enet_pdata *pdata,
44 struct xgene_cle_dbptr *dbptr, u32 *buf) 44 struct xgene_cle_dbptr *dbptr, u32 *buf)
45{ 45{
46 buf[0] = SET_VAL(CLE_DROP, dbptr->drop);
46 buf[4] = SET_VAL(CLE_FPSEL, dbptr->fpsel) | 47 buf[4] = SET_VAL(CLE_FPSEL, dbptr->fpsel) |
47 SET_VAL(CLE_DSTQIDL, dbptr->dstqid); 48 SET_VAL(CLE_DSTQIDL, dbptr->dstqid);
48 49
@@ -412,7 +413,7 @@ static int xgene_enet_cle_init(struct xgene_enet_pdata *pdata)
412 .branch = { 413 .branch = {
413 { 414 {
414 /* IPV4 */ 415 /* IPV4 */
415 .valid = 0, 416 .valid = 1,
416 .next_packet_pointer = 22, 417 .next_packet_pointer = 22,
417 .jump_bw = JMP_FW, 418 .jump_bw = JMP_FW,
418 .jump_rel = JMP_ABS, 419 .jump_rel = JMP_ABS,
@@ -420,7 +421,7 @@ static int xgene_enet_cle_init(struct xgene_enet_pdata *pdata)
420 .next_node = PKT_PROT_NODE, 421 .next_node = PKT_PROT_NODE,
421 .next_branch = 0, 422 .next_branch = 0,
422 .data = 0x8, 423 .data = 0x8,
423 .mask = 0xffff 424 .mask = 0x0
424 }, 425 },
425 { 426 {
426 .valid = 0, 427 .valid = 0,
@@ -456,7 +457,7 @@ static int xgene_enet_cle_init(struct xgene_enet_pdata *pdata)
456 .next_node = RSS_IPV4_TCP_NODE, 457 .next_node = RSS_IPV4_TCP_NODE,
457 .next_branch = 0, 458 .next_branch = 0,
458 .data = 0x0600, 459 .data = 0x0600,
459 .mask = 0xffff 460 .mask = 0x00ff
460 }, 461 },
461 { 462 {
462 /* UDP */ 463 /* UDP */
@@ -468,7 +469,7 @@ static int xgene_enet_cle_init(struct xgene_enet_pdata *pdata)
468 .next_node = RSS_IPV4_UDP_NODE, 469 .next_node = RSS_IPV4_UDP_NODE,
469 .next_branch = 0, 470 .next_branch = 0,
470 .data = 0x1100, 471 .data = 0x1100,
471 .mask = 0xffff 472 .mask = 0x00ff
472 }, 473 },
473 { 474 {
474 .valid = 0, 475 .valid = 0,
@@ -642,7 +643,7 @@ static int xgene_enet_cle_init(struct xgene_enet_pdata *pdata)
642 { 643 {
643 /* TCP DST Port */ 644 /* TCP DST Port */
644 .valid = 0, 645 .valid = 0,
645 .next_packet_pointer = 256, 646 .next_packet_pointer = 258,
646 .jump_bw = JMP_FW, 647 .jump_bw = JMP_FW,
647 .jump_rel = JMP_ABS, 648 .jump_rel = JMP_ABS,
648 .operation = EQT, 649 .operation = EQT,
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.h b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.h
index 29a17abdd828..3bf90683240e 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_cle.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_cle.h
@@ -83,6 +83,8 @@
83#define CLE_TYPE_POS 0 83#define CLE_TYPE_POS 0
84#define CLE_TYPE_LEN 2 84#define CLE_TYPE_LEN 2
85 85
86#define CLE_DROP_POS 28
87#define CLE_DROP_LEN 1
86#define CLE_DSTQIDL_POS 25 88#define CLE_DSTQIDL_POS 25
87#define CLE_DSTQIDL_LEN 7 89#define CLE_DSTQIDL_LEN 7
88#define CLE_DSTQIDH_POS 0 90#define CLE_DSTQIDH_POS 0
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 39e081a70f5b..513d2a62ee6d 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -219,27 +219,30 @@ void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
219 struct xgene_enet_pdata *pdata, 219 struct xgene_enet_pdata *pdata,
220 enum xgene_enet_err_code status) 220 enum xgene_enet_err_code status)
221{ 221{
222 struct rtnl_link_stats64 *stats = &pdata->stats;
223
224 switch (status) { 222 switch (status) {
225 case INGRESS_CRC: 223 case INGRESS_CRC:
226 stats->rx_crc_errors++; 224 ring->rx_crc_errors++;
225 ring->rx_dropped++;
227 break; 226 break;
228 case INGRESS_CHECKSUM: 227 case INGRESS_CHECKSUM:
229 case INGRESS_CHECKSUM_COMPUTE: 228 case INGRESS_CHECKSUM_COMPUTE:
230 stats->rx_errors++; 229 ring->rx_errors++;
230 ring->rx_dropped++;
231 break; 231 break;
232 case INGRESS_TRUNC_FRAME: 232 case INGRESS_TRUNC_FRAME:
233 stats->rx_frame_errors++; 233 ring->rx_frame_errors++;
234 ring->rx_dropped++;
234 break; 235 break;
235 case INGRESS_PKT_LEN: 236 case INGRESS_PKT_LEN:
236 stats->rx_length_errors++; 237 ring->rx_length_errors++;
238 ring->rx_dropped++;
237 break; 239 break;
238 case INGRESS_PKT_UNDER: 240 case INGRESS_PKT_UNDER:
239 stats->rx_frame_errors++; 241 ring->rx_frame_errors++;
242 ring->rx_dropped++;
240 break; 243 break;
241 case INGRESS_FIFO_OVERRUN: 244 case INGRESS_FIFO_OVERRUN:
242 stats->rx_fifo_errors++; 245 ring->rx_fifo_errors++;
243 break; 246 break;
244 default: 247 default:
245 break; 248 break;
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
index ba7da98af2ef..45220be3122f 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
@@ -86,7 +86,7 @@ enum xgene_enet_rm {
86#define RINGADDRL_POS 5 86#define RINGADDRL_POS 5
87#define RINGADDRL_LEN 27 87#define RINGADDRL_LEN 27
88#define RINGADDRH_POS 0 88#define RINGADDRH_POS 0
89#define RINGADDRH_LEN 6 89#define RINGADDRH_LEN 7
90#define RINGSIZE_POS 23 90#define RINGSIZE_POS 23
91#define RINGSIZE_LEN 3 91#define RINGSIZE_LEN 3
92#define RINGTYPE_POS 19 92#define RINGTYPE_POS 19
@@ -94,9 +94,9 @@ enum xgene_enet_rm {
94#define RINGMODE_POS 20 94#define RINGMODE_POS 20
95#define RINGMODE_LEN 3 95#define RINGMODE_LEN 3
96#define RECOMTIMEOUTL_POS 28 96#define RECOMTIMEOUTL_POS 28
97#define RECOMTIMEOUTL_LEN 3 97#define RECOMTIMEOUTL_LEN 4
98#define RECOMTIMEOUTH_POS 0 98#define RECOMTIMEOUTH_POS 0
99#define RECOMTIMEOUTH_LEN 2 99#define RECOMTIMEOUTH_LEN 3
100#define NUMMSGSINQ_POS 1 100#define NUMMSGSINQ_POS 1
101#define NUMMSGSINQ_LEN 16 101#define NUMMSGSINQ_LEN 16
102#define ACCEPTLERR BIT(19) 102#define ACCEPTLERR BIT(19)
@@ -201,6 +201,8 @@ enum xgene_enet_rm {
201#define USERINFO_LEN 32 201#define USERINFO_LEN 32
202#define FPQNUM_POS 32 202#define FPQNUM_POS 32
203#define FPQNUM_LEN 12 203#define FPQNUM_LEN 12
204#define ELERR_POS 46
205#define ELERR_LEN 2
204#define NV_POS 50 206#define NV_POS 50
205#define NV_LEN 1 207#define NV_LEN 1
206#define LL_POS 51 208#define LL_POS 51
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 8d4c1ad2fc60..fd200883d228 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -443,8 +443,8 @@ static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb,
443 443
444 skb_tx_timestamp(skb); 444 skb_tx_timestamp(skb);
445 445
446 pdata->stats.tx_packets++; 446 tx_ring->tx_packets++;
447 pdata->stats.tx_bytes += skb->len; 447 tx_ring->tx_bytes += skb->len;
448 448
449 pdata->ring_ops->wr_cmd(tx_ring, count); 449 pdata->ring_ops->wr_cmd(tx_ring, count);
450 return NETDEV_TX_OK; 450 return NETDEV_TX_OK;
@@ -483,12 +483,12 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
483 skb = buf_pool->rx_skb[skb_index]; 483 skb = buf_pool->rx_skb[skb_index];
484 484
485 /* checking for error */ 485 /* checking for error */
486 status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0)); 486 status = (GET_VAL(ELERR, le64_to_cpu(raw_desc->m0)) << LERR_LEN) ||
487 GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
487 if (unlikely(status > 2)) { 488 if (unlikely(status > 2)) {
488 dev_kfree_skb_any(skb); 489 dev_kfree_skb_any(skb);
489 xgene_enet_parse_error(rx_ring, netdev_priv(rx_ring->ndev), 490 xgene_enet_parse_error(rx_ring, netdev_priv(rx_ring->ndev),
490 status); 491 status);
491 pdata->stats.rx_dropped++;
492 ret = -EIO; 492 ret = -EIO;
493 goto out; 493 goto out;
494 } 494 }
@@ -506,8 +506,8 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
506 xgene_enet_skip_csum(skb); 506 xgene_enet_skip_csum(skb);
507 } 507 }
508 508
509 pdata->stats.rx_packets++; 509 rx_ring->rx_packets++;
510 pdata->stats.rx_bytes += datalen; 510 rx_ring->rx_bytes += datalen;
511 napi_gro_receive(&rx_ring->napi, skb); 511 napi_gro_receive(&rx_ring->napi, skb);
512out: 512out:
513 if (--rx_ring->nbufpool == 0) { 513 if (--rx_ring->nbufpool == 0) {
@@ -630,7 +630,7 @@ static int xgene_enet_register_irq(struct net_device *ndev)
630 ring = pdata->rx_ring[i]; 630 ring = pdata->rx_ring[i];
631 irq_set_status_flags(ring->irq, IRQ_DISABLE_UNLAZY); 631 irq_set_status_flags(ring->irq, IRQ_DISABLE_UNLAZY);
632 ret = devm_request_irq(dev, ring->irq, xgene_enet_rx_irq, 632 ret = devm_request_irq(dev, ring->irq, xgene_enet_rx_irq,
633 IRQF_SHARED, ring->irq_name, ring); 633 0, ring->irq_name, ring);
634 if (ret) { 634 if (ret) {
635 netdev_err(ndev, "Failed to request irq %s\n", 635 netdev_err(ndev, "Failed to request irq %s\n",
636 ring->irq_name); 636 ring->irq_name);
@@ -641,7 +641,7 @@ static int xgene_enet_register_irq(struct net_device *ndev)
641 ring = pdata->tx_ring[i]->cp_ring; 641 ring = pdata->tx_ring[i]->cp_ring;
642 irq_set_status_flags(ring->irq, IRQ_DISABLE_UNLAZY); 642 irq_set_status_flags(ring->irq, IRQ_DISABLE_UNLAZY);
643 ret = devm_request_irq(dev, ring->irq, xgene_enet_rx_irq, 643 ret = devm_request_irq(dev, ring->irq, xgene_enet_rx_irq,
644 IRQF_SHARED, ring->irq_name, ring); 644 0, ring->irq_name, ring);
645 if (ret) { 645 if (ret) {
646 netdev_err(ndev, "Failed to request irq %s\n", 646 netdev_err(ndev, "Failed to request irq %s\n",
647 ring->irq_name); 647 ring->irq_name);
@@ -1114,12 +1114,31 @@ static struct rtnl_link_stats64 *xgene_enet_get_stats64(
1114{ 1114{
1115 struct xgene_enet_pdata *pdata = netdev_priv(ndev); 1115 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
1116 struct rtnl_link_stats64 *stats = &pdata->stats; 1116 struct rtnl_link_stats64 *stats = &pdata->stats;
1117 struct xgene_enet_desc_ring *ring;
1118 int i;
1117 1119
1118 stats->rx_errors += stats->rx_length_errors + 1120 memset(stats, 0, sizeof(struct rtnl_link_stats64));
1119 stats->rx_crc_errors + 1121 for (i = 0; i < pdata->txq_cnt; i++) {
1120 stats->rx_frame_errors + 1122 ring = pdata->tx_ring[i];
1121 stats->rx_fifo_errors; 1123 if (ring) {
1122 memcpy(storage, &pdata->stats, sizeof(struct rtnl_link_stats64)); 1124 stats->tx_packets += ring->tx_packets;
1125 stats->tx_bytes += ring->tx_bytes;
1126 }
1127 }
1128
1129 for (i = 0; i < pdata->rxq_cnt; i++) {
1130 ring = pdata->rx_ring[i];
1131 if (ring) {
1132 stats->rx_packets += ring->rx_packets;
1133 stats->rx_bytes += ring->rx_bytes;
1134 stats->rx_errors += ring->rx_length_errors +
1135 ring->rx_crc_errors +
1136 ring->rx_frame_errors +
1137 ring->rx_fifo_errors;
1138 stats->rx_dropped += ring->rx_dropped;
1139 }
1140 }
1141 memcpy(storage, stats, sizeof(struct rtnl_link_stats64));
1123 1142
1124 return storage; 1143 return storage;
1125} 1144}
@@ -1234,6 +1253,13 @@ static int xgene_enet_get_irqs(struct xgene_enet_pdata *pdata)
1234 for (i = 0; i < max_irqs; i++) { 1253 for (i = 0; i < max_irqs; i++) {
1235 ret = platform_get_irq(pdev, i); 1254 ret = platform_get_irq(pdev, i);
1236 if (ret <= 0) { 1255 if (ret <= 0) {
1256 if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) {
1257 max_irqs = i;
1258 pdata->rxq_cnt = max_irqs / 2;
1259 pdata->txq_cnt = max_irqs / 2;
1260 pdata->cq_cnt = max_irqs / 2;
1261 break;
1262 }
1237 dev_err(dev, "Unable to get ENET IRQ\n"); 1263 dev_err(dev, "Unable to get ENET IRQ\n");
1238 ret = ret ? : -ENXIO; 1264 ret = ret ? : -ENXIO;
1239 return ret; 1265 return ret;
@@ -1437,19 +1463,28 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata)
1437 pdata->port_ops = &xgene_xgport_ops; 1463 pdata->port_ops = &xgene_xgport_ops;
1438 pdata->cle_ops = &xgene_cle3in_ops; 1464 pdata->cle_ops = &xgene_cle3in_ops;
1439 pdata->rm = RM0; 1465 pdata->rm = RM0;
1440 pdata->rxq_cnt = XGENE_NUM_RX_RING; 1466 if (!pdata->rxq_cnt) {
1441 pdata->txq_cnt = XGENE_NUM_TX_RING; 1467 pdata->rxq_cnt = XGENE_NUM_RX_RING;
1442 pdata->cq_cnt = XGENE_NUM_TXC_RING; 1468 pdata->txq_cnt = XGENE_NUM_TX_RING;
1469 pdata->cq_cnt = XGENE_NUM_TXC_RING;
1470 }
1443 break; 1471 break;
1444 } 1472 }
1445 1473
1446 if (pdata->enet_id == XGENE_ENET1) { 1474 if (pdata->enet_id == XGENE_ENET1) {
1447 switch (pdata->port_id) { 1475 switch (pdata->port_id) {
1448 case 0: 1476 case 0:
1449 pdata->cpu_bufnum = START_CPU_BUFNUM_0; 1477 if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) {
1450 pdata->eth_bufnum = START_ETH_BUFNUM_0; 1478 pdata->cpu_bufnum = X2_START_CPU_BUFNUM_0;
1451 pdata->bp_bufnum = START_BP_BUFNUM_0; 1479 pdata->eth_bufnum = X2_START_ETH_BUFNUM_0;
1452 pdata->ring_num = START_RING_NUM_0; 1480 pdata->bp_bufnum = X2_START_BP_BUFNUM_0;
1481 pdata->ring_num = START_RING_NUM_0;
1482 } else {
1483 pdata->cpu_bufnum = START_CPU_BUFNUM_0;
1484 pdata->eth_bufnum = START_ETH_BUFNUM_0;
1485 pdata->bp_bufnum = START_BP_BUFNUM_0;
1486 pdata->ring_num = START_RING_NUM_0;
1487 }
1453 break; 1488 break;
1454 case 1: 1489 case 1:
1455 if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) { 1490 if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) {
@@ -1595,21 +1630,22 @@ static int xgene_enet_probe(struct platform_device *pdev)
1595 1630
1596 ret = xgene_enet_init_hw(pdata); 1631 ret = xgene_enet_init_hw(pdata);
1597 if (ret) 1632 if (ret)
1598 goto err; 1633 goto err_netdev;
1599 1634
1600 mac_ops = pdata->mac_ops; 1635 mac_ops = pdata->mac_ops;
1601 if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { 1636 if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) {
1602 ret = xgene_enet_mdio_config(pdata); 1637 ret = xgene_enet_mdio_config(pdata);
1603 if (ret) 1638 if (ret)
1604 goto err; 1639 goto err_netdev;
1605 } else { 1640 } else {
1606 INIT_DELAYED_WORK(&pdata->link_work, mac_ops->link_state); 1641 INIT_DELAYED_WORK(&pdata->link_work, mac_ops->link_state);
1607 } 1642 }
1608 1643
1609 xgene_enet_napi_add(pdata); 1644 xgene_enet_napi_add(pdata);
1610 return 0; 1645 return 0;
1611err: 1646err_netdev:
1612 unregister_netdev(ndev); 1647 unregister_netdev(ndev);
1648err:
1613 free_netdev(ndev); 1649 free_netdev(ndev);
1614 return ret; 1650 return ret;
1615} 1651}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
index 175d18890c7a..9d9cf445148c 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
@@ -49,10 +49,10 @@
49#define XGENE_ENET_MSS 1448 49#define XGENE_ENET_MSS 1448
50#define XGENE_MIN_ENET_FRAME_SIZE 60 50#define XGENE_MIN_ENET_FRAME_SIZE 60
51 51
52#define XGENE_MAX_ENET_IRQ 8 52#define XGENE_MAX_ENET_IRQ 16
53#define XGENE_NUM_RX_RING 4 53#define XGENE_NUM_RX_RING 8
54#define XGENE_NUM_TX_RING 4 54#define XGENE_NUM_TX_RING 8
55#define XGENE_NUM_TXC_RING 4 55#define XGENE_NUM_TXC_RING 8
56 56
57#define START_CPU_BUFNUM_0 0 57#define START_CPU_BUFNUM_0 0
58#define START_ETH_BUFNUM_0 2 58#define START_ETH_BUFNUM_0 2
@@ -121,6 +121,16 @@ struct xgene_enet_desc_ring {
121 struct xgene_enet_raw_desc16 *raw_desc16; 121 struct xgene_enet_raw_desc16 *raw_desc16;
122 }; 122 };
123 __le64 *exp_bufs; 123 __le64 *exp_bufs;
124 u64 tx_packets;
125 u64 tx_bytes;
126 u64 rx_packets;
127 u64 rx_bytes;
128 u64 rx_dropped;
129 u64 rx_errors;
130 u64 rx_length_errors;
131 u64 rx_crc_errors;
132 u64 rx_frame_errors;
133 u64 rx_fifo_errors;
124}; 134};
125 135
126struct xgene_mac_ops { 136struct xgene_mac_ops {
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.h b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.h
index 29a71b4dcc44..002df5a6756e 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.h
@@ -33,7 +33,7 @@
33#define LINK_STATUS BIT(2) 33#define LINK_STATUS BIT(2)
34#define LINK_UP BIT(15) 34#define LINK_UP BIT(15)
35#define MPA_IDLE_WITH_QMI_EMPTY BIT(12) 35#define MPA_IDLE_WITH_QMI_EMPTY BIT(12)
36#define SG_RX_DV_GATE_REG_0_ADDR 0x0dfc 36#define SG_RX_DV_GATE_REG_0_ADDR 0x05fc
37 37
38extern const struct xgene_mac_ops xgene_sgmac_ops; 38extern const struct xgene_mac_ops xgene_sgmac_ops;
39extern const struct xgene_port_ops xgene_sgport_ops; 39extern const struct xgene_port_ops xgene_sgport_ops;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 72eb29ed0359..c39a7f5c6a01 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -813,6 +813,46 @@ static inline struct sk_buff *bnxt_copy_skb(struct bnxt_napi *bnapi, u8 *data,
813 return skb; 813 return skb;
814} 814}
815 815
816static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_napi *bnapi,
817 u32 *raw_cons, void *cmp)
818{
819 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
820 struct rx_cmp *rxcmp = cmp;
821 u32 tmp_raw_cons = *raw_cons;
822 u8 cmp_type, agg_bufs = 0;
823
824 cmp_type = RX_CMP_TYPE(rxcmp);
825
826 if (cmp_type == CMP_TYPE_RX_L2_CMP) {
827 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) &
828 RX_CMP_AGG_BUFS) >>
829 RX_CMP_AGG_BUFS_SHIFT;
830 } else if (cmp_type == CMP_TYPE_RX_L2_TPA_END_CMP) {
831 struct rx_tpa_end_cmp *tpa_end = cmp;
832
833 agg_bufs = (le32_to_cpu(tpa_end->rx_tpa_end_cmp_misc_v1) &
834 RX_TPA_END_CMP_AGG_BUFS) >>
835 RX_TPA_END_CMP_AGG_BUFS_SHIFT;
836 }
837
838 if (agg_bufs) {
839 if (!bnxt_agg_bufs_valid(bp, cpr, agg_bufs, &tmp_raw_cons))
840 return -EBUSY;
841 }
842 *raw_cons = tmp_raw_cons;
843 return 0;
844}
845
846static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
847{
848 if (!rxr->bnapi->in_reset) {
849 rxr->bnapi->in_reset = true;
850 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
851 schedule_work(&bp->sp_task);
852 }
853 rxr->rx_next_cons = 0xffff;
854}
855
816static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, 856static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
817 struct rx_tpa_start_cmp *tpa_start, 857 struct rx_tpa_start_cmp *tpa_start,
818 struct rx_tpa_start_cmp_ext *tpa_start1) 858 struct rx_tpa_start_cmp_ext *tpa_start1)
@@ -830,6 +870,11 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
830 prod_rx_buf = &rxr->rx_buf_ring[prod]; 870 prod_rx_buf = &rxr->rx_buf_ring[prod];
831 tpa_info = &rxr->rx_tpa[agg_id]; 871 tpa_info = &rxr->rx_tpa[agg_id];
832 872
873 if (unlikely(cons != rxr->rx_next_cons)) {
874 bnxt_sched_reset(bp, rxr);
875 return;
876 }
877
833 prod_rx_buf->data = tpa_info->data; 878 prod_rx_buf->data = tpa_info->data;
834 879
835 mapping = tpa_info->mapping; 880 mapping = tpa_info->mapping;
@@ -867,6 +912,7 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
867 912
868 rxr->rx_prod = NEXT_RX(prod); 913 rxr->rx_prod = NEXT_RX(prod);
869 cons = NEXT_RX(cons); 914 cons = NEXT_RX(cons);
915 rxr->rx_next_cons = NEXT_RX(cons);
870 cons_rx_buf = &rxr->rx_buf_ring[cons]; 916 cons_rx_buf = &rxr->rx_buf_ring[cons];
871 917
872 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data); 918 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data);
@@ -980,6 +1026,14 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
980 dma_addr_t mapping; 1026 dma_addr_t mapping;
981 struct sk_buff *skb; 1027 struct sk_buff *skb;
982 1028
1029 if (unlikely(bnapi->in_reset)) {
1030 int rc = bnxt_discard_rx(bp, bnapi, raw_cons, tpa_end);
1031
1032 if (rc < 0)
1033 return ERR_PTR(-EBUSY);
1034 return NULL;
1035 }
1036
983 tpa_info = &rxr->rx_tpa[agg_id]; 1037 tpa_info = &rxr->rx_tpa[agg_id];
984 data = tpa_info->data; 1038 data = tpa_info->data;
985 prefetch(data); 1039 prefetch(data);
@@ -1146,6 +1200,12 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi *bnapi, u32 *raw_cons,
1146 cons = rxcmp->rx_cmp_opaque; 1200 cons = rxcmp->rx_cmp_opaque;
1147 rx_buf = &rxr->rx_buf_ring[cons]; 1201 rx_buf = &rxr->rx_buf_ring[cons];
1148 data = rx_buf->data; 1202 data = rx_buf->data;
1203 if (unlikely(cons != rxr->rx_next_cons)) {
1204 int rc1 = bnxt_discard_rx(bp, bnapi, raw_cons, rxcmp);
1205
1206 bnxt_sched_reset(bp, rxr);
1207 return rc1;
1208 }
1149 prefetch(data); 1209 prefetch(data);
1150 1210
1151 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & RX_CMP_AGG_BUFS) >> 1211 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & RX_CMP_AGG_BUFS) >>
@@ -1245,6 +1305,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi *bnapi, u32 *raw_cons,
1245 1305
1246next_rx: 1306next_rx:
1247 rxr->rx_prod = NEXT_RX(prod); 1307 rxr->rx_prod = NEXT_RX(prod);
1308 rxr->rx_next_cons = NEXT_RX(cons);
1248 1309
1249next_rx_no_prod: 1310next_rx_no_prod:
1250 *raw_cons = tmp_raw_cons; 1311 *raw_cons = tmp_raw_cons;
@@ -1388,6 +1449,10 @@ static int bnxt_poll_work(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
1388 if (!TX_CMP_VALID(txcmp, raw_cons)) 1449 if (!TX_CMP_VALID(txcmp, raw_cons))
1389 break; 1450 break;
1390 1451
1452 /* The valid test of the entry must be done first before
1453 * reading any further.
1454 */
1455 rmb();
1391 if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) { 1456 if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) {
1392 tx_pkts++; 1457 tx_pkts++;
1393 /* return full budget so NAPI will complete. */ 1458 /* return full budget so NAPI will complete. */
@@ -2482,6 +2547,7 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
2482 rxr->rx_prod = 0; 2547 rxr->rx_prod = 0;
2483 rxr->rx_agg_prod = 0; 2548 rxr->rx_agg_prod = 0;
2484 rxr->rx_sw_agg_prod = 0; 2549 rxr->rx_sw_agg_prod = 0;
2550 rxr->rx_next_cons = 0;
2485 } 2551 }
2486 } 2552 }
2487} 2553}
@@ -4038,9 +4104,11 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp)
4038} 4104}
4039 4105
4040static int bnxt_cfg_rx_mode(struct bnxt *); 4106static int bnxt_cfg_rx_mode(struct bnxt *);
4107static bool bnxt_mc_list_updated(struct bnxt *, u32 *);
4041 4108
4042static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) 4109static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
4043{ 4110{
4111 struct bnxt_vnic_info *vnic = &bp->vnic_info[0];
4044 int rc = 0; 4112 int rc = 0;
4045 4113
4046 if (irq_re_init) { 4114 if (irq_re_init) {
@@ -4096,13 +4164,22 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
4096 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); 4164 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc);
4097 goto err_out; 4165 goto err_out;
4098 } 4166 }
4099 bp->vnic_info[0].uc_filter_count = 1; 4167 vnic->uc_filter_count = 1;
4100 4168
4101 bp->vnic_info[0].rx_mask = CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; 4169 vnic->rx_mask = CFA_L2_SET_RX_MASK_REQ_MASK_BCAST;
4102 4170
4103 if ((bp->dev->flags & IFF_PROMISC) && BNXT_PF(bp)) 4171 if ((bp->dev->flags & IFF_PROMISC) && BNXT_PF(bp))
4104 bp->vnic_info[0].rx_mask |= 4172 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS;
4105 CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; 4173
4174 if (bp->dev->flags & IFF_ALLMULTI) {
4175 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST;
4176 vnic->mc_list_count = 0;
4177 } else {
4178 u32 mask = 0;
4179
4180 bnxt_mc_list_updated(bp, &mask);
4181 vnic->rx_mask |= mask;
4182 }
4106 4183
4107 rc = bnxt_cfg_rx_mode(bp); 4184 rc = bnxt_cfg_rx_mode(bp);
4108 if (rc) 4185 if (rc)
@@ -4447,6 +4524,7 @@ static void bnxt_enable_napi(struct bnxt *bp)
4447 int i; 4524 int i;
4448 4525
4449 for (i = 0; i < bp->cp_nr_rings; i++) { 4526 for (i = 0; i < bp->cp_nr_rings; i++) {
4527 bp->bnapi[i]->in_reset = false;
4450 bnxt_enable_poll(bp->bnapi[i]); 4528 bnxt_enable_poll(bp->bnapi[i]);
4451 napi_enable(&bp->bnapi[i]->napi); 4529 napi_enable(&bp->bnapi[i]->napi);
4452 } 4530 }
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 8b823ff558ff..de9d53eee3dd 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -584,6 +584,7 @@ struct bnxt_rx_ring_info {
584 u16 rx_prod; 584 u16 rx_prod;
585 u16 rx_agg_prod; 585 u16 rx_agg_prod;
586 u16 rx_sw_agg_prod; 586 u16 rx_sw_agg_prod;
587 u16 rx_next_cons;
587 void __iomem *rx_doorbell; 588 void __iomem *rx_doorbell;
588 void __iomem *rx_agg_doorbell; 589 void __iomem *rx_agg_doorbell;
589 590
@@ -636,6 +637,7 @@ struct bnxt_napi {
636#ifdef CONFIG_NET_RX_BUSY_POLL 637#ifdef CONFIG_NET_RX_BUSY_POLL
637 atomic_t poll_state; 638 atomic_t poll_state;
638#endif 639#endif
640 bool in_reset;
639}; 641};
640 642
641#ifdef CONFIG_NET_RX_BUSY_POLL 643#ifdef CONFIG_NET_RX_BUSY_POLL
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
index fa05e347262f..06b819db51b1 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
@@ -533,6 +533,7 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs,
533 nicvf_config_vlan_stripping(nic, nic->netdev->features); 533 nicvf_config_vlan_stripping(nic, nic->netdev->features);
534 534
535 /* Enable Receive queue */ 535 /* Enable Receive queue */
536 memset(&rq_cfg, 0, sizeof(struct rq_cfg));
536 rq_cfg.ena = 1; 537 rq_cfg.ena = 1;
537 rq_cfg.tcp_ena = 0; 538 rq_cfg.tcp_ena = 0;
538 nicvf_queue_reg_write(nic, NIC_QSET_RQ_0_7_CFG, qidx, *(u64 *)&rq_cfg); 539 nicvf_queue_reg_write(nic, NIC_QSET_RQ_0_7_CFG, qidx, *(u64 *)&rq_cfg);
@@ -565,6 +566,7 @@ void nicvf_cmp_queue_config(struct nicvf *nic, struct queue_set *qs,
565 qidx, (u64)(cq->dmem.phys_base)); 566 qidx, (u64)(cq->dmem.phys_base));
566 567
567 /* Enable Completion queue */ 568 /* Enable Completion queue */
569 memset(&cq_cfg, 0, sizeof(struct cq_cfg));
568 cq_cfg.ena = 1; 570 cq_cfg.ena = 1;
569 cq_cfg.reset = 0; 571 cq_cfg.reset = 0;
570 cq_cfg.caching = 0; 572 cq_cfg.caching = 0;
@@ -613,6 +615,7 @@ static void nicvf_snd_queue_config(struct nicvf *nic, struct queue_set *qs,
613 qidx, (u64)(sq->dmem.phys_base)); 615 qidx, (u64)(sq->dmem.phys_base));
614 616
615 /* Enable send queue & set queue size */ 617 /* Enable send queue & set queue size */
618 memset(&sq_cfg, 0, sizeof(struct sq_cfg));
616 sq_cfg.ena = 1; 619 sq_cfg.ena = 1;
617 sq_cfg.reset = 0; 620 sq_cfg.reset = 0;
618 sq_cfg.ldwb = 0; 621 sq_cfg.ldwb = 0;
@@ -649,6 +652,7 @@ static void nicvf_rbdr_config(struct nicvf *nic, struct queue_set *qs,
649 652
650 /* Enable RBDR & set queue size */ 653 /* Enable RBDR & set queue size */
651 /* Buffer size should be in multiples of 128 bytes */ 654 /* Buffer size should be in multiples of 128 bytes */
655 memset(&rbdr_cfg, 0, sizeof(struct rbdr_cfg));
652 rbdr_cfg.ena = 1; 656 rbdr_cfg.ena = 1;
653 rbdr_cfg.reset = 0; 657 rbdr_cfg.reset = 0;
654 rbdr_cfg.ldwb = 0; 658 rbdr_cfg.ldwb = 0;
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index 1f23845a0694..085f9125cf42 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -145,7 +145,7 @@ static void nps_enet_tx_handler(struct net_device *ndev)
145 u32 tx_ctrl_nt = (tx_ctrl_value & TX_CTL_NT_MASK) >> TX_CTL_NT_SHIFT; 145 u32 tx_ctrl_nt = (tx_ctrl_value & TX_CTL_NT_MASK) >> TX_CTL_NT_SHIFT;
146 146
147 /* Check if we got TX */ 147 /* Check if we got TX */
148 if (!priv->tx_packet_sent || tx_ctrl_ct) 148 if (!priv->tx_skb || tx_ctrl_ct)
149 return; 149 return;
150 150
151 /* Ack Tx ctrl register */ 151 /* Ack Tx ctrl register */
@@ -160,7 +160,7 @@ static void nps_enet_tx_handler(struct net_device *ndev)
160 } 160 }
161 161
162 dev_kfree_skb(priv->tx_skb); 162 dev_kfree_skb(priv->tx_skb);
163 priv->tx_packet_sent = false; 163 priv->tx_skb = NULL;
164 164
165 if (netif_queue_stopped(ndev)) 165 if (netif_queue_stopped(ndev))
166 netif_wake_queue(ndev); 166 netif_wake_queue(ndev);
@@ -183,6 +183,9 @@ static int nps_enet_poll(struct napi_struct *napi, int budget)
183 work_done = nps_enet_rx_handler(ndev); 183 work_done = nps_enet_rx_handler(ndev);
184 if (work_done < budget) { 184 if (work_done < budget) {
185 u32 buf_int_enable_value = 0; 185 u32 buf_int_enable_value = 0;
186 u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL);
187 u32 tx_ctrl_ct =
188 (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT;
186 189
187 napi_complete(napi); 190 napi_complete(napi);
188 191
@@ -192,6 +195,18 @@ static int nps_enet_poll(struct napi_struct *napi, int budget)
192 195
193 nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 196 nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE,
194 buf_int_enable_value); 197 buf_int_enable_value);
198
199 /* in case we will get a tx interrupt while interrupts
200 * are masked, we will lose it since the tx is edge interrupt.
201 * specifically, while executing the code section above,
202 * between nps_enet_tx_handler and the interrupts enable, all
203 * tx requests will be stuck until we will get an rx interrupt.
204 * the two code lines below will solve this situation by
205 * re-adding ourselves to the poll list.
206 */
207
208 if (priv->tx_skb && !tx_ctrl_ct)
209 napi_reschedule(napi);
195 } 210 }
196 211
197 return work_done; 212 return work_done;
@@ -217,7 +232,7 @@ static irqreturn_t nps_enet_irq_handler(s32 irq, void *dev_instance)
217 u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT; 232 u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT;
218 u32 rx_ctrl_cr = (rx_ctrl_value & RX_CTL_CR_MASK) >> RX_CTL_CR_SHIFT; 233 u32 rx_ctrl_cr = (rx_ctrl_value & RX_CTL_CR_MASK) >> RX_CTL_CR_SHIFT;
219 234
220 if ((!tx_ctrl_ct && priv->tx_packet_sent) || rx_ctrl_cr) 235 if ((!tx_ctrl_ct && priv->tx_skb) || rx_ctrl_cr)
221 if (likely(napi_schedule_prep(&priv->napi))) { 236 if (likely(napi_schedule_prep(&priv->napi))) {
222 nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0); 237 nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0);
223 __napi_schedule(&priv->napi); 238 __napi_schedule(&priv->napi);
@@ -387,8 +402,6 @@ static void nps_enet_send_frame(struct net_device *ndev,
387 /* Write the length of the Frame */ 402 /* Write the length of the Frame */
388 tx_ctrl_value |= length << TX_CTL_NT_SHIFT; 403 tx_ctrl_value |= length << TX_CTL_NT_SHIFT;
389 404
390 /* Indicate SW is done */
391 priv->tx_packet_sent = true;
392 tx_ctrl_value |= NPS_ENET_ENABLE << TX_CTL_CT_SHIFT; 405 tx_ctrl_value |= NPS_ENET_ENABLE << TX_CTL_CT_SHIFT;
393 /* Send Frame */ 406 /* Send Frame */
394 nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, tx_ctrl_value); 407 nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, tx_ctrl_value);
@@ -465,7 +478,7 @@ static s32 nps_enet_open(struct net_device *ndev)
465 s32 err; 478 s32 err;
466 479
467 /* Reset private variables */ 480 /* Reset private variables */
468 priv->tx_packet_sent = false; 481 priv->tx_skb = NULL;
469 priv->ge_mac_cfg_2_value = 0; 482 priv->ge_mac_cfg_2_value = 0;
470 priv->ge_mac_cfg_3_value = 0; 483 priv->ge_mac_cfg_3_value = 0;
471 484
@@ -534,6 +547,11 @@ static netdev_tx_t nps_enet_start_xmit(struct sk_buff *skb,
534 547
535 priv->tx_skb = skb; 548 priv->tx_skb = skb;
536 549
550 /* make sure tx_skb is actually written to the memory
551 * before the HW is informed and the IRQ is fired.
552 */
553 wmb();
554
537 nps_enet_send_frame(ndev, skb); 555 nps_enet_send_frame(ndev, skb);
538 556
539 return NETDEV_TX_OK; 557 return NETDEV_TX_OK;
diff --git a/drivers/net/ethernet/ezchip/nps_enet.h b/drivers/net/ethernet/ezchip/nps_enet.h
index d0cab600bce8..3939ca20cc9f 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.h
+++ b/drivers/net/ethernet/ezchip/nps_enet.h
@@ -165,14 +165,12 @@
165 * struct nps_enet_priv - Storage of ENET's private information. 165 * struct nps_enet_priv - Storage of ENET's private information.
166 * @regs_base: Base address of ENET memory-mapped control registers. 166 * @regs_base: Base address of ENET memory-mapped control registers.
167 * @irq: For RX/TX IRQ number. 167 * @irq: For RX/TX IRQ number.
168 * @tx_packet_sent: SW indication if frame is being sent.
169 * @tx_skb: socket buffer of sent frame. 168 * @tx_skb: socket buffer of sent frame.
170 * @napi: Structure for NAPI. 169 * @napi: Structure for NAPI.
171 */ 170 */
172struct nps_enet_priv { 171struct nps_enet_priv {
173 void __iomem *regs_base; 172 void __iomem *regs_base;
174 s32 irq; 173 s32 irq;
175 bool tx_packet_sent;
176 struct sk_buff *tx_skb; 174 struct sk_buff *tx_skb;
177 struct napi_struct napi; 175 struct napi_struct napi;
178 u32 ge_mac_cfg_2_value; 176 u32 ge_mac_cfg_2_value;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 08243c2ff4b4..2a03857cca18 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1521,9 +1521,15 @@ fec_enet_rx(struct net_device *ndev, int budget)
1521 struct fec_enet_private *fep = netdev_priv(ndev); 1521 struct fec_enet_private *fep = netdev_priv(ndev);
1522 1522
1523 for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS) { 1523 for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS) {
1524 clear_bit(queue_id, &fep->work_rx); 1524 int ret;
1525 pkt_received += fec_enet_rx_queue(ndev, 1525
1526 ret = fec_enet_rx_queue(ndev,
1526 budget - pkt_received, queue_id); 1527 budget - pkt_received, queue_id);
1528
1529 if (ret < budget - pkt_received)
1530 clear_bit(queue_id, &fep->work_rx);
1531
1532 pkt_received += ret;
1527 } 1533 }
1528 return pkt_received; 1534 return pkt_received;
1529} 1535}
diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig
index b5c6d42daa12..2664827ddecd 100644
--- a/drivers/net/ethernet/marvell/Kconfig
+++ b/drivers/net/ethernet/marvell/Kconfig
@@ -68,7 +68,7 @@ config MVNETA
68 68
69config MVNETA_BM 69config MVNETA_BM
70 tristate 70 tristate
71 default y if MVNETA=y && MVNETA_BM_ENABLE 71 default y if MVNETA=y && MVNETA_BM_ENABLE!=n
72 default MVNETA_BM_ENABLE 72 default MVNETA_BM_ENABLE
73 select HWBM 73 select HWBM
74 help 74 help
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index b723e3bcab39..ca3a38421ee7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -707,7 +707,7 @@ static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
707 707
708 if (ipv6h->nexthdr == IPPROTO_FRAGMENT || ipv6h->nexthdr == IPPROTO_HOPOPTS) 708 if (ipv6h->nexthdr == IPPROTO_FRAGMENT || ipv6h->nexthdr == IPPROTO_HOPOPTS)
709 return -1; 709 return -1;
710 hw_checksum = csum_add(hw_checksum, (__force __wsum)(ipv6h->nexthdr << 8)); 710 hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(ipv6h->nexthdr));
711 711
712 csum_pseudo_hdr = csum_partial(&ipv6h->saddr, 712 csum_pseudo_hdr = csum_partial(&ipv6h->saddr,
713 sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0); 713 sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index 559d11a443bc..f5c3b9465d8d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -14,7 +14,6 @@ config MLX5_CORE_EN
14 bool "Mellanox Technologies ConnectX-4 Ethernet support" 14 bool "Mellanox Technologies ConnectX-4 Ethernet support"
15 depends on NETDEVICES && ETHERNET && PCI && MLX5_CORE 15 depends on NETDEVICES && ETHERNET && PCI && MLX5_CORE
16 select PTP_1588_CLOCK 16 select PTP_1588_CLOCK
17 select VXLAN if MLX5_CORE=y
18 default n 17 default n
19 ---help--- 18 ---help---
20 Ethernet support in Mellanox Technologies ConnectX-4 NIC. 19 Ethernet support in Mellanox Technologies ConnectX-4 NIC.
@@ -32,3 +31,10 @@ config MLX5_CORE_EN_DCB
32 This flag is depended on the kernel's DCB support. 31 This flag is depended on the kernel's DCB support.
33 32
34 If unsure, set to Y 33 If unsure, set to Y
34
35config MLX5_CORE_EN_VXLAN
36 bool "VXLAN offloads Support"
37 default y
38 depends on MLX5_CORE_EN && VXLAN && !(MLX5_CORE=y && VXLAN=m)
39 ---help---
40 Say Y here if you want to use VXLAN offloads in the driver.
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index 4fc45ee0c5d1..bf65b71c7360 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -6,6 +6,7 @@ mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
6 6
7mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o \ 7mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o \
8 en_main.o en_fs.o en_ethtool.o en_tx.o en_rx.o \ 8 en_main.o en_fs.o en_ethtool.o en_tx.o en_rx.o \
9 en_txrx.o en_clock.o vxlan.o en_tc.o 9 en_txrx.o en_clock.o en_tc.o
10 10
11mlx5_core-$(CONFIG_MLX5_CORE_EN_VXLAN) += vxlan.o
11mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o 12mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 3881dce0cc30..24344aafbd36 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -564,7 +564,9 @@ struct mlx5e_priv {
564 struct mlx5e_flow_tables fts; 564 struct mlx5e_flow_tables fts;
565 struct mlx5e_eth_addr_db eth_addr; 565 struct mlx5e_eth_addr_db eth_addr;
566 struct mlx5e_vlan_db vlan; 566 struct mlx5e_vlan_db vlan;
567#ifdef CONFIG_MLX5_CORE_EN_VXLAN
567 struct mlx5e_vxlan_db vxlan; 568 struct mlx5e_vxlan_db vxlan;
569#endif
568 570
569 struct mlx5e_params params; 571 struct mlx5e_params params;
570 struct workqueue_struct *wq; 572 struct workqueue_struct *wq;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index d4dfc5ce516a..94fef705890b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2149,6 +2149,7 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
2149 vf_stats); 2149 vf_stats);
2150} 2150}
2151 2151
2152#if IS_ENABLED(CONFIG_MLX5_CORE_EN_VXLAN)
2152static void mlx5e_add_vxlan_port(struct net_device *netdev, 2153static void mlx5e_add_vxlan_port(struct net_device *netdev,
2153 sa_family_t sa_family, __be16 port) 2154 sa_family_t sa_family, __be16 port)
2154{ 2155{
@@ -2220,6 +2221,7 @@ static netdev_features_t mlx5e_features_check(struct sk_buff *skb,
2220 2221
2221 return features; 2222 return features;
2222} 2223}
2224#endif
2223 2225
2224static const struct net_device_ops mlx5e_netdev_ops_basic = { 2226static const struct net_device_ops mlx5e_netdev_ops_basic = {
2225 .ndo_open = mlx5e_open, 2227 .ndo_open = mlx5e_open,
@@ -2251,9 +2253,11 @@ static const struct net_device_ops mlx5e_netdev_ops_sriov = {
2251 .ndo_set_features = mlx5e_set_features, 2253 .ndo_set_features = mlx5e_set_features,
2252 .ndo_change_mtu = mlx5e_change_mtu, 2254 .ndo_change_mtu = mlx5e_change_mtu,
2253 .ndo_do_ioctl = mlx5e_ioctl, 2255 .ndo_do_ioctl = mlx5e_ioctl,
2256#ifdef CONFIG_MLX5_CORE_EN_VXLAN
2254 .ndo_add_vxlan_port = mlx5e_add_vxlan_port, 2257 .ndo_add_vxlan_port = mlx5e_add_vxlan_port,
2255 .ndo_del_vxlan_port = mlx5e_del_vxlan_port, 2258 .ndo_del_vxlan_port = mlx5e_del_vxlan_port,
2256 .ndo_features_check = mlx5e_features_check, 2259 .ndo_features_check = mlx5e_features_check,
2260#endif
2257 .ndo_set_vf_mac = mlx5e_set_vf_mac, 2261 .ndo_set_vf_mac = mlx5e_set_vf_mac,
2258 .ndo_set_vf_vlan = mlx5e_set_vf_vlan, 2262 .ndo_set_vf_vlan = mlx5e_set_vf_vlan,
2259 .ndo_get_vf_config = mlx5e_get_vf_config, 2263 .ndo_get_vf_config = mlx5e_get_vf_config,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
index 129f3527aa14..217ac530a514 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
@@ -48,14 +48,21 @@ struct mlx5e_vxlan_work {
48 48
49static inline bool mlx5e_vxlan_allowed(struct mlx5_core_dev *mdev) 49static inline bool mlx5e_vxlan_allowed(struct mlx5_core_dev *mdev)
50{ 50{
51 return (MLX5_CAP_ETH(mdev, tunnel_stateless_vxlan) && 51 return IS_ENABLED(CONFIG_MLX5_CORE_EN_VXLAN) &&
52 (MLX5_CAP_ETH(mdev, tunnel_stateless_vxlan) &&
52 mlx5_core_is_pf(mdev)); 53 mlx5_core_is_pf(mdev));
53} 54}
54 55
56#ifdef CONFIG_MLX5_CORE_EN_VXLAN
55void mlx5e_vxlan_init(struct mlx5e_priv *priv); 57void mlx5e_vxlan_init(struct mlx5e_priv *priv);
58void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv);
59#else
60static inline void mlx5e_vxlan_init(struct mlx5e_priv *priv) {}
61static inline void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv) {}
62#endif
63
56void mlx5e_vxlan_queue_work(struct mlx5e_priv *priv, sa_family_t sa_family, 64void mlx5e_vxlan_queue_work(struct mlx5e_priv *priv, sa_family_t sa_family,
57 u16 port, int add); 65 u16 port, int add);
58struct mlx5e_vxlan *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port); 66struct mlx5e_vxlan *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port);
59void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv);
60 67
61#endif /* __MLX5_VXLAN_H__ */ 68#endif /* __MLX5_VXLAN_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 4afbc3e9e381..668b2f465ca5 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -2541,11 +2541,11 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
2541 lag->ref_count++; 2541 lag->ref_count++;
2542 return 0; 2542 return 0;
2543 2543
2544err_col_port_enable:
2545 mlxsw_sp_lag_col_port_remove(mlxsw_sp_port, lag_id);
2544err_col_port_add: 2546err_col_port_add:
2545 if (!lag->ref_count) 2547 if (!lag->ref_count)
2546 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id); 2548 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id);
2547err_col_port_enable:
2548 mlxsw_sp_lag_col_port_remove(mlxsw_sp_port, lag_id);
2549 return err; 2549 return err;
2550} 2550}
2551 2551
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index e1c74efff51a..9cd6f472234a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -214,7 +214,15 @@ static int __mlxsw_sp_port_flood_set(struct mlxsw_sp_port *mlxsw_sp_port,
214 mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, idx_begin, 214 mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, idx_begin,
215 table_type, range, local_port, set); 215 table_type, range, local_port, set);
216 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); 216 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl);
217 if (err)
218 goto err_flood_bm_set;
219 else
220 goto buffer_out;
217 221
222err_flood_bm_set:
223 mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_UC, idx_begin,
224 table_type, range, local_port, !set);
225 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl);
218buffer_out: 226buffer_out:
219 kfree(sftr_pl); 227 kfree(sftr_pl);
220 return err; 228 return err;
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
index db80eb1c6d4f..2b10f1bcd151 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
@@ -1015,20 +1015,24 @@ static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
1015{ 1015{
1016 int i, v, addr; 1016 int i, v, addr;
1017 __le32 *ptr32; 1017 __le32 *ptr32;
1018 int ret;
1018 1019
1019 addr = base; 1020 addr = base;
1020 ptr32 = buf; 1021 ptr32 = buf;
1021 for (i = 0; i < size / sizeof(u32); i++) { 1022 for (i = 0; i < size / sizeof(u32); i++) {
1022 if (netxen_rom_fast_read(adapter, addr, &v) == -1) 1023 ret = netxen_rom_fast_read(adapter, addr, &v);
1023 return -1; 1024 if (ret)
1025 return ret;
1026
1024 *ptr32 = cpu_to_le32(v); 1027 *ptr32 = cpu_to_le32(v);
1025 ptr32++; 1028 ptr32++;
1026 addr += sizeof(u32); 1029 addr += sizeof(u32);
1027 } 1030 }
1028 if ((char *)buf + size > (char *)ptr32) { 1031 if ((char *)buf + size > (char *)ptr32) {
1029 __le32 local; 1032 __le32 local;
1030 if (netxen_rom_fast_read(adapter, addr, &v) == -1) 1033 ret = netxen_rom_fast_read(adapter, addr, &v);
1031 return -1; 1034 if (ret)
1035 return ret;
1032 local = cpu_to_le32(v); 1036 local = cpu_to_le32(v);
1033 memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32); 1037 memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32);
1034 } 1038 }
@@ -1940,7 +1944,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
1940 if (adapter->phy_read && 1944 if (adapter->phy_read &&
1941 adapter->phy_read(adapter, 1945 adapter->phy_read(adapter,
1942 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 1946 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
1943 &autoneg) != 0) 1947 &autoneg) == 0)
1944 adapter->link_autoneg = autoneg; 1948 adapter->link_autoneg = autoneg;
1945 } else 1949 } else
1946 goto link_down; 1950 goto link_down;
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index fd362b6923f4..9c6eed9b45f7 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -852,7 +852,8 @@ netxen_check_options(struct netxen_adapter *adapter)
852 ptr32 = (__le32 *)&serial_num; 852 ptr32 = (__le32 *)&serial_num;
853 offset = NX_FW_SERIAL_NUM_OFFSET; 853 offset = NX_FW_SERIAL_NUM_OFFSET;
854 for (i = 0; i < 8; i++) { 854 for (i = 0; i < 8; i++) {
855 if (netxen_rom_fast_read(adapter, offset, &val) == -1) { 855 err = netxen_rom_fast_read(adapter, offset, &val);
856 if (err) {
856 dev_err(&pdev->dev, "error reading board info\n"); 857 dev_err(&pdev->dev, "error reading board info\n");
857 adapter->driver_mismatch = 1; 858 adapter->driver_mismatch = 1;
858 return; 859 return;
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 7869465435fa..12f6615797de 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -421,7 +421,7 @@ netdev_tx_t qede_start_xmit(struct sk_buff *skb,
421 u8 xmit_type; 421 u8 xmit_type;
422 u16 idx; 422 u16 idx;
423 u16 hlen; 423 u16 hlen;
424 bool data_split; 424 bool data_split = false;
425 425
426 /* Get tx-queue context and netdev index */ 426 /* Get tx-queue context and netdev index */
427 txq_index = skb_get_queue_mapping(skb); 427 txq_index = skb_get_queue_mapping(skb);
@@ -1938,8 +1938,6 @@ static struct qede_dev *qede_alloc_etherdev(struct qed_dev *cdev,
1938 edev->q_num_rx_buffers = NUM_RX_BDS_DEF; 1938 edev->q_num_rx_buffers = NUM_RX_BDS_DEF;
1939 edev->q_num_tx_buffers = NUM_TX_BDS_DEF; 1939 edev->q_num_tx_buffers = NUM_TX_BDS_DEF;
1940 1940
1941 DP_INFO(edev, "Allocated netdev with 64 tx queues and 64 rx queues\n");
1942
1943 SET_NETDEV_DEV(ndev, &pdev->dev); 1941 SET_NETDEV_DEV(ndev, &pdev->dev);
1944 1942
1945 memset(&edev->stats, 0, sizeof(edev->stats)); 1943 memset(&edev->stats, 0, sizeof(edev->stats));
@@ -2090,9 +2088,9 @@ static void qede_update_pf_params(struct qed_dev *cdev)
2090{ 2088{
2091 struct qed_pf_params pf_params; 2089 struct qed_pf_params pf_params;
2092 2090
2093 /* 16 rx + 16 tx */ 2091 /* 64 rx + 64 tx */
2094 memset(&pf_params, 0, sizeof(struct qed_pf_params)); 2092 memset(&pf_params, 0, sizeof(struct qed_pf_params));
2095 pf_params.eth_pf_params.num_cons = 32; 2093 pf_params.eth_pf_params.num_cons = 128;
2096 qed_ops->common->update_pf_params(cdev, &pf_params); 2094 qed_ops->common->update_pf_params(cdev, &pf_params);
2097} 2095}
2098 2096
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
index cda9e604a95f..0844b7c75767 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
@@ -1417,6 +1417,7 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter)
1417 struct qlcnic_fw_dump *fw_dump = &ahw->fw_dump; 1417 struct qlcnic_fw_dump *fw_dump = &ahw->fw_dump;
1418 struct pci_dev *pdev = adapter->pdev; 1418 struct pci_dev *pdev = adapter->pdev;
1419 bool extended = false; 1419 bool extended = false;
1420 int ret;
1420 1421
1421 prev_version = adapter->fw_version; 1422 prev_version = adapter->fw_version;
1422 current_version = qlcnic_83xx_get_fw_version(adapter); 1423 current_version = qlcnic_83xx_get_fw_version(adapter);
@@ -1427,8 +1428,11 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter)
1427 if (qlcnic_83xx_md_check_extended_dump_capability(adapter)) 1428 if (qlcnic_83xx_md_check_extended_dump_capability(adapter))
1428 extended = !qlcnic_83xx_extend_md_capab(adapter); 1429 extended = !qlcnic_83xx_extend_md_capab(adapter);
1429 1430
1430 if (!qlcnic_fw_cmd_get_minidump_temp(adapter)) 1431 ret = qlcnic_fw_cmd_get_minidump_temp(adapter);
1431 dev_info(&pdev->dev, "Supports FW dump capability\n"); 1432 if (ret)
1433 return;
1434
1435 dev_info(&pdev->dev, "Supports FW dump capability\n");
1432 1436
1433 /* Once we have minidump template with extended iSCSI dump 1437 /* Once we have minidump template with extended iSCSI dump
1434 * capability, update the minidump capture mask to 0x1f as 1438 * capability, update the minidump capture mask to 0x1f as
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 9e2a0bd8f5a8..4277d0c12101 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1506,6 +1506,8 @@ static int ravb_close(struct net_device *ndev)
1506 priv->phydev = NULL; 1506 priv->phydev = NULL;
1507 } 1507 }
1508 1508
1509 if (priv->chip_id == RCAR_GEN3)
1510 free_irq(priv->emac_irq, ndev);
1509 free_irq(ndev->irq, ndev); 1511 free_irq(ndev->irq, ndev);
1510 1512
1511 napi_disable(&priv->napi[RAVB_NC]); 1513 napi_disable(&priv->napi[RAVB_NC]);
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index bc168894bda3..7b0a644122eb 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -504,8 +504,6 @@ static int geneve_gro_complete(struct sk_buff *skb, int nhoff,
504 int gh_len; 504 int gh_len;
505 int err = -ENOSYS; 505 int err = -ENOSYS;
506 506
507 udp_tunnel_gro_complete(skb, nhoff);
508
509 gh = (struct genevehdr *)(skb->data + nhoff); 507 gh = (struct genevehdr *)(skb->data + nhoff);
510 gh_len = geneve_hlen(gh); 508 gh_len = geneve_hlen(gh);
511 type = gh->proto_type; 509 type = gh->proto_type;
@@ -516,6 +514,9 @@ static int geneve_gro_complete(struct sk_buff *skb, int nhoff,
516 err = ptype->callbacks.gro_complete(skb, nhoff + gh_len); 514 err = ptype->callbacks.gro_complete(skb, nhoff + gh_len);
517 515
518 rcu_read_unlock(); 516 rcu_read_unlock();
517
518 skb_set_inner_mac_header(skb, nhoff + gh_len);
519
519 return err; 520 return err;
520} 521}
521 522
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index c6385617bfb2..92eaab95ae2b 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -85,7 +85,7 @@ struct gcm_iv {
85 * @tfm: crypto struct, key storage 85 * @tfm: crypto struct, key storage
86 */ 86 */
87struct macsec_key { 87struct macsec_key {
88 u64 id; 88 u8 id[MACSEC_KEYID_LEN];
89 struct crypto_aead *tfm; 89 struct crypto_aead *tfm;
90}; 90};
91 91
@@ -1529,7 +1529,8 @@ static const struct nla_policy macsec_genl_sa_policy[NUM_MACSEC_SA_ATTR] = {
1529 [MACSEC_SA_ATTR_AN] = { .type = NLA_U8 }, 1529 [MACSEC_SA_ATTR_AN] = { .type = NLA_U8 },
1530 [MACSEC_SA_ATTR_ACTIVE] = { .type = NLA_U8 }, 1530 [MACSEC_SA_ATTR_ACTIVE] = { .type = NLA_U8 },
1531 [MACSEC_SA_ATTR_PN] = { .type = NLA_U32 }, 1531 [MACSEC_SA_ATTR_PN] = { .type = NLA_U32 },
1532 [MACSEC_SA_ATTR_KEYID] = { .type = NLA_U64 }, 1532 [MACSEC_SA_ATTR_KEYID] = { .type = NLA_BINARY,
1533 .len = MACSEC_KEYID_LEN, },
1533 [MACSEC_SA_ATTR_KEY] = { .type = NLA_BINARY, 1534 [MACSEC_SA_ATTR_KEY] = { .type = NLA_BINARY,
1534 .len = MACSEC_MAX_KEY_LEN, }, 1535 .len = MACSEC_MAX_KEY_LEN, },
1535}; 1536};
@@ -1576,6 +1577,9 @@ static bool validate_add_rxsa(struct nlattr **attrs)
1576 return false; 1577 return false;
1577 } 1578 }
1578 1579
1580 if (nla_len(attrs[MACSEC_SA_ATTR_KEYID]) != MACSEC_KEYID_LEN)
1581 return false;
1582
1579 return true; 1583 return true;
1580} 1584}
1581 1585
@@ -1641,7 +1645,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
1641 if (tb_sa[MACSEC_SA_ATTR_ACTIVE]) 1645 if (tb_sa[MACSEC_SA_ATTR_ACTIVE])
1642 rx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); 1646 rx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]);
1643 1647
1644 rx_sa->key.id = nla_get_u64(tb_sa[MACSEC_SA_ATTR_KEYID]); 1648 nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEY], MACSEC_KEYID_LEN);
1645 rx_sa->sc = rx_sc; 1649 rx_sa->sc = rx_sc;
1646 rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa); 1650 rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa);
1647 1651
@@ -1722,6 +1726,9 @@ static bool validate_add_txsa(struct nlattr **attrs)
1722 return false; 1726 return false;
1723 } 1727 }
1724 1728
1729 if (nla_len(attrs[MACSEC_SA_ATTR_KEYID]) != MACSEC_KEYID_LEN)
1730 return false;
1731
1725 return true; 1732 return true;
1726} 1733}
1727 1734
@@ -1777,7 +1784,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
1777 return -ENOMEM; 1784 return -ENOMEM;
1778 } 1785 }
1779 1786
1780 tx_sa->key.id = nla_get_u64(tb_sa[MACSEC_SA_ATTR_KEYID]); 1787 nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEY], MACSEC_KEYID_LEN);
1781 1788
1782 spin_lock_bh(&tx_sa->lock); 1789 spin_lock_bh(&tx_sa->lock);
1783 tx_sa->next_pn = nla_get_u32(tb_sa[MACSEC_SA_ATTR_PN]); 1790 tx_sa->next_pn = nla_get_u32(tb_sa[MACSEC_SA_ATTR_PN]);
@@ -2318,7 +2325,7 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
2318 2325
2319 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) || 2326 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) ||
2320 nla_put_u32(skb, MACSEC_SA_ATTR_PN, tx_sa->next_pn) || 2327 nla_put_u32(skb, MACSEC_SA_ATTR_PN, tx_sa->next_pn) ||
2321 nla_put_u64(skb, MACSEC_SA_ATTR_KEYID, tx_sa->key.id) || 2328 nla_put(skb, MACSEC_SA_ATTR_KEYID, MACSEC_KEYID_LEN, tx_sa->key.id) ||
2322 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, tx_sa->active)) { 2329 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, tx_sa->active)) {
2323 nla_nest_cancel(skb, txsa_nest); 2330 nla_nest_cancel(skb, txsa_nest);
2324 nla_nest_cancel(skb, txsa_list); 2331 nla_nest_cancel(skb, txsa_list);
@@ -2419,7 +2426,7 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
2419 2426
2420 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) || 2427 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) ||
2421 nla_put_u32(skb, MACSEC_SA_ATTR_PN, rx_sa->next_pn) || 2428 nla_put_u32(skb, MACSEC_SA_ATTR_PN, rx_sa->next_pn) ||
2422 nla_put_u64(skb, MACSEC_SA_ATTR_KEYID, rx_sa->key.id) || 2429 nla_put(skb, MACSEC_SA_ATTR_KEYID, MACSEC_KEYID_LEN, rx_sa->key.id) ||
2423 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, rx_sa->active)) { 2430 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, rx_sa->active)) {
2424 nla_nest_cancel(skb, rxsa_nest); 2431 nla_nest_cancel(skb, rxsa_nest);
2425 nla_nest_cancel(skb, rxsc_nest); 2432 nla_nest_cancel(skb, rxsc_nest);
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 95394edd1ed5..9a35aa462314 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -373,7 +373,7 @@ static rx_handler_result_t macvtap_handle_frame(struct sk_buff **pskb)
373 goto wake_up; 373 goto wake_up;
374 } 374 }
375 375
376 kfree_skb(skb); 376 consume_skb(skb);
377 while (segs) { 377 while (segs) {
378 struct sk_buff *nskb = segs->next; 378 struct sk_buff *nskb = segs->next;
379 379
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 5590b9c182c9..445fc5aef308 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -790,9 +790,11 @@ void phy_start(struct phy_device *phydev)
790 break; 790 break;
791 case PHY_HALTED: 791 case PHY_HALTED:
792 /* make sure interrupts are re-enabled for the PHY */ 792 /* make sure interrupts are re-enabled for the PHY */
793 err = phy_enable_interrupts(phydev); 793 if (phydev->irq != PHY_POLL) {
794 if (err < 0) 794 err = phy_enable_interrupts(phydev);
795 break; 795 if (err < 0)
796 break;
797 }
796 798
797 phydev->state = PHY_RESUMING; 799 phydev->state = PHY_RESUMING;
798 do_resume = true; 800 do_resume = true;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 1c0fa364323e..8ac261ab7d7d 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -616,8 +616,9 @@ out:
616static int vxlan_gro_complete(struct sk_buff *skb, int nhoff, 616static int vxlan_gro_complete(struct sk_buff *skb, int nhoff,
617 struct udp_offload *uoff) 617 struct udp_offload *uoff)
618{ 618{
619 udp_tunnel_gro_complete(skb, nhoff); 619 /* Sets 'skb->inner_mac_header' since we are always called with
620 620 * 'skb->encapsulation' set.
621 */
621 return eth_gro_complete(skb, nhoff + sizeof(struct vxlanhdr)); 622 return eth_gro_complete(skb, nhoff + sizeof(struct vxlanhdr));
622} 623}
623 624
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 75870e68a7c3..34731e29c589 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -105,6 +105,7 @@ void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
105 struct iwl_tx_cmd *tx_cmd, 105 struct iwl_tx_cmd *tx_cmd,
106 struct ieee80211_tx_info *info, u8 sta_id) 106 struct ieee80211_tx_info *info, u8 sta_id)
107{ 107{
108 struct ieee80211_tx_info *skb_info = IEEE80211_SKB_CB(skb);
108 struct ieee80211_hdr *hdr = (void *)skb->data; 109 struct ieee80211_hdr *hdr = (void *)skb->data;
109 __le16 fc = hdr->frame_control; 110 __le16 fc = hdr->frame_control;
110 u32 tx_flags = le32_to_cpu(tx_cmd->tx_flags); 111 u32 tx_flags = le32_to_cpu(tx_cmd->tx_flags);
@@ -185,7 +186,7 @@ void iwl_mvm_set_tx_cmd(struct iwl_mvm *mvm, struct sk_buff *skb,
185 tx_cmd->tx_flags = cpu_to_le32(tx_flags); 186 tx_cmd->tx_flags = cpu_to_le32(tx_flags);
186 /* Total # bytes to be transmitted */ 187 /* Total # bytes to be transmitted */
187 tx_cmd->len = cpu_to_le16((u16)skb->len + 188 tx_cmd->len = cpu_to_le16((u16)skb->len +
188 (uintptr_t)info->driver_data[0]); 189 (uintptr_t)skb_info->driver_data[0]);
189 tx_cmd->next_frame_len = 0; 190 tx_cmd->next_frame_len = 0;
190 tx_cmd->life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE); 191 tx_cmd->life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
191 tx_cmd->sta_id = sta_id; 192 tx_cmd->sta_id = sta_id;
@@ -327,10 +328,11 @@ static void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm,
327 */ 328 */
328static struct iwl_device_cmd * 329static struct iwl_device_cmd *
329iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb, 330iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
330 int hdrlen, struct ieee80211_sta *sta, u8 sta_id) 331 struct ieee80211_tx_info *info, int hdrlen,
332 struct ieee80211_sta *sta, u8 sta_id)
331{ 333{
332 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 334 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
333 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 335 struct ieee80211_tx_info *skb_info = IEEE80211_SKB_CB(skb);
334 struct iwl_device_cmd *dev_cmd; 336 struct iwl_device_cmd *dev_cmd;
335 struct iwl_tx_cmd *tx_cmd; 337 struct iwl_tx_cmd *tx_cmd;
336 338
@@ -350,10 +352,10 @@ iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
350 352
351 iwl_mvm_set_tx_cmd_rate(mvm, tx_cmd, info, sta, hdr->frame_control); 353 iwl_mvm_set_tx_cmd_rate(mvm, tx_cmd, info, sta, hdr->frame_control);
352 354
353 memset(&info->status, 0, sizeof(info->status)); 355 memset(&skb_info->status, 0, sizeof(skb_info->status));
354 memset(info->driver_data, 0, sizeof(info->driver_data)); 356 memset(skb_info->driver_data, 0, sizeof(skb_info->driver_data));
355 357
356 info->driver_data[1] = dev_cmd; 358 skb_info->driver_data[1] = dev_cmd;
357 359
358 return dev_cmd; 360 return dev_cmd;
359} 361}
@@ -361,22 +363,25 @@ iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
361int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb) 363int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
362{ 364{
363 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 365 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
364 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 366 struct ieee80211_tx_info *skb_info = IEEE80211_SKB_CB(skb);
367 struct ieee80211_tx_info info;
365 struct iwl_device_cmd *dev_cmd; 368 struct iwl_device_cmd *dev_cmd;
366 struct iwl_tx_cmd *tx_cmd; 369 struct iwl_tx_cmd *tx_cmd;
367 u8 sta_id; 370 u8 sta_id;
368 int hdrlen = ieee80211_hdrlen(hdr->frame_control); 371 int hdrlen = ieee80211_hdrlen(hdr->frame_control);
369 372
370 if (WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_AMPDU)) 373 memcpy(&info, skb->cb, sizeof(info));
374
375 if (WARN_ON_ONCE(info.flags & IEEE80211_TX_CTL_AMPDU))
371 return -1; 376 return -1;
372 377
373 if (WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM && 378 if (WARN_ON_ONCE(info.flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&
374 (!info->control.vif || 379 (!info.control.vif ||
375 info->hw_queue != info->control.vif->cab_queue))) 380 info.hw_queue != info.control.vif->cab_queue)))
376 return -1; 381 return -1;
377 382
378 /* This holds the amsdu headers length */ 383 /* This holds the amsdu headers length */
379 info->driver_data[0] = (void *)(uintptr_t)0; 384 skb_info->driver_data[0] = (void *)(uintptr_t)0;
380 385
381 /* 386 /*
382 * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets that can be used 387 * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets that can be used
@@ -385,7 +390,7 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
385 * and hence needs to be sent on the aux queue 390 * and hence needs to be sent on the aux queue
386 */ 391 */
387 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && 392 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
388 info->control.vif->type == NL80211_IFTYPE_STATION) 393 info.control.vif->type == NL80211_IFTYPE_STATION)
389 IEEE80211_SKB_CB(skb)->hw_queue = mvm->aux_queue; 394 IEEE80211_SKB_CB(skb)->hw_queue = mvm->aux_queue;
390 395
391 /* 396 /*
@@ -398,14 +403,14 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
398 * AUX station. 403 * AUX station.
399 */ 404 */
400 sta_id = mvm->aux_sta.sta_id; 405 sta_id = mvm->aux_sta.sta_id;
401 if (info->control.vif) { 406 if (info.control.vif) {
402 struct iwl_mvm_vif *mvmvif = 407 struct iwl_mvm_vif *mvmvif =
403 iwl_mvm_vif_from_mac80211(info->control.vif); 408 iwl_mvm_vif_from_mac80211(info.control.vif);
404 409
405 if (info->control.vif->type == NL80211_IFTYPE_P2P_DEVICE || 410 if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE ||
406 info->control.vif->type == NL80211_IFTYPE_AP) 411 info.control.vif->type == NL80211_IFTYPE_AP)
407 sta_id = mvmvif->bcast_sta.sta_id; 412 sta_id = mvmvif->bcast_sta.sta_id;
408 else if (info->control.vif->type == NL80211_IFTYPE_STATION && 413 else if (info.control.vif->type == NL80211_IFTYPE_STATION &&
409 is_multicast_ether_addr(hdr->addr1)) { 414 is_multicast_ether_addr(hdr->addr1)) {
410 u8 ap_sta_id = ACCESS_ONCE(mvmvif->ap_sta_id); 415 u8 ap_sta_id = ACCESS_ONCE(mvmvif->ap_sta_id);
411 416
@@ -414,19 +419,18 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
414 } 419 }
415 } 420 }
416 421
417 IWL_DEBUG_TX(mvm, "station Id %d, queue=%d\n", sta_id, info->hw_queue); 422 IWL_DEBUG_TX(mvm, "station Id %d, queue=%d\n", sta_id, info.hw_queue);
418 423
419 dev_cmd = iwl_mvm_set_tx_params(mvm, skb, hdrlen, NULL, sta_id); 424 dev_cmd = iwl_mvm_set_tx_params(mvm, skb, &info, hdrlen, NULL, sta_id);
420 if (!dev_cmd) 425 if (!dev_cmd)
421 return -1; 426 return -1;
422 427
423 /* From now on, we cannot access info->control */
424 tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload; 428 tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload;
425 429
426 /* Copy MAC header from skb into command buffer */ 430 /* Copy MAC header from skb into command buffer */
427 memcpy(tx_cmd->hdr, hdr, hdrlen); 431 memcpy(tx_cmd->hdr, hdr, hdrlen);
428 432
429 if (iwl_trans_tx(mvm->trans, skb, dev_cmd, info->hw_queue)) { 433 if (iwl_trans_tx(mvm->trans, skb, dev_cmd, info.hw_queue)) {
430 iwl_trans_free_tx_cmd(mvm->trans, dev_cmd); 434 iwl_trans_free_tx_cmd(mvm->trans, dev_cmd);
431 return -1; 435 return -1;
432 } 436 }
@@ -445,11 +449,11 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
445 449
446#ifdef CONFIG_INET 450#ifdef CONFIG_INET
447static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb, 451static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
452 struct ieee80211_tx_info *info,
448 struct ieee80211_sta *sta, 453 struct ieee80211_sta *sta,
449 struct sk_buff_head *mpdus_skb) 454 struct sk_buff_head *mpdus_skb)
450{ 455{
451 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 456 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
452 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
453 struct ieee80211_hdr *hdr = (void *)skb->data; 457 struct ieee80211_hdr *hdr = (void *)skb->data;
454 unsigned int mss = skb_shinfo(skb)->gso_size; 458 unsigned int mss = skb_shinfo(skb)->gso_size;
455 struct sk_buff *tmp, *next; 459 struct sk_buff *tmp, *next;
@@ -544,6 +548,8 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
544 548
545 /* This skb fits in one single A-MSDU */ 549 /* This skb fits in one single A-MSDU */
546 if (num_subframes * mss >= tcp_payload_len) { 550 if (num_subframes * mss >= tcp_payload_len) {
551 struct ieee80211_tx_info *skb_info = IEEE80211_SKB_CB(skb);
552
547 /* 553 /*
548 * Compute the length of all the data added for the A-MSDU. 554 * Compute the length of all the data added for the A-MSDU.
549 * This will be used to compute the length to write in the TX 555 * This will be used to compute the length to write in the TX
@@ -552,11 +558,10 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
552 * already had one set of SNAP / IP / TCP headers. 558 * already had one set of SNAP / IP / TCP headers.
553 */ 559 */
554 num_subframes = DIV_ROUND_UP(tcp_payload_len, mss); 560 num_subframes = DIV_ROUND_UP(tcp_payload_len, mss);
555 info = IEEE80211_SKB_CB(skb);
556 amsdu_add = num_subframes * sizeof(struct ethhdr) + 561 amsdu_add = num_subframes * sizeof(struct ethhdr) +
557 (num_subframes - 1) * (snap_ip_tcp + pad); 562 (num_subframes - 1) * (snap_ip_tcp + pad);
558 /* This holds the amsdu headers length */ 563 /* This holds the amsdu headers length */
559 info->driver_data[0] = (void *)(uintptr_t)amsdu_add; 564 skb_info->driver_data[0] = (void *)(uintptr_t)amsdu_add;
560 565
561 __skb_queue_tail(mpdus_skb, skb); 566 __skb_queue_tail(mpdus_skb, skb);
562 return 0; 567 return 0;
@@ -596,11 +601,14 @@ segment:
596 ip_hdr(tmp)->id = htons(ip_base_id + i * num_subframes); 601 ip_hdr(tmp)->id = htons(ip_base_id + i * num_subframes);
597 602
598 if (tcp_payload_len > mss) { 603 if (tcp_payload_len > mss) {
604 struct ieee80211_tx_info *skb_info =
605 IEEE80211_SKB_CB(tmp);
606
599 num_subframes = DIV_ROUND_UP(tcp_payload_len, mss); 607 num_subframes = DIV_ROUND_UP(tcp_payload_len, mss);
600 info = IEEE80211_SKB_CB(tmp);
601 amsdu_add = num_subframes * sizeof(struct ethhdr) + 608 amsdu_add = num_subframes * sizeof(struct ethhdr) +
602 (num_subframes - 1) * (snap_ip_tcp + pad); 609 (num_subframes - 1) * (snap_ip_tcp + pad);
603 info->driver_data[0] = (void *)(uintptr_t)amsdu_add; 610 skb_info->driver_data[0] =
611 (void *)(uintptr_t)amsdu_add;
604 skb_shinfo(tmp)->gso_size = mss; 612 skb_shinfo(tmp)->gso_size = mss;
605 } else { 613 } else {
606 qc = ieee80211_get_qos_ctl((void *)tmp->data); 614 qc = ieee80211_get_qos_ctl((void *)tmp->data);
@@ -622,6 +630,7 @@ segment:
622} 630}
623#else /* CONFIG_INET */ 631#else /* CONFIG_INET */
624static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb, 632static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
633 struct ieee80211_tx_info *info,
625 struct ieee80211_sta *sta, 634 struct ieee80211_sta *sta,
626 struct sk_buff_head *mpdus_skb) 635 struct sk_buff_head *mpdus_skb)
627{ 636{
@@ -636,10 +645,10 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
636 * Sets the fields in the Tx cmd that are crypto related 645 * Sets the fields in the Tx cmd that are crypto related
637 */ 646 */
638static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb, 647static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
648 struct ieee80211_tx_info *info,
639 struct ieee80211_sta *sta) 649 struct ieee80211_sta *sta)
640{ 650{
641 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 651 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
642 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
643 struct iwl_mvm_sta *mvmsta; 652 struct iwl_mvm_sta *mvmsta;
644 struct iwl_device_cmd *dev_cmd; 653 struct iwl_device_cmd *dev_cmd;
645 struct iwl_tx_cmd *tx_cmd; 654 struct iwl_tx_cmd *tx_cmd;
@@ -660,7 +669,8 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
660 if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) 669 if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
661 return -1; 670 return -1;
662 671
663 dev_cmd = iwl_mvm_set_tx_params(mvm, skb, hdrlen, sta, mvmsta->sta_id); 672 dev_cmd = iwl_mvm_set_tx_params(mvm, skb, info, hdrlen,
673 sta, mvmsta->sta_id);
664 if (!dev_cmd) 674 if (!dev_cmd)
665 goto drop; 675 goto drop;
666 676
@@ -736,7 +746,8 @@ int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
736 struct ieee80211_sta *sta) 746 struct ieee80211_sta *sta)
737{ 747{
738 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 748 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
739 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 749 struct ieee80211_tx_info *skb_info = IEEE80211_SKB_CB(skb);
750 struct ieee80211_tx_info info;
740 struct sk_buff_head mpdus_skbs; 751 struct sk_buff_head mpdus_skbs;
741 unsigned int payload_len; 752 unsigned int payload_len;
742 int ret; 753 int ret;
@@ -747,21 +758,23 @@ int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
747 if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) 758 if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
748 return -1; 759 return -1;
749 760
761 memcpy(&info, skb->cb, sizeof(info));
762
750 /* This holds the amsdu headers length */ 763 /* This holds the amsdu headers length */
751 info->driver_data[0] = (void *)(uintptr_t)0; 764 skb_info->driver_data[0] = (void *)(uintptr_t)0;
752 765
753 if (!skb_is_gso(skb)) 766 if (!skb_is_gso(skb))
754 return iwl_mvm_tx_mpdu(mvm, skb, sta); 767 return iwl_mvm_tx_mpdu(mvm, skb, &info, sta);
755 768
756 payload_len = skb_tail_pointer(skb) - skb_transport_header(skb) - 769 payload_len = skb_tail_pointer(skb) - skb_transport_header(skb) -
757 tcp_hdrlen(skb) + skb->data_len; 770 tcp_hdrlen(skb) + skb->data_len;
758 771
759 if (payload_len <= skb_shinfo(skb)->gso_size) 772 if (payload_len <= skb_shinfo(skb)->gso_size)
760 return iwl_mvm_tx_mpdu(mvm, skb, sta); 773 return iwl_mvm_tx_mpdu(mvm, skb, &info, sta);
761 774
762 __skb_queue_head_init(&mpdus_skbs); 775 __skb_queue_head_init(&mpdus_skbs);
763 776
764 ret = iwl_mvm_tx_tso(mvm, skb, sta, &mpdus_skbs); 777 ret = iwl_mvm_tx_tso(mvm, skb, &info, sta, &mpdus_skbs);
765 if (ret) 778 if (ret)
766 return ret; 779 return ret;
767 780
@@ -771,7 +784,7 @@ int iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
771 while (!skb_queue_empty(&mpdus_skbs)) { 784 while (!skb_queue_empty(&mpdus_skbs)) {
772 skb = __skb_dequeue(&mpdus_skbs); 785 skb = __skb_dequeue(&mpdus_skbs);
773 786
774 ret = iwl_mvm_tx_mpdu(mvm, skb, sta); 787 ret = iwl_mvm_tx_mpdu(mvm, skb, &info, sta);
775 if (ret) { 788 if (ret) {
776 __skb_queue_purge(&mpdus_skbs); 789 __skb_queue_purge(&mpdus_skbs);
777 return ret; 790 return ret;
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index b42f26029225..4412a57ec862 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -711,6 +711,7 @@ static void xenvif_tx_err(struct xenvif_queue *queue,
711 if (cons == end) 711 if (cons == end)
712 break; 712 break;
713 RING_COPY_REQUEST(&queue->tx, cons++, txp); 713 RING_COPY_REQUEST(&queue->tx, cons++, txp);
714 extra_count = 0; /* only the first frag can have extras */
714 } while (1); 715 } while (1);
715 queue->tx.req_cons = cons; 716 queue->tx.req_cons = cons;
716} 717}
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 5101f3ab4f29..92f536596b24 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -402,9 +402,9 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
402 402
403 /* 403 /*
404 * vmemmap_populate_hugepages() allocates the memmap array in 404 * vmemmap_populate_hugepages() allocates the memmap array in
405 * HPAGE_SIZE chunks. 405 * PMD_SIZE chunks.
406 */ 406 */
407 memmap_size = ALIGN(64 * npfns, HPAGE_SIZE); 407 memmap_size = ALIGN(64 * npfns, PMD_SIZE);
408 offset = ALIGN(start + SZ_8K + memmap_size, nd_pfn->align) 408 offset = ALIGN(start + SZ_8K + memmap_size, nd_pfn->align)
409 - start; 409 - start;
410 } else if (nd_pfn->mode == PFN_MODE_RAM) 410 } else if (nd_pfn->mode == PFN_MODE_RAM)
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 6c9f5467bc5f..dd7cdbee8029 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -294,7 +294,7 @@ void pci_bus_add_device(struct pci_dev *dev)
294 294
295 dev->match_driver = true; 295 dev->match_driver = true;
296 retval = device_attach(&dev->dev); 296 retval = device_attach(&dev->dev);
297 if (retval < 0) { 297 if (retval < 0 && retval != -EPROBE_DEFER) {
298 dev_warn(&dev->dev, "device attach failed (%d)\n", retval); 298 dev_warn(&dev->dev, "device attach failed (%d)\n", retval);
299 pci_proc_detach_device(dev); 299 pci_proc_detach_device(dev);
300 pci_remove_sysfs_dev_files(dev); 300 pci_remove_sysfs_dev_files(dev);
@@ -324,7 +324,9 @@ void pci_bus_add_devices(const struct pci_bus *bus)
324 } 324 }
325 325
326 list_for_each_entry(dev, &bus->devices, bus_list) { 326 list_for_each_entry(dev, &bus->devices, bus_list) {
327 BUG_ON(!dev->is_added); 327 /* Skip if device attach failed */
328 if (!dev->is_added)
329 continue;
328 child = dev->subordinate; 330 child = dev->subordinate;
329 if (child) 331 if (child)
330 pci_bus_add_devices(child); 332 pci_bus_add_devices(child);
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index 4429312e848d..2c447130b954 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -722,9 +722,11 @@ static int atmel_conf_pin_config_group_set(struct pinctrl_dev *pctldev,
722 break; 722 break;
723 case PIN_CONFIG_BIAS_PULL_UP: 723 case PIN_CONFIG_BIAS_PULL_UP:
724 conf |= ATMEL_PIO_PUEN_MASK; 724 conf |= ATMEL_PIO_PUEN_MASK;
725 conf &= (~ATMEL_PIO_PDEN_MASK);
725 break; 726 break;
726 case PIN_CONFIG_BIAS_PULL_DOWN: 727 case PIN_CONFIG_BIAS_PULL_DOWN:
727 conf |= ATMEL_PIO_PDEN_MASK; 728 conf |= ATMEL_PIO_PDEN_MASK;
729 conf &= (~ATMEL_PIO_PUEN_MASK);
728 break; 730 break;
729 case PIN_CONFIG_DRIVE_OPEN_DRAIN: 731 case PIN_CONFIG_DRIVE_OPEN_DRAIN:
730 if (arg == 0) 732 if (arg == 0)
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 40cd894e4df5..514a5e8fdbab 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -157,7 +157,9 @@ static struct regulator_ops axp20x_ops_sw = {
157static const struct regulator_linear_range axp20x_ldo4_ranges[] = { 157static const struct regulator_linear_range axp20x_ldo4_ranges[] = {
158 REGULATOR_LINEAR_RANGE(1250000, 0x0, 0x0, 0), 158 REGULATOR_LINEAR_RANGE(1250000, 0x0, 0x0, 0),
159 REGULATOR_LINEAR_RANGE(1300000, 0x1, 0x8, 100000), 159 REGULATOR_LINEAR_RANGE(1300000, 0x1, 0x8, 100000),
160 REGULATOR_LINEAR_RANGE(2500000, 0x9, 0xf, 100000), 160 REGULATOR_LINEAR_RANGE(2500000, 0x9, 0x9, 0),
161 REGULATOR_LINEAR_RANGE(2700000, 0xa, 0xb, 100000),
162 REGULATOR_LINEAR_RANGE(3000000, 0xc, 0xf, 100000),
161}; 163};
162 164
163static const struct regulator_desc axp20x_regulators[] = { 165static const struct regulator_desc axp20x_regulators[] = {
@@ -215,10 +217,14 @@ static const struct regulator_desc axp22x_regulators[] = {
215 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)), 217 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
216 AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100, 218 AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
217 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)), 219 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
218 AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100, 220 /* Note the datasheet only guarantees reliable operation up to
221 * 3.3V, this needs to be enforced via dts provided constraints */
222 AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 700, 3800, 100,
219 AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07, 223 AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
220 AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 224 AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
221 AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100, 225 /* Note the datasheet only guarantees reliable operation up to
226 * 3.3V, this needs to be enforced via dts provided constraints */
227 AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 700, 3800, 100,
222 AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07, 228 AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
223 AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 229 AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
224 AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000), 230 AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index ed9e7e96f877..c6af343f54ea 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -900,4 +900,4 @@ module_exit(da9063_regulator_cleanup);
900MODULE_AUTHOR("Krystian Garbaciak <krystian.garbaciak@diasemi.com>"); 900MODULE_AUTHOR("Krystian Garbaciak <krystian.garbaciak@diasemi.com>");
901MODULE_DESCRIPTION("DA9063 regulators driver"); 901MODULE_DESCRIPTION("DA9063 regulators driver");
902MODULE_LICENSE("GPL"); 902MODULE_LICENSE("GPL");
903MODULE_ALIAS("paltform:" DA9063_DRVNAME_REGULATORS); 903MODULE_ALIAS("platform:" DA9063_DRVNAME_REGULATORS);
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index a8718e98674a..83e89e5d4752 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -162,6 +162,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
162 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); 162 of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
163 163
164 config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0); 164 config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
165 if (config->enable_gpio == -EPROBE_DEFER)
166 return ERR_PTR(-EPROBE_DEFER);
165 167
166 /* Fetch GPIOs. - optional property*/ 168 /* Fetch GPIOs. - optional property*/
167 ret = of_gpio_count(np); 169 ret = of_gpio_count(np);
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index d24e2c783dc5..6dfa3502e1f1 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -308,7 +308,7 @@ static struct regulator_ops s2mps11_buck_ops = {
308 .enable_mask = S2MPS11_ENABLE_MASK \ 308 .enable_mask = S2MPS11_ENABLE_MASK \
309} 309}
310 310
311#define regulator_desc_s2mps11_buck6_10(num, min, step) { \ 311#define regulator_desc_s2mps11_buck67810(num, min, step) { \
312 .name = "BUCK"#num, \ 312 .name = "BUCK"#num, \
313 .id = S2MPS11_BUCK##num, \ 313 .id = S2MPS11_BUCK##num, \
314 .ops = &s2mps11_buck_ops, \ 314 .ops = &s2mps11_buck_ops, \
@@ -324,6 +324,22 @@ static struct regulator_ops s2mps11_buck_ops = {
324 .enable_mask = S2MPS11_ENABLE_MASK \ 324 .enable_mask = S2MPS11_ENABLE_MASK \
325} 325}
326 326
327#define regulator_desc_s2mps11_buck9 { \
328 .name = "BUCK9", \
329 .id = S2MPS11_BUCK9, \
330 .ops = &s2mps11_buck_ops, \
331 .type = REGULATOR_VOLTAGE, \
332 .owner = THIS_MODULE, \
333 .min_uV = MIN_3000_MV, \
334 .uV_step = STEP_25_MV, \
335 .n_voltages = S2MPS11_BUCK9_N_VOLTAGES, \
336 .ramp_delay = S2MPS11_RAMP_DELAY, \
337 .vsel_reg = S2MPS11_REG_B9CTRL2, \
338 .vsel_mask = S2MPS11_BUCK9_VSEL_MASK, \
339 .enable_reg = S2MPS11_REG_B9CTRL1, \
340 .enable_mask = S2MPS11_ENABLE_MASK \
341}
342
327static const struct regulator_desc s2mps11_regulators[] = { 343static const struct regulator_desc s2mps11_regulators[] = {
328 regulator_desc_s2mps11_ldo(1, STEP_25_MV), 344 regulator_desc_s2mps11_ldo(1, STEP_25_MV),
329 regulator_desc_s2mps11_ldo(2, STEP_50_MV), 345 regulator_desc_s2mps11_ldo(2, STEP_50_MV),
@@ -368,11 +384,11 @@ static const struct regulator_desc s2mps11_regulators[] = {
368 regulator_desc_s2mps11_buck1_4(3), 384 regulator_desc_s2mps11_buck1_4(3),
369 regulator_desc_s2mps11_buck1_4(4), 385 regulator_desc_s2mps11_buck1_4(4),
370 regulator_desc_s2mps11_buck5, 386 regulator_desc_s2mps11_buck5,
371 regulator_desc_s2mps11_buck6_10(6, MIN_600_MV, STEP_6_25_MV), 387 regulator_desc_s2mps11_buck67810(6, MIN_600_MV, STEP_6_25_MV),
372 regulator_desc_s2mps11_buck6_10(7, MIN_600_MV, STEP_6_25_MV), 388 regulator_desc_s2mps11_buck67810(7, MIN_600_MV, STEP_6_25_MV),
373 regulator_desc_s2mps11_buck6_10(8, MIN_600_MV, STEP_6_25_MV), 389 regulator_desc_s2mps11_buck67810(8, MIN_600_MV, STEP_6_25_MV),
374 regulator_desc_s2mps11_buck6_10(9, MIN_3000_MV, STEP_25_MV), 390 regulator_desc_s2mps11_buck9,
375 regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV), 391 regulator_desc_s2mps11_buck67810(10, MIN_750_MV, STEP_12_5_MV),
376}; 392};
377 393
378static struct regulator_ops s2mps14_reg_ops; 394static struct regulator_ops s2mps14_reg_ops;
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 8eaed0522aa3..a655cf29c16f 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -532,6 +532,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
532 return SCSI_DH_DEV_TEMP_BUSY; 532 return SCSI_DH_DEV_TEMP_BUSY;
533 533
534 retry: 534 retry:
535 err = 0;
535 retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags); 536 retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags);
536 537
537 if (retval) { 538 if (retval) {
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 5d0ec42a9317..634254a52301 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -4214,7 +4214,7 @@ static struct scsi_host_template qla1280_driver_template = {
4214 .eh_bus_reset_handler = qla1280_eh_bus_reset, 4214 .eh_bus_reset_handler = qla1280_eh_bus_reset,
4215 .eh_host_reset_handler = qla1280_eh_adapter_reset, 4215 .eh_host_reset_handler = qla1280_eh_adapter_reset,
4216 .bios_param = qla1280_biosparam, 4216 .bios_param = qla1280_biosparam,
4217 .can_queue = 0xfffff, 4217 .can_queue = MAX_OUTSTANDING_COMMANDS,
4218 .this_id = -1, 4218 .this_id = -1,
4219 .sg_tablesize = SG_ALL, 4219 .sg_tablesize = SG_ALL,
4220 .use_clustering = ENABLE_CLUSTERING, 4220 .use_clustering = ENABLE_CLUSTERING,
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index bb00be8d1851..17a6387e20b5 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -567,7 +567,7 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
567 txd = ep93xx_spi_dma_prepare(espi, DMA_MEM_TO_DEV); 567 txd = ep93xx_spi_dma_prepare(espi, DMA_MEM_TO_DEV);
568 if (IS_ERR(txd)) { 568 if (IS_ERR(txd)) {
569 ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM); 569 ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
570 dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(rxd)); 570 dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
571 msg->status = PTR_ERR(txd); 571 msg->status = PTR_ERR(txd);
572 return; 572 return;
573 } 573 }
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 39412c9097c6..c1a2d747b246 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -385,8 +385,8 @@ static int dspi_transfer_one_message(struct spi_master *master,
385 dspi->cur_chip = spi_get_ctldata(spi); 385 dspi->cur_chip = spi_get_ctldata(spi);
386 dspi->cs = spi->chip_select; 386 dspi->cs = spi->chip_select;
387 dspi->cs_change = 0; 387 dspi->cs_change = 0;
388 if (dspi->cur_transfer->transfer_list.next 388 if (list_is_last(&dspi->cur_transfer->transfer_list,
389 == &dspi->cur_msg->transfers) 389 &dspi->cur_msg->transfers) || transfer->cs_change)
390 dspi->cs_change = 1; 390 dspi->cs_change = 1;
391 dspi->void_write_data = dspi->cur_chip->void_write_data; 391 dspi->void_write_data = dspi->cur_chip->void_write_data;
392 392
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 43a02e377b3b..0caa3c8bef46 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -423,12 +423,16 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
423 423
424 if (mcspi_dma->dma_tx) { 424 if (mcspi_dma->dma_tx) {
425 struct dma_async_tx_descriptor *tx; 425 struct dma_async_tx_descriptor *tx;
426 struct scatterlist sg;
426 427
427 dmaengine_slave_config(mcspi_dma->dma_tx, &cfg); 428 dmaengine_slave_config(mcspi_dma->dma_tx, &cfg);
428 429
429 tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, xfer->tx_sg.sgl, 430 sg_init_table(&sg, 1);
430 xfer->tx_sg.nents, DMA_MEM_TO_DEV, 431 sg_dma_address(&sg) = xfer->tx_dma;
431 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 432 sg_dma_len(&sg) = xfer->len;
433
434 tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
435 DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
432 if (tx) { 436 if (tx) {
433 tx->callback = omap2_mcspi_tx_callback; 437 tx->callback = omap2_mcspi_tx_callback;
434 tx->callback_param = spi; 438 tx->callback_param = spi;
@@ -474,15 +478,20 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
474 478
475 if (mcspi_dma->dma_rx) { 479 if (mcspi_dma->dma_rx) {
476 struct dma_async_tx_descriptor *tx; 480 struct dma_async_tx_descriptor *tx;
481 struct scatterlist sg;
477 482
478 dmaengine_slave_config(mcspi_dma->dma_rx, &cfg); 483 dmaengine_slave_config(mcspi_dma->dma_rx, &cfg);
479 484
480 if ((l & OMAP2_MCSPI_CHCONF_TURBO) && mcspi->fifo_depth == 0) 485 if ((l & OMAP2_MCSPI_CHCONF_TURBO) && mcspi->fifo_depth == 0)
481 dma_count -= es; 486 dma_count -= es;
482 487
483 tx = dmaengine_prep_slave_sg(mcspi_dma->dma_rx, xfer->rx_sg.sgl, 488 sg_init_table(&sg, 1);
484 xfer->rx_sg.nents, DMA_DEV_TO_MEM, 489 sg_dma_address(&sg) = xfer->rx_dma;
485 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 490 sg_dma_len(&sg) = dma_count;
491
492 tx = dmaengine_prep_slave_sg(mcspi_dma->dma_rx, &sg, 1,
493 DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT |
494 DMA_CTRL_ACK);
486 if (tx) { 495 if (tx) {
487 tx->callback = omap2_mcspi_rx_callback; 496 tx->callback = omap2_mcspi_rx_callback;
488 tx->callback_param = spi; 497 tx->callback_param = spi;
@@ -496,6 +505,8 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
496 omap2_mcspi_set_dma_req(spi, 1, 1); 505 omap2_mcspi_set_dma_req(spi, 1, 1);
497 506
498 wait_for_completion(&mcspi_dma->dma_rx_completion); 507 wait_for_completion(&mcspi_dma->dma_rx_completion);
508 dma_unmap_single(mcspi->dev, xfer->rx_dma, count,
509 DMA_FROM_DEVICE);
499 510
500 if (mcspi->fifo_depth > 0) 511 if (mcspi->fifo_depth > 0)
501 return count; 512 return count;
@@ -608,6 +619,8 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
608 619
609 if (tx != NULL) { 620 if (tx != NULL) {
610 wait_for_completion(&mcspi_dma->dma_tx_completion); 621 wait_for_completion(&mcspi_dma->dma_tx_completion);
622 dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len,
623 DMA_TO_DEVICE);
611 624
612 if (mcspi->fifo_depth > 0) { 625 if (mcspi->fifo_depth > 0) {
613 irqstat_reg = mcspi->base + OMAP2_MCSPI_IRQSTATUS; 626 irqstat_reg = mcspi->base + OMAP2_MCSPI_IRQSTATUS;
@@ -1074,16 +1087,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
1074 gpio_free(spi->cs_gpio); 1087 gpio_free(spi->cs_gpio);
1075} 1088}
1076 1089
1077static bool omap2_mcspi_can_dma(struct spi_master *master,
1078 struct spi_device *spi,
1079 struct spi_transfer *xfer)
1080{
1081 if (xfer->len < DMA_MIN_BYTES)
1082 return false;
1083
1084 return true;
1085}
1086
1087static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi, 1090static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi,
1088 struct spi_device *spi, struct spi_transfer *t) 1091 struct spi_device *spi, struct spi_transfer *t)
1089{ 1092{
@@ -1265,6 +1268,32 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
1265 return -EINVAL; 1268 return -EINVAL;
1266 } 1269 }
1267 1270
1271 if (len < DMA_MIN_BYTES)
1272 goto skip_dma_map;
1273
1274 if (mcspi_dma->dma_tx && tx_buf != NULL) {
1275 t->tx_dma = dma_map_single(mcspi->dev, (void *) tx_buf,
1276 len, DMA_TO_DEVICE);
1277 if (dma_mapping_error(mcspi->dev, t->tx_dma)) {
1278 dev_dbg(mcspi->dev, "dma %cX %d bytes error\n",
1279 'T', len);
1280 return -EINVAL;
1281 }
1282 }
1283 if (mcspi_dma->dma_rx && rx_buf != NULL) {
1284 t->rx_dma = dma_map_single(mcspi->dev, rx_buf, t->len,
1285 DMA_FROM_DEVICE);
1286 if (dma_mapping_error(mcspi->dev, t->rx_dma)) {
1287 dev_dbg(mcspi->dev, "dma %cX %d bytes error\n",
1288 'R', len);
1289 if (tx_buf != NULL)
1290 dma_unmap_single(mcspi->dev, t->tx_dma,
1291 len, DMA_TO_DEVICE);
1292 return -EINVAL;
1293 }
1294 }
1295
1296skip_dma_map:
1268 return omap2_mcspi_work_one(mcspi, spi, t); 1297 return omap2_mcspi_work_one(mcspi, spi, t);
1269} 1298}
1270 1299
@@ -1348,7 +1377,6 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1348 master->transfer_one = omap2_mcspi_transfer_one; 1377 master->transfer_one = omap2_mcspi_transfer_one;
1349 master->set_cs = omap2_mcspi_set_cs; 1378 master->set_cs = omap2_mcspi_set_cs;
1350 master->cleanup = omap2_mcspi_cleanup; 1379 master->cleanup = omap2_mcspi_cleanup;
1351 master->can_dma = omap2_mcspi_can_dma;
1352 master->dev.of_node = node; 1380 master->dev.of_node = node;
1353 master->max_speed_hz = OMAP2_MCSPI_MAX_FREQ; 1381 master->max_speed_hz = OMAP2_MCSPI_MAX_FREQ;
1354 master->min_speed_hz = OMAP2_MCSPI_MAX_FREQ >> 15; 1382 master->min_speed_hz = OMAP2_MCSPI_MAX_FREQ >> 15;
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 85e59a406a4c..86138e4101b0 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -126,7 +126,7 @@ static const struct lpss_config lpss_platforms[] = {
126 .reg_general = -1, 126 .reg_general = -1,
127 .reg_ssp = 0x20, 127 .reg_ssp = 0x20,
128 .reg_cs_ctrl = 0x24, 128 .reg_cs_ctrl = 0x24,
129 .reg_capabilities = 0xfc, 129 .reg_capabilities = -1,
130 .rx_threshold = 1, 130 .rx_threshold = 1,
131 .tx_threshold_lo = 32, 131 .tx_threshold_lo = 32,
132 .tx_threshold_hi = 56, 132 .tx_threshold_hi = 56,
diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index eac3c960b2de..443f664534e1 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -94,6 +94,7 @@ struct ti_qspi {
94#define QSPI_FLEN(n) ((n - 1) << 0) 94#define QSPI_FLEN(n) ((n - 1) << 0)
95#define QSPI_WLEN_MAX_BITS 128 95#define QSPI_WLEN_MAX_BITS 128
96#define QSPI_WLEN_MAX_BYTES 16 96#define QSPI_WLEN_MAX_BYTES 16
97#define QSPI_WLEN_MASK QSPI_WLEN(QSPI_WLEN_MAX_BITS)
97 98
98/* STATUS REGISTER */ 99/* STATUS REGISTER */
99#define BUSY 0x01 100#define BUSY 0x01
@@ -235,16 +236,16 @@ static inline int ti_qspi_poll_wc(struct ti_qspi *qspi)
235 return -ETIMEDOUT; 236 return -ETIMEDOUT;
236} 237}
237 238
238static int qspi_write_msg(struct ti_qspi *qspi, struct spi_transfer *t) 239static int qspi_write_msg(struct ti_qspi *qspi, struct spi_transfer *t,
240 int count)
239{ 241{
240 int wlen, count, xfer_len; 242 int wlen, xfer_len;
241 unsigned int cmd; 243 unsigned int cmd;
242 const u8 *txbuf; 244 const u8 *txbuf;
243 u32 data; 245 u32 data;
244 246
245 txbuf = t->tx_buf; 247 txbuf = t->tx_buf;
246 cmd = qspi->cmd | QSPI_WR_SNGL; 248 cmd = qspi->cmd | QSPI_WR_SNGL;
247 count = t->len;
248 wlen = t->bits_per_word >> 3; /* in bytes */ 249 wlen = t->bits_per_word >> 3; /* in bytes */
249 xfer_len = wlen; 250 xfer_len = wlen;
250 251
@@ -304,9 +305,10 @@ static int qspi_write_msg(struct ti_qspi *qspi, struct spi_transfer *t)
304 return 0; 305 return 0;
305} 306}
306 307
307static int qspi_read_msg(struct ti_qspi *qspi, struct spi_transfer *t) 308static int qspi_read_msg(struct ti_qspi *qspi, struct spi_transfer *t,
309 int count)
308{ 310{
309 int wlen, count; 311 int wlen;
310 unsigned int cmd; 312 unsigned int cmd;
311 u8 *rxbuf; 313 u8 *rxbuf;
312 314
@@ -323,7 +325,6 @@ static int qspi_read_msg(struct ti_qspi *qspi, struct spi_transfer *t)
323 cmd |= QSPI_RD_SNGL; 325 cmd |= QSPI_RD_SNGL;
324 break; 326 break;
325 } 327 }
326 count = t->len;
327 wlen = t->bits_per_word >> 3; /* in bytes */ 328 wlen = t->bits_per_word >> 3; /* in bytes */
328 329
329 while (count) { 330 while (count) {
@@ -354,12 +355,13 @@ static int qspi_read_msg(struct ti_qspi *qspi, struct spi_transfer *t)
354 return 0; 355 return 0;
355} 356}
356 357
357static int qspi_transfer_msg(struct ti_qspi *qspi, struct spi_transfer *t) 358static int qspi_transfer_msg(struct ti_qspi *qspi, struct spi_transfer *t,
359 int count)
358{ 360{
359 int ret; 361 int ret;
360 362
361 if (t->tx_buf) { 363 if (t->tx_buf) {
362 ret = qspi_write_msg(qspi, t); 364 ret = qspi_write_msg(qspi, t, count);
363 if (ret) { 365 if (ret) {
364 dev_dbg(qspi->dev, "Error while writing\n"); 366 dev_dbg(qspi->dev, "Error while writing\n");
365 return ret; 367 return ret;
@@ -367,7 +369,7 @@ static int qspi_transfer_msg(struct ti_qspi *qspi, struct spi_transfer *t)
367 } 369 }
368 370
369 if (t->rx_buf) { 371 if (t->rx_buf) {
370 ret = qspi_read_msg(qspi, t); 372 ret = qspi_read_msg(qspi, t, count);
371 if (ret) { 373 if (ret) {
372 dev_dbg(qspi->dev, "Error while reading\n"); 374 dev_dbg(qspi->dev, "Error while reading\n");
373 return ret; 375 return ret;
@@ -450,7 +452,8 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
450 struct spi_device *spi = m->spi; 452 struct spi_device *spi = m->spi;
451 struct spi_transfer *t; 453 struct spi_transfer *t;
452 int status = 0, ret; 454 int status = 0, ret;
453 int frame_length; 455 unsigned int frame_len_words, transfer_len_words;
456 int wlen;
454 457
455 /* setup device control reg */ 458 /* setup device control reg */
456 qspi->dc = 0; 459 qspi->dc = 0;
@@ -462,14 +465,15 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
462 if (spi->mode & SPI_CS_HIGH) 465 if (spi->mode & SPI_CS_HIGH)
463 qspi->dc |= QSPI_CSPOL(spi->chip_select); 466 qspi->dc |= QSPI_CSPOL(spi->chip_select);
464 467
465 frame_length = (m->frame_length << 3) / spi->bits_per_word; 468 frame_len_words = 0;
466 469 list_for_each_entry(t, &m->transfers, transfer_list)
467 frame_length = clamp(frame_length, 0, QSPI_FRAME); 470 frame_len_words += t->len / (t->bits_per_word >> 3);
471 frame_len_words = min_t(unsigned int, frame_len_words, QSPI_FRAME);
468 472
469 /* setup command reg */ 473 /* setup command reg */
470 qspi->cmd = 0; 474 qspi->cmd = 0;
471 qspi->cmd |= QSPI_EN_CS(spi->chip_select); 475 qspi->cmd |= QSPI_EN_CS(spi->chip_select);
472 qspi->cmd |= QSPI_FLEN(frame_length); 476 qspi->cmd |= QSPI_FLEN(frame_len_words);
473 477
474 ti_qspi_write(qspi, qspi->dc, QSPI_SPI_DC_REG); 478 ti_qspi_write(qspi, qspi->dc, QSPI_SPI_DC_REG);
475 479
@@ -479,16 +483,23 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
479 ti_qspi_disable_memory_map(spi); 483 ti_qspi_disable_memory_map(spi);
480 484
481 list_for_each_entry(t, &m->transfers, transfer_list) { 485 list_for_each_entry(t, &m->transfers, transfer_list) {
482 qspi->cmd |= QSPI_WLEN(t->bits_per_word); 486 qspi->cmd = ((qspi->cmd & ~QSPI_WLEN_MASK) |
487 QSPI_WLEN(t->bits_per_word));
488
489 wlen = t->bits_per_word >> 3;
490 transfer_len_words = min(t->len / wlen, frame_len_words);
483 491
484 ret = qspi_transfer_msg(qspi, t); 492 ret = qspi_transfer_msg(qspi, t, transfer_len_words * wlen);
485 if (ret) { 493 if (ret) {
486 dev_dbg(qspi->dev, "transfer message failed\n"); 494 dev_dbg(qspi->dev, "transfer message failed\n");
487 mutex_unlock(&qspi->list_lock); 495 mutex_unlock(&qspi->list_lock);
488 return -EINVAL; 496 return -EINVAL;
489 } 497 }
490 498
491 m->actual_length += t->len; 499 m->actual_length += transfer_len_words * wlen;
500 frame_len_words -= transfer_len_words;
501 if (frame_len_words == 0)
502 break;
492 } 503 }
493 504
494 mutex_unlock(&qspi->list_lock); 505 mutex_unlock(&qspi->list_lock);
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index feef8a9c4de7..f02404052b7b 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -112,7 +112,6 @@ static int ecryptfs_readdir(struct file *file, struct dir_context *ctx)
112 .sb = inode->i_sb, 112 .sb = inode->i_sb,
113 }; 113 };
114 lower_file = ecryptfs_file_to_lower(file); 114 lower_file = ecryptfs_file_to_lower(file);
115 lower_file->f_pos = ctx->pos;
116 rc = iterate_dir(lower_file, &buf.ctx); 115 rc = iterate_dir(lower_file, &buf.ctx);
117 ctx->pos = buf.ctx.pos; 116 ctx->pos = buf.ctx.pos;
118 if (rc < 0) 117 if (rc < 0)
@@ -223,14 +222,6 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
223 } 222 }
224 ecryptfs_set_file_lower( 223 ecryptfs_set_file_lower(
225 file, ecryptfs_inode_to_private(inode)->lower_file); 224 file, ecryptfs_inode_to_private(inode)->lower_file);
226 if (d_is_dir(ecryptfs_dentry)) {
227 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
228 mutex_lock(&crypt_stat->cs_mutex);
229 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
230 mutex_unlock(&crypt_stat->cs_mutex);
231 rc = 0;
232 goto out;
233 }
234 rc = read_or_initialize_metadata(ecryptfs_dentry); 225 rc = read_or_initialize_metadata(ecryptfs_dentry);
235 if (rc) 226 if (rc)
236 goto out_put; 227 goto out_put;
@@ -247,6 +238,45 @@ out:
247 return rc; 238 return rc;
248} 239}
249 240
241/**
242 * ecryptfs_dir_open
243 * @inode: inode speciying file to open
244 * @file: Structure to return filled in
245 *
246 * Opens the file specified by inode.
247 *
248 * Returns zero on success; non-zero otherwise
249 */
250static int ecryptfs_dir_open(struct inode *inode, struct file *file)
251{
252 struct dentry *ecryptfs_dentry = file->f_path.dentry;
253 /* Private value of ecryptfs_dentry allocated in
254 * ecryptfs_lookup() */
255 struct ecryptfs_file_info *file_info;
256 struct file *lower_file;
257
258 /* Released in ecryptfs_release or end of function if failure */
259 file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL);
260 ecryptfs_set_file_private(file, file_info);
261 if (unlikely(!file_info)) {
262 ecryptfs_printk(KERN_ERR,
263 "Error attempting to allocate memory\n");
264 return -ENOMEM;
265 }
266 lower_file = dentry_open(ecryptfs_dentry_to_lower_path(ecryptfs_dentry),
267 file->f_flags, current_cred());
268 if (IS_ERR(lower_file)) {
269 printk(KERN_ERR "%s: Error attempting to initialize "
270 "the lower file for the dentry with name "
271 "[%pd]; rc = [%ld]\n", __func__,
272 ecryptfs_dentry, PTR_ERR(lower_file));
273 kmem_cache_free(ecryptfs_file_info_cache, file_info);
274 return PTR_ERR(lower_file);
275 }
276 ecryptfs_set_file_lower(file, lower_file);
277 return 0;
278}
279
250static int ecryptfs_flush(struct file *file, fl_owner_t td) 280static int ecryptfs_flush(struct file *file, fl_owner_t td)
251{ 281{
252 struct file *lower_file = ecryptfs_file_to_lower(file); 282 struct file *lower_file = ecryptfs_file_to_lower(file);
@@ -267,6 +297,19 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
267 return 0; 297 return 0;
268} 298}
269 299
300static int ecryptfs_dir_release(struct inode *inode, struct file *file)
301{
302 fput(ecryptfs_file_to_lower(file));
303 kmem_cache_free(ecryptfs_file_info_cache,
304 ecryptfs_file_to_private(file));
305 return 0;
306}
307
308static loff_t ecryptfs_dir_llseek(struct file *file, loff_t offset, int whence)
309{
310 return vfs_llseek(ecryptfs_file_to_lower(file), offset, whence);
311}
312
270static int 313static int
271ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync) 314ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
272{ 315{
@@ -346,20 +389,16 @@ const struct file_operations ecryptfs_dir_fops = {
346#ifdef CONFIG_COMPAT 389#ifdef CONFIG_COMPAT
347 .compat_ioctl = ecryptfs_compat_ioctl, 390 .compat_ioctl = ecryptfs_compat_ioctl,
348#endif 391#endif
349 .open = ecryptfs_open, 392 .open = ecryptfs_dir_open,
350 .flush = ecryptfs_flush, 393 .release = ecryptfs_dir_release,
351 .release = ecryptfs_release,
352 .fsync = ecryptfs_fsync, 394 .fsync = ecryptfs_fsync,
353 .fasync = ecryptfs_fasync, 395 .llseek = ecryptfs_dir_llseek,
354 .splice_read = generic_file_splice_read,
355 .llseek = default_llseek,
356}; 396};
357 397
358const struct file_operations ecryptfs_main_fops = { 398const struct file_operations ecryptfs_main_fops = {
359 .llseek = generic_file_llseek, 399 .llseek = generic_file_llseek,
360 .read_iter = ecryptfs_read_update_atime, 400 .read_iter = ecryptfs_read_update_atime,
361 .write_iter = generic_file_write_iter, 401 .write_iter = generic_file_write_iter,
362 .iterate = ecryptfs_readdir,
363 .unlocked_ioctl = ecryptfs_unlocked_ioctl, 402 .unlocked_ioctl = ecryptfs_unlocked_ioctl,
364#ifdef CONFIG_COMPAT 403#ifdef CONFIG_COMPAT
365 .compat_ioctl = ecryptfs_compat_ioctl, 404 .compat_ioctl = ecryptfs_compat_ioctl,
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 5384ceb35b1c..98b3eb7d8eaf 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -203,6 +203,8 @@ int get_rock_ridge_filename(struct iso_directory_record *de,
203 int retnamlen = 0; 203 int retnamlen = 0;
204 int truncate = 0; 204 int truncate = 0;
205 int ret = 0; 205 int ret = 0;
206 char *p;
207 int len;
206 208
207 if (!ISOFS_SB(inode->i_sb)->s_rock) 209 if (!ISOFS_SB(inode->i_sb)->s_rock)
208 return 0; 210 return 0;
@@ -267,12 +269,17 @@ repeat:
267 rr->u.NM.flags); 269 rr->u.NM.flags);
268 break; 270 break;
269 } 271 }
270 if ((strlen(retname) + rr->len - 5) >= 254) { 272 len = rr->len - 5;
273 if (retnamlen + len >= 254) {
271 truncate = 1; 274 truncate = 1;
272 break; 275 break;
273 } 276 }
274 strncat(retname, rr->u.NM.name, rr->len - 5); 277 p = memchr(rr->u.NM.name, '\0', len);
275 retnamlen += rr->len - 5; 278 if (unlikely(p))
279 len = p - rr->u.NM.name;
280 memcpy(retname + retnamlen, rr->u.NM.name, len);
281 retnamlen += len;
282 retname[retnamlen] = '\0';
276 break; 283 break;
277 case SIG('R', 'E'): 284 case SIG('R', 'E'):
278 kfree(rs.buffer); 285 kfree(rs.buffer);
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 03b688d19f69..37f9678ae4df 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -153,9 +153,9 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to,
153 p = buf + len + nlen; 153 p = buf + len + nlen;
154 *p = '\0'; 154 *p = '\0';
155 for (kn = kn_to; kn != common; kn = kn->parent) { 155 for (kn = kn_to; kn != common; kn = kn->parent) {
156 nlen = strlen(kn->name); 156 size_t tmp = strlen(kn->name);
157 p -= nlen; 157 p -= tmp;
158 memcpy(p, kn->name, nlen); 158 memcpy(p, kn->name, tmp);
159 *(--p) = '/'; 159 *(--p) = '/';
160 } 160 }
161 161
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index f73541fbe7af..3d670a3678f2 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -15,6 +15,7 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/pagemap.h> 16#include <linux/pagemap.h>
17#include <linux/namei.h> 17#include <linux/namei.h>
18#include <linux/seq_file.h>
18 19
19#include "kernfs-internal.h" 20#include "kernfs-internal.h"
20 21
@@ -40,6 +41,19 @@ static int kernfs_sop_show_options(struct seq_file *sf, struct dentry *dentry)
40 return 0; 41 return 0;
41} 42}
42 43
44static int kernfs_sop_show_path(struct seq_file *sf, struct dentry *dentry)
45{
46 struct kernfs_node *node = dentry->d_fsdata;
47 struct kernfs_root *root = kernfs_root(node);
48 struct kernfs_syscall_ops *scops = root->syscall_ops;
49
50 if (scops && scops->show_path)
51 return scops->show_path(sf, node, root);
52
53 seq_dentry(sf, dentry, " \t\n\\");
54 return 0;
55}
56
43const struct super_operations kernfs_sops = { 57const struct super_operations kernfs_sops = {
44 .statfs = simple_statfs, 58 .statfs = simple_statfs,
45 .drop_inode = generic_delete_inode, 59 .drop_inode = generic_delete_inode,
@@ -47,6 +61,7 @@ const struct super_operations kernfs_sops = {
47 61
48 .remount_fs = kernfs_sop_remount_fs, 62 .remount_fs = kernfs_sop_remount_fs,
49 .show_options = kernfs_sop_show_options, 63 .show_options = kernfs_sop_show_options,
64 .show_path = kernfs_sop_show_path,
50}; 65};
51 66
52/** 67/**
diff --git a/fs/namei.c b/fs/namei.c
index 1d9ca2d5dff6..30145f8f21ed 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2267,6 +2267,33 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
2267EXPORT_SYMBOL(vfs_path_lookup); 2267EXPORT_SYMBOL(vfs_path_lookup);
2268 2268
2269/** 2269/**
2270 * lookup_hash - lookup single pathname component on already hashed name
2271 * @name: name and hash to lookup
2272 * @base: base directory to lookup from
2273 *
2274 * The name must have been verified and hashed (see lookup_one_len()). Using
2275 * this after just full_name_hash() is unsafe.
2276 *
2277 * This function also doesn't check for search permission on base directory.
2278 *
2279 * Use lookup_one_len_unlocked() instead, unless you really know what you are
2280 * doing.
2281 *
2282 * Do not hold i_mutex; this helper takes i_mutex if necessary.
2283 */
2284struct dentry *lookup_hash(const struct qstr *name, struct dentry *base)
2285{
2286 struct dentry *ret;
2287
2288 ret = lookup_dcache(name, base, 0);
2289 if (!ret)
2290 ret = lookup_slow(name, base, 0);
2291
2292 return ret;
2293}
2294EXPORT_SYMBOL(lookup_hash);
2295
2296/**
2270 * lookup_one_len - filesystem helper to lookup single pathname component 2297 * lookup_one_len - filesystem helper to lookup single pathname component
2271 * @name: pathname component to lookup 2298 * @name: pathname component to lookup
2272 * @base: base directory to lookup from 2299 * @base: base directory to lookup from
@@ -2337,7 +2364,6 @@ struct dentry *lookup_one_len_unlocked(const char *name,
2337 struct qstr this; 2364 struct qstr this;
2338 unsigned int c; 2365 unsigned int c;
2339 int err; 2366 int err;
2340 struct dentry *ret;
2341 2367
2342 this.name = name; 2368 this.name = name;
2343 this.len = len; 2369 this.len = len;
@@ -2369,10 +2395,7 @@ struct dentry *lookup_one_len_unlocked(const char *name,
2369 if (err) 2395 if (err)
2370 return ERR_PTR(err); 2396 return ERR_PTR(err);
2371 2397
2372 ret = lookup_dcache(&this, base, 0); 2398 return lookup_hash(&this, base);
2373 if (!ret)
2374 ret = lookup_slow(&this, base, 0);
2375 return ret;
2376} 2399}
2377EXPORT_SYMBOL(lookup_one_len_unlocked); 2400EXPORT_SYMBOL(lookup_one_len_unlocked);
2378 2401
@@ -2942,22 +2965,10 @@ no_open:
2942 dentry = lookup_real(dir, dentry, nd->flags); 2965 dentry = lookup_real(dir, dentry, nd->flags);
2943 if (IS_ERR(dentry)) 2966 if (IS_ERR(dentry))
2944 return PTR_ERR(dentry); 2967 return PTR_ERR(dentry);
2945 2968 }
2946 if (create_error) { 2969 if (create_error && !dentry->d_inode) {
2947 int open_flag = op->open_flag; 2970 error = create_error;
2948 2971 goto out;
2949 error = create_error;
2950 if ((open_flag & O_EXCL)) {
2951 if (!dentry->d_inode)
2952 goto out;
2953 } else if (!dentry->d_inode) {
2954 goto out;
2955 } else if ((open_flag & O_TRUNC) &&
2956 d_is_reg(dentry)) {
2957 goto out;
2958 }
2959 /* will fail later, go on to get the right error */
2960 }
2961 } 2972 }
2962looked_up: 2973looked_up:
2963 path->dentry = dentry; 2974 path->dentry = dentry;
@@ -4213,7 +4224,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4213 bool new_is_dir = false; 4224 bool new_is_dir = false;
4214 unsigned max_links = new_dir->i_sb->s_max_links; 4225 unsigned max_links = new_dir->i_sb->s_max_links;
4215 4226
4216 if (source == target) 4227 /*
4228 * Check source == target.
4229 * On overlayfs need to look at underlying inodes.
4230 */
4231 if (vfs_select_inode(old_dentry, 0) == vfs_select_inode(new_dentry, 0))
4217 return 0; 4232 return 0;
4218 4233
4219 error = may_delete(old_dir, old_dentry, is_dir); 4234 error = may_delete(old_dir, old_dentry, is_dir);
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 0cdf497c91ef..2162434728c0 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -322,3 +322,90 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
322 brelse(di_bh); 322 brelse(di_bh);
323 return acl; 323 return acl;
324} 324}
325
326int ocfs2_acl_chmod(struct inode *inode, struct buffer_head *bh)
327{
328 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
329 struct posix_acl *acl;
330 int ret;
331
332 if (S_ISLNK(inode->i_mode))
333 return -EOPNOTSUPP;
334
335 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
336 return 0;
337
338 acl = ocfs2_get_acl_nolock(inode, ACL_TYPE_ACCESS, bh);
339 if (IS_ERR(acl) || !acl)
340 return PTR_ERR(acl);
341 ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
342 if (ret)
343 return ret;
344 ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
345 acl, NULL, NULL);
346 posix_acl_release(acl);
347 return ret;
348}
349
350/*
351 * Initialize the ACLs of a new inode. If parent directory has default ACL,
352 * then clone to new inode. Called from ocfs2_mknod.
353 */
354int ocfs2_init_acl(handle_t *handle,
355 struct inode *inode,
356 struct inode *dir,
357 struct buffer_head *di_bh,
358 struct buffer_head *dir_bh,
359 struct ocfs2_alloc_context *meta_ac,
360 struct ocfs2_alloc_context *data_ac)
361{
362 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
363 struct posix_acl *acl = NULL;
364 int ret = 0, ret2;
365 umode_t mode;
366
367 if (!S_ISLNK(inode->i_mode)) {
368 if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
369 acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT,
370 dir_bh);
371 if (IS_ERR(acl))
372 return PTR_ERR(acl);
373 }
374 if (!acl) {
375 mode = inode->i_mode & ~current_umask();
376 ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
377 if (ret) {
378 mlog_errno(ret);
379 goto cleanup;
380 }
381 }
382 }
383 if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
384 if (S_ISDIR(inode->i_mode)) {
385 ret = ocfs2_set_acl(handle, inode, di_bh,
386 ACL_TYPE_DEFAULT, acl,
387 meta_ac, data_ac);
388 if (ret)
389 goto cleanup;
390 }
391 mode = inode->i_mode;
392 ret = __posix_acl_create(&acl, GFP_NOFS, &mode);
393 if (ret < 0)
394 return ret;
395
396 ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
397 if (ret2) {
398 mlog_errno(ret2);
399 ret = ret2;
400 goto cleanup;
401 }
402 if (ret > 0) {
403 ret = ocfs2_set_acl(handle, inode,
404 di_bh, ACL_TYPE_ACCESS,
405 acl, meta_ac, data_ac);
406 }
407 }
408cleanup:
409 posix_acl_release(acl);
410 return ret;
411}
diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h
index 3fce68d08625..2783a75b3999 100644
--- a/fs/ocfs2/acl.h
+++ b/fs/ocfs2/acl.h
@@ -35,5 +35,10 @@ int ocfs2_set_acl(handle_t *handle,
35 struct posix_acl *acl, 35 struct posix_acl *acl,
36 struct ocfs2_alloc_context *meta_ac, 36 struct ocfs2_alloc_context *meta_ac,
37 struct ocfs2_alloc_context *data_ac); 37 struct ocfs2_alloc_context *data_ac);
38extern int ocfs2_acl_chmod(struct inode *, struct buffer_head *);
39extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
40 struct buffer_head *, struct buffer_head *,
41 struct ocfs2_alloc_context *,
42 struct ocfs2_alloc_context *);
38 43
39#endif /* OCFS2_ACL_H */ 44#endif /* OCFS2_ACL_H */
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 5308841756be..59cce53c91d8 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1268,20 +1268,20 @@ bail_unlock_rw:
1268 if (size_change) 1268 if (size_change)
1269 ocfs2_rw_unlock(inode, 1); 1269 ocfs2_rw_unlock(inode, 1);
1270bail: 1270bail:
1271 brelse(bh);
1272 1271
1273 /* Release quota pointers in case we acquired them */ 1272 /* Release quota pointers in case we acquired them */
1274 for (qtype = 0; qtype < OCFS2_MAXQUOTAS; qtype++) 1273 for (qtype = 0; qtype < OCFS2_MAXQUOTAS; qtype++)
1275 dqput(transfer_to[qtype]); 1274 dqput(transfer_to[qtype]);
1276 1275
1277 if (!status && attr->ia_valid & ATTR_MODE) { 1276 if (!status && attr->ia_valid & ATTR_MODE) {
1278 status = posix_acl_chmod(inode, inode->i_mode); 1277 status = ocfs2_acl_chmod(inode, bh);
1279 if (status < 0) 1278 if (status < 0)
1280 mlog_errno(status); 1279 mlog_errno(status);
1281 } 1280 }
1282 if (inode_locked) 1281 if (inode_locked)
1283 ocfs2_inode_unlock(inode, 1); 1282 ocfs2_inode_unlock(inode, 1);
1284 1283
1284 brelse(bh);
1285 return status; 1285 return status;
1286} 1286}
1287 1287
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 6b3e87189a64..a8f1225e6d9b 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -259,7 +259,6 @@ static int ocfs2_mknod(struct inode *dir,
259 struct ocfs2_dir_lookup_result lookup = { NULL, }; 259 struct ocfs2_dir_lookup_result lookup = { NULL, };
260 sigset_t oldset; 260 sigset_t oldset;
261 int did_block_signals = 0; 261 int did_block_signals = 0;
262 struct posix_acl *default_acl = NULL, *acl = NULL;
263 struct ocfs2_dentry_lock *dl = NULL; 262 struct ocfs2_dentry_lock *dl = NULL;
264 263
265 trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, 264 trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name,
@@ -367,12 +366,6 @@ static int ocfs2_mknod(struct inode *dir,
367 goto leave; 366 goto leave;
368 } 367 }
369 368
370 status = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
371 if (status) {
372 mlog_errno(status);
373 goto leave;
374 }
375
376 handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, 369 handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb,
377 S_ISDIR(mode), 370 S_ISDIR(mode),
378 xattr_credits)); 371 xattr_credits));
@@ -421,16 +414,8 @@ static int ocfs2_mknod(struct inode *dir,
421 inc_nlink(dir); 414 inc_nlink(dir);
422 } 415 }
423 416
424 if (default_acl) { 417 status = ocfs2_init_acl(handle, inode, dir, new_fe_bh, parent_fe_bh,
425 status = ocfs2_set_acl(handle, inode, new_fe_bh, 418 meta_ac, data_ac);
426 ACL_TYPE_DEFAULT, default_acl,
427 meta_ac, data_ac);
428 }
429 if (!status && acl) {
430 status = ocfs2_set_acl(handle, inode, new_fe_bh,
431 ACL_TYPE_ACCESS, acl,
432 meta_ac, data_ac);
433 }
434 419
435 if (status < 0) { 420 if (status < 0) {
436 mlog_errno(status); 421 mlog_errno(status);
@@ -472,10 +457,6 @@ static int ocfs2_mknod(struct inode *dir,
472 d_instantiate(dentry, inode); 457 d_instantiate(dentry, inode);
473 status = 0; 458 status = 0;
474leave: 459leave:
475 if (default_acl)
476 posix_acl_release(default_acl);
477 if (acl)
478 posix_acl_release(acl);
479 if (status < 0 && did_quota_inode) 460 if (status < 0 && did_quota_inode)
480 dquot_free_inode(inode); 461 dquot_free_inode(inode);
481 if (handle) 462 if (handle)
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 744d5d90c363..92bbe93bfe10 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -4248,20 +4248,12 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
4248 struct inode *inode = d_inode(old_dentry); 4248 struct inode *inode = d_inode(old_dentry);
4249 struct buffer_head *old_bh = NULL; 4249 struct buffer_head *old_bh = NULL;
4250 struct inode *new_orphan_inode = NULL; 4250 struct inode *new_orphan_inode = NULL;
4251 struct posix_acl *default_acl, *acl;
4252 umode_t mode;
4253 4251
4254 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) 4252 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)))
4255 return -EOPNOTSUPP; 4253 return -EOPNOTSUPP;
4256 4254
4257 mode = inode->i_mode;
4258 error = posix_acl_create(dir, &mode, &default_acl, &acl);
4259 if (error) {
4260 mlog_errno(error);
4261 return error;
4262 }
4263 4255
4264 error = ocfs2_create_inode_in_orphan(dir, mode, 4256 error = ocfs2_create_inode_in_orphan(dir, inode->i_mode,
4265 &new_orphan_inode); 4257 &new_orphan_inode);
4266 if (error) { 4258 if (error) {
4267 mlog_errno(error); 4259 mlog_errno(error);
@@ -4300,16 +4292,11 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
4300 /* If the security isn't preserved, we need to re-initialize them. */ 4292 /* If the security isn't preserved, we need to re-initialize them. */
4301 if (!preserve) { 4293 if (!preserve) {
4302 error = ocfs2_init_security_and_acl(dir, new_orphan_inode, 4294 error = ocfs2_init_security_and_acl(dir, new_orphan_inode,
4303 &new_dentry->d_name, 4295 &new_dentry->d_name);
4304 default_acl, acl);
4305 if (error) 4296 if (error)
4306 mlog_errno(error); 4297 mlog_errno(error);
4307 } 4298 }
4308out: 4299out:
4309 if (default_acl)
4310 posix_acl_release(default_acl);
4311 if (acl)
4312 posix_acl_release(acl);
4313 if (!error) { 4300 if (!error) {
4314 error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode, 4301 error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode,
4315 new_dentry); 4302 new_dentry);
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 7d3d979f57d9..f19b7381a998 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -7216,12 +7216,10 @@ out:
7216 */ 7216 */
7217int ocfs2_init_security_and_acl(struct inode *dir, 7217int ocfs2_init_security_and_acl(struct inode *dir,
7218 struct inode *inode, 7218 struct inode *inode,
7219 const struct qstr *qstr, 7219 const struct qstr *qstr)
7220 struct posix_acl *default_acl,
7221 struct posix_acl *acl)
7222{ 7220{
7223 struct buffer_head *dir_bh = NULL;
7224 int ret = 0; 7221 int ret = 0;
7222 struct buffer_head *dir_bh = NULL;
7225 7223
7226 ret = ocfs2_init_security_get(inode, dir, qstr, NULL); 7224 ret = ocfs2_init_security_get(inode, dir, qstr, NULL);
7227 if (ret) { 7225 if (ret) {
@@ -7234,11 +7232,9 @@ int ocfs2_init_security_and_acl(struct inode *dir,
7234 mlog_errno(ret); 7232 mlog_errno(ret);
7235 goto leave; 7233 goto leave;
7236 } 7234 }
7237 7235 ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL);
7238 if (!ret && default_acl) 7236 if (ret)
7239 ret = ocfs2_iop_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 7237 mlog_errno(ret);
7240 if (!ret && acl)
7241 ret = ocfs2_iop_set_acl(inode, acl, ACL_TYPE_ACCESS);
7242 7238
7243 ocfs2_inode_unlock(dir, 0); 7239 ocfs2_inode_unlock(dir, 0);
7244 brelse(dir_bh); 7240 brelse(dir_bh);
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index f10d5b93c366..1633cc15ea1f 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -94,7 +94,5 @@ int ocfs2_reflink_xattrs(struct inode *old_inode,
94 bool preserve_security); 94 bool preserve_security);
95int ocfs2_init_security_and_acl(struct inode *dir, 95int ocfs2_init_security_and_acl(struct inode *dir,
96 struct inode *inode, 96 struct inode *inode,
97 const struct qstr *qstr, 97 const struct qstr *qstr);
98 struct posix_acl *default_acl,
99 struct posix_acl *acl);
100#endif /* OCFS2_XATTR_H */ 98#endif /* OCFS2_XATTR_H */
diff --git a/fs/open.c b/fs/open.c
index 17cb6b1dab75..081d3d6df74b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -840,16 +840,12 @@ EXPORT_SYMBOL(file_path);
840int vfs_open(const struct path *path, struct file *file, 840int vfs_open(const struct path *path, struct file *file,
841 const struct cred *cred) 841 const struct cred *cred)
842{ 842{
843 struct dentry *dentry = path->dentry; 843 struct inode *inode = vfs_select_inode(path->dentry, file->f_flags);
844 struct inode *inode = dentry->d_inode;
845 844
846 file->f_path = *path; 845 if (IS_ERR(inode))
847 if (dentry->d_flags & DCACHE_OP_SELECT_INODE) { 846 return PTR_ERR(inode);
848 inode = dentry->d_op->d_select_inode(dentry, file->f_flags);
849 if (IS_ERR(inode))
850 return PTR_ERR(inode);
851 }
852 847
848 file->f_path = *path;
853 return do_dentry_open(file, inode, NULL, cred); 849 return do_dentry_open(file, inode, NULL, cred);
854} 850}
855 851
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5d972e6cd3fe..791235e03d17 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -411,9 +411,7 @@ static inline struct dentry *ovl_lookup_real(struct dentry *dir,
411{ 411{
412 struct dentry *dentry; 412 struct dentry *dentry;
413 413
414 inode_lock(dir->d_inode); 414 dentry = lookup_hash(name, dir);
415 dentry = lookup_one_len(name->name, dir, name->len);
416 inode_unlock(dir->d_inode);
417 415
418 if (IS_ERR(dentry)) { 416 if (IS_ERR(dentry)) {
419 if (PTR_ERR(dentry) == -ENOENT) 417 if (PTR_ERR(dentry) == -ENOENT)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 92e37e224cd2..0d163a84082d 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -434,7 +434,7 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
434 && !lookup_symbol_name(wchan, symname)) 434 && !lookup_symbol_name(wchan, symname))
435 seq_printf(m, "%s", symname); 435 seq_printf(m, "%s", symname);
436 else 436 else
437 seq_puts(m, "0\n"); 437 seq_putc(m, '0');
438 438
439 return 0; 439 return 0;
440} 440}
diff --git a/fs/splice.c b/fs/splice.c
index b018eb485019..dd9bf7e410d2 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1143,6 +1143,9 @@ static long do_splice_to(struct file *in, loff_t *ppos,
1143 if (unlikely(ret < 0)) 1143 if (unlikely(ret < 0))
1144 return ret; 1144 return ret;
1145 1145
1146 if (unlikely(len > MAX_RW_COUNT))
1147 len = MAX_RW_COUNT;
1148
1146 if (in->f_op->splice_read) 1149 if (in->f_op->splice_read)
1147 splice_read = in->f_op->splice_read; 1150 splice_read = in->f_op->splice_read;
1148 else 1151 else
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index eeae401a2412..3d5202eda22f 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -246,7 +246,7 @@
246#define __HAVE_BUILTIN_BSWAP32__ 246#define __HAVE_BUILTIN_BSWAP32__
247#define __HAVE_BUILTIN_BSWAP64__ 247#define __HAVE_BUILTIN_BSWAP64__
248#endif 248#endif
249#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600) 249#if GCC_VERSION >= 40800
250#define __HAVE_BUILTIN_BSWAP16__ 250#define __HAVE_BUILTIN_BSWAP16__
251#endif 251#endif
252#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ 252#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 4bb4de8d95ea..7e9422cb5989 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -565,4 +565,16 @@ static inline struct dentry *d_real(struct dentry *dentry)
565 return dentry; 565 return dentry;
566} 566}
567 567
568static inline struct inode *vfs_select_inode(struct dentry *dentry,
569 unsigned open_flags)
570{
571 struct inode *inode = d_inode(dentry);
572
573 if (inode && unlikely(dentry->d_flags & DCACHE_OP_SELECT_INODE))
574 inode = dentry->d_op->d_select_inode(dentry, open_flags);
575
576 return inode;
577}
578
579
568#endif /* __LINUX_DCACHE_H */ 580#endif /* __LINUX_DCACHE_H */
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index c06c44242f39..30f089ebe0a4 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -152,6 +152,8 @@ struct kernfs_syscall_ops {
152 int (*rmdir)(struct kernfs_node *kn); 152 int (*rmdir)(struct kernfs_node *kn);
153 int (*rename)(struct kernfs_node *kn, struct kernfs_node *new_parent, 153 int (*rename)(struct kernfs_node *kn, struct kernfs_node *new_parent,
154 const char *new_name); 154 const char *new_name);
155 int (*show_path)(struct seq_file *sf, struct kernfs_node *kn,
156 struct kernfs_root *root);
155}; 157};
156 158
157struct kernfs_root { 159struct kernfs_root {
diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h
index b288965e8101..2c14eeca46f0 100644
--- a/include/linux/mfd/samsung/s2mps11.h
+++ b/include/linux/mfd/samsung/s2mps11.h
@@ -173,10 +173,12 @@ enum s2mps11_regulators {
173 173
174#define S2MPS11_LDO_VSEL_MASK 0x3F 174#define S2MPS11_LDO_VSEL_MASK 0x3F
175#define S2MPS11_BUCK_VSEL_MASK 0xFF 175#define S2MPS11_BUCK_VSEL_MASK 0xFF
176#define S2MPS11_BUCK9_VSEL_MASK 0x1F
176#define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT) 177#define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT)
177#define S2MPS11_ENABLE_SHIFT 0x06 178#define S2MPS11_ENABLE_SHIFT 0x06
178#define S2MPS11_LDO_N_VOLTAGES (S2MPS11_LDO_VSEL_MASK + 1) 179#define S2MPS11_LDO_N_VOLTAGES (S2MPS11_LDO_VSEL_MASK + 1)
179#define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1) 180#define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1)
181#define S2MPS11_BUCK9_N_VOLTAGES (S2MPS11_BUCK9_VSEL_MASK + 1)
180#define S2MPS11_RAMP_DELAY 25000 /* uV/us */ 182#define S2MPS11_RAMP_DELAY 25000 /* uV/us */
181 183
182#define S2MPS11_CTRL1_PWRHOLD_MASK BIT(4) 184#define S2MPS11_CTRL1_PWRHOLD_MASK BIT(4)
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 8f9fc3d26e6d..8e95cd87cd74 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -134,6 +134,7 @@
134#define TWL6040_HFDACENA (1 << 0) 134#define TWL6040_HFDACENA (1 << 0)
135#define TWL6040_HFPGAENA (1 << 1) 135#define TWL6040_HFPGAENA (1 << 1)
136#define TWL6040_HFDRVENA (1 << 4) 136#define TWL6040_HFDRVENA (1 << 4)
137#define TWL6040_HFSWENA (1 << 6)
137 138
138/* VIBCTLL/R (0x18/0x1A) fields */ 139/* VIBCTLL/R (0x18/0x1A) fields */
139 140
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 864d7221de84..8f468e0d2534 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -500,11 +500,20 @@ static inline int page_mapcount(struct page *page)
500 500
501#ifdef CONFIG_TRANSPARENT_HUGEPAGE 501#ifdef CONFIG_TRANSPARENT_HUGEPAGE
502int total_mapcount(struct page *page); 502int total_mapcount(struct page *page);
503int page_trans_huge_mapcount(struct page *page, int *total_mapcount);
503#else 504#else
504static inline int total_mapcount(struct page *page) 505static inline int total_mapcount(struct page *page)
505{ 506{
506 return page_mapcount(page); 507 return page_mapcount(page);
507} 508}
509static inline int page_trans_huge_mapcount(struct page *page,
510 int *total_mapcount)
511{
512 int mapcount = page_mapcount(page);
513 if (total_mapcount)
514 *total_mapcount = mapcount;
515 return mapcount;
516}
508#endif 517#endif
509 518
510static inline struct page *virt_to_head_page(const void *x) 519static inline struct page *virt_to_head_page(const void *x)
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 77d01700daf7..ec5ec2818a28 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -79,6 +79,8 @@ extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int);
79 79
80extern struct dentry *lookup_one_len(const char *, struct dentry *, int); 80extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
81extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int); 81extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
82struct qstr;
83extern struct dentry *lookup_hash(const struct qstr *, struct dentry *);
82 84
83extern int follow_down_one(struct path *); 85extern int follow_down_one(struct path *);
84extern int follow_down(struct path *); 86extern int follow_down(struct path *);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b3c46b019ac1..78181a88903b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2164,6 +2164,9 @@ struct packet_offload {
2164 2164
2165struct udp_offload; 2165struct udp_offload;
2166 2166
2167/* 'skb->encapsulation' is set before gro_complete() is called. gro_complete()
2168 * must set 'skb->inner_mac_header' to the beginning of tunnel payload.
2169 */
2167struct udp_offload_callbacks { 2170struct udp_offload_callbacks {
2168 struct sk_buff **(*gro_receive)(struct sk_buff **head, 2171 struct sk_buff **(*gro_receive)(struct sk_buff **head,
2169 struct sk_buff *skb, 2172 struct sk_buff *skb,
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 0a4cd4703f40..ad220359f1b0 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -418,7 +418,7 @@ extern sector_t swapdev_block(int, pgoff_t);
418extern int page_swapcount(struct page *); 418extern int page_swapcount(struct page *);
419extern int swp_swapcount(swp_entry_t entry); 419extern int swp_swapcount(swp_entry_t entry);
420extern struct swap_info_struct *page_swap_info(struct page *); 420extern struct swap_info_struct *page_swap_info(struct page *);
421extern int reuse_swap_page(struct page *); 421extern bool reuse_swap_page(struct page *, int *);
422extern int try_to_free_swap(struct page *); 422extern int try_to_free_swap(struct page *);
423struct backing_dev_info; 423struct backing_dev_info;
424 424
@@ -513,8 +513,8 @@ static inline int swp_swapcount(swp_entry_t entry)
513 return 0; 513 return 0;
514} 514}
515 515
516#define reuse_swap_page(page) \ 516#define reuse_swap_page(page, total_mapcount) \
517 (!PageTransCompound(page) && page_mapcount(page) == 1) 517 (page_trans_huge_mapcount(page, total_mapcount) == 1)
518 518
519static inline int try_to_free_swap(struct page *page) 519static inline int try_to_free_swap(struct page *page)
520{ 520{
diff --git a/include/linux/uio.h b/include/linux/uio.h
index fd9bcfedad42..1b5d1cd796e2 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -87,6 +87,7 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i);
87size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i); 87size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i);
88size_t iov_iter_zero(size_t bytes, struct iov_iter *); 88size_t iov_iter_zero(size_t bytes, struct iov_iter *);
89unsigned long iov_iter_alignment(const struct iov_iter *i); 89unsigned long iov_iter_alignment(const struct iov_iter *i);
90unsigned long iov_iter_gap_alignment(const struct iov_iter *i);
90void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov, 91void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov,
91 unsigned long nr_segs, size_t count); 92 unsigned long nr_segs, size_t count);
92void iov_iter_kvec(struct iov_iter *i, int direction, const struct kvec *kvec, 93void iov_iter_kvec(struct iov_iter *i, int direction, const struct kvec *kvec,
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
index 730d82ad6ee5..24cd3949a9a4 100644
--- a/include/net/netns/xfrm.h
+++ b/include/net/netns/xfrm.h
@@ -80,6 +80,7 @@ struct netns_xfrm {
80 struct flow_cache flow_cache_global; 80 struct flow_cache flow_cache_global;
81 atomic_t flow_cache_genid; 81 atomic_t flow_cache_genid;
82 struct list_head flow_cache_gc_list; 82 struct list_head flow_cache_gc_list;
83 atomic_t flow_cache_gc_count;
83 spinlock_t flow_cache_gc_lock; 84 spinlock_t flow_cache_gc_lock;
84 struct work_struct flow_cache_gc_work; 85 struct work_struct flow_cache_gc_work;
85 struct work_struct flow_cache_flush_work; 86 struct work_struct flow_cache_flush_work;
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index b83114077cee..a1140249ec25 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -106,15 +106,6 @@ static inline struct sk_buff *udp_tunnel_handle_offloads(struct sk_buff *skb,
106 return iptunnel_handle_offloads(skb, type); 106 return iptunnel_handle_offloads(skb, type);
107} 107}
108 108
109static inline void udp_tunnel_gro_complete(struct sk_buff *skb, int nhoff)
110{
111 struct udphdr *uh;
112
113 uh = (struct udphdr *)(skb->data + nhoff - sizeof(struct udphdr));
114 skb_shinfo(skb)->gso_type |= uh->check ?
115 SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
116}
117
118static inline void udp_tunnel_encap_enable(struct socket *sock) 109static inline void udp_tunnel_encap_enable(struct socket *sock)
119{ 110{
120#if IS_ENABLED(CONFIG_IPV6) 111#if IS_ENABLED(CONFIG_IPV6)
diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
index f80277569f24..e601c8c3bdc7 100644
--- a/include/uapi/linux/if.h
+++ b/include/uapi/linux/if.h
@@ -19,14 +19,20 @@
19#ifndef _LINUX_IF_H 19#ifndef _LINUX_IF_H
20#define _LINUX_IF_H 20#define _LINUX_IF_H
21 21
22#include <linux/libc-compat.h> /* for compatibility with glibc */
22#include <linux/types.h> /* for "__kernel_caddr_t" et al */ 23#include <linux/types.h> /* for "__kernel_caddr_t" et al */
23#include <linux/socket.h> /* for "struct sockaddr" et al */ 24#include <linux/socket.h> /* for "struct sockaddr" et al */
24#include <linux/compiler.h> /* for "__user" et al */ 25#include <linux/compiler.h> /* for "__user" et al */
25 26
27#if __UAPI_DEF_IF_IFNAMSIZ
26#define IFNAMSIZ 16 28#define IFNAMSIZ 16
29#endif /* __UAPI_DEF_IF_IFNAMSIZ */
27#define IFALIASZ 256 30#define IFALIASZ 256
28#include <linux/hdlc/ioctl.h> 31#include <linux/hdlc/ioctl.h>
29 32
33/* For glibc compatibility. An empty enum does not compile. */
34#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && \
35 __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
30/** 36/**
31 * enum net_device_flags - &struct net_device flags 37 * enum net_device_flags - &struct net_device flags
32 * 38 *
@@ -68,6 +74,8 @@
68 * @IFF_ECHO: echo sent packets. Volatile. 74 * @IFF_ECHO: echo sent packets. Volatile.
69 */ 75 */
70enum net_device_flags { 76enum net_device_flags {
77/* for compatibility with glibc net/if.h */
78#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
71 IFF_UP = 1<<0, /* sysfs */ 79 IFF_UP = 1<<0, /* sysfs */
72 IFF_BROADCAST = 1<<1, /* volatile */ 80 IFF_BROADCAST = 1<<1, /* volatile */
73 IFF_DEBUG = 1<<2, /* sysfs */ 81 IFF_DEBUG = 1<<2, /* sysfs */
@@ -84,11 +92,17 @@ enum net_device_flags {
84 IFF_PORTSEL = 1<<13, /* sysfs */ 92 IFF_PORTSEL = 1<<13, /* sysfs */
85 IFF_AUTOMEDIA = 1<<14, /* sysfs */ 93 IFF_AUTOMEDIA = 1<<14, /* sysfs */
86 IFF_DYNAMIC = 1<<15, /* sysfs */ 94 IFF_DYNAMIC = 1<<15, /* sysfs */
95#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
96#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
87 IFF_LOWER_UP = 1<<16, /* volatile */ 97 IFF_LOWER_UP = 1<<16, /* volatile */
88 IFF_DORMANT = 1<<17, /* volatile */ 98 IFF_DORMANT = 1<<17, /* volatile */
89 IFF_ECHO = 1<<18, /* volatile */ 99 IFF_ECHO = 1<<18, /* volatile */
100#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
90}; 101};
102#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */
91 103
104/* for compatibility with glibc net/if.h */
105#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
92#define IFF_UP IFF_UP 106#define IFF_UP IFF_UP
93#define IFF_BROADCAST IFF_BROADCAST 107#define IFF_BROADCAST IFF_BROADCAST
94#define IFF_DEBUG IFF_DEBUG 108#define IFF_DEBUG IFF_DEBUG
@@ -105,9 +119,13 @@ enum net_device_flags {
105#define IFF_PORTSEL IFF_PORTSEL 119#define IFF_PORTSEL IFF_PORTSEL
106#define IFF_AUTOMEDIA IFF_AUTOMEDIA 120#define IFF_AUTOMEDIA IFF_AUTOMEDIA
107#define IFF_DYNAMIC IFF_DYNAMIC 121#define IFF_DYNAMIC IFF_DYNAMIC
122#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
123
124#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
108#define IFF_LOWER_UP IFF_LOWER_UP 125#define IFF_LOWER_UP IFF_LOWER_UP
109#define IFF_DORMANT IFF_DORMANT 126#define IFF_DORMANT IFF_DORMANT
110#define IFF_ECHO IFF_ECHO 127#define IFF_ECHO IFF_ECHO
128#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
111 129
112#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\ 130#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
113 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) 131 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
@@ -166,6 +184,8 @@ enum {
166 * being very small might be worth keeping for clean configuration. 184 * being very small might be worth keeping for clean configuration.
167 */ 185 */
168 186
187/* for compatibility with glibc net/if.h */
188#if __UAPI_DEF_IF_IFMAP
169struct ifmap { 189struct ifmap {
170 unsigned long mem_start; 190 unsigned long mem_start;
171 unsigned long mem_end; 191 unsigned long mem_end;
@@ -175,6 +195,7 @@ struct ifmap {
175 unsigned char port; 195 unsigned char port;
176 /* 3 bytes spare */ 196 /* 3 bytes spare */
177}; 197};
198#endif /* __UAPI_DEF_IF_IFMAP */
178 199
179struct if_settings { 200struct if_settings {
180 unsigned int type; /* Type of physical device or protocol */ 201 unsigned int type; /* Type of physical device or protocol */
@@ -200,6 +221,8 @@ struct if_settings {
200 * remainder may be interface specific. 221 * remainder may be interface specific.
201 */ 222 */
202 223
224/* for compatibility with glibc net/if.h */
225#if __UAPI_DEF_IF_IFREQ
203struct ifreq { 226struct ifreq {
204#define IFHWADDRLEN 6 227#define IFHWADDRLEN 6
205 union 228 union
@@ -223,6 +246,7 @@ struct ifreq {
223 struct if_settings ifru_settings; 246 struct if_settings ifru_settings;
224 } ifr_ifru; 247 } ifr_ifru;
225}; 248};
249#endif /* __UAPI_DEF_IF_IFREQ */
226 250
227#define ifr_name ifr_ifrn.ifrn_name /* interface name */ 251#define ifr_name ifr_ifrn.ifrn_name /* interface name */
228#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 252#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
@@ -249,6 +273,8 @@ struct ifreq {
249 * must know all networks accessible). 273 * must know all networks accessible).
250 */ 274 */
251 275
276/* for compatibility with glibc net/if.h */
277#if __UAPI_DEF_IF_IFCONF
252struct ifconf { 278struct ifconf {
253 int ifc_len; /* size of buffer */ 279 int ifc_len; /* size of buffer */
254 union { 280 union {
@@ -256,6 +282,8 @@ struct ifconf {
256 struct ifreq __user *ifcu_req; 282 struct ifreq __user *ifcu_req;
257 } ifc_ifcu; 283 } ifc_ifcu;
258}; 284};
285#endif /* __UAPI_DEF_IF_IFCONF */
286
259#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ 287#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
260#define ifc_req ifc_ifcu.ifcu_req /* array of structures */ 288#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
261 289
diff --git a/include/uapi/linux/if_macsec.h b/include/uapi/linux/if_macsec.h
index 4c58d9917aa4..3411ed06b9c0 100644
--- a/include/uapi/linux/if_macsec.h
+++ b/include/uapi/linux/if_macsec.h
@@ -19,6 +19,8 @@
19 19
20#define MACSEC_MAX_KEY_LEN 128 20#define MACSEC_MAX_KEY_LEN 128
21 21
22#define MACSEC_KEYID_LEN 16
23
22#define MACSEC_DEFAULT_CIPHER_ID 0x0080020001000001ULL 24#define MACSEC_DEFAULT_CIPHER_ID 0x0080020001000001ULL
23#define MACSEC_DEFAULT_CIPHER_ALT 0x0080C20001000001ULL 25#define MACSEC_DEFAULT_CIPHER_ALT 0x0080C20001000001ULL
24 26
@@ -77,7 +79,7 @@ enum macsec_sa_attrs {
77 MACSEC_SA_ATTR_ACTIVE, /* config/dump, u8 0..1 */ 79 MACSEC_SA_ATTR_ACTIVE, /* config/dump, u8 0..1 */
78 MACSEC_SA_ATTR_PN, /* config/dump, u32 */ 80 MACSEC_SA_ATTR_PN, /* config/dump, u32 */
79 MACSEC_SA_ATTR_KEY, /* config, data */ 81 MACSEC_SA_ATTR_KEY, /* config, data */
80 MACSEC_SA_ATTR_KEYID, /* config/dump, u64 */ 82 MACSEC_SA_ATTR_KEYID, /* config/dump, 128-bit */
81 MACSEC_SA_ATTR_STATS, /* dump, nested, macsec_sa_stats_attr */ 83 MACSEC_SA_ATTR_STATS, /* dump, nested, macsec_sa_stats_attr */
82 __MACSEC_SA_ATTR_END, 84 __MACSEC_SA_ATTR_END,
83 NUM_MACSEC_SA_ATTR = __MACSEC_SA_ATTR_END, 85 NUM_MACSEC_SA_ATTR = __MACSEC_SA_ATTR_END,
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 7d024ceb075d..d5e38c73377c 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -51,6 +51,40 @@
51/* We have included glibc headers... */ 51/* We have included glibc headers... */
52#if defined(__GLIBC__) 52#if defined(__GLIBC__)
53 53
54/* Coordinate with glibc net/if.h header. */
55#if defined(_NET_IF_H)
56
57/* GLIBC headers included first so don't define anything
58 * that would already be defined. */
59
60#define __UAPI_DEF_IF_IFCONF 0
61#define __UAPI_DEF_IF_IFMAP 0
62#define __UAPI_DEF_IF_IFNAMSIZ 0
63#define __UAPI_DEF_IF_IFREQ 0
64/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
65#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
66/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
67#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
68#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
69#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
70
71#else /* _NET_IF_H */
72
73/* Linux headers included first, and we must define everything
74 * we need. The expectation is that glibc will check the
75 * __UAPI_DEF_* defines and adjust appropriately. */
76
77#define __UAPI_DEF_IF_IFCONF 1
78#define __UAPI_DEF_IF_IFMAP 1
79#define __UAPI_DEF_IF_IFNAMSIZ 1
80#define __UAPI_DEF_IF_IFREQ 1
81/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
82#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
83/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
84#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
85
86#endif /* _NET_IF_H */
87
54/* Coordinate with glibc netinet/in.h header. */ 88/* Coordinate with glibc netinet/in.h header. */
55#if defined(_NETINET_IN_H) 89#if defined(_NETINET_IN_H)
56 90
@@ -117,6 +151,16 @@
117 * that we need. */ 151 * that we need. */
118#else /* !defined(__GLIBC__) */ 152#else /* !defined(__GLIBC__) */
119 153
154/* Definitions for if.h */
155#define __UAPI_DEF_IF_IFCONF 1
156#define __UAPI_DEF_IF_IFMAP 1
157#define __UAPI_DEF_IF_IFNAMSIZ 1
158#define __UAPI_DEF_IF_IFREQ 1
159/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
160#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
161/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
162#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
163
120/* Definitions for in.h */ 164/* Definitions for in.h */
121#define __UAPI_DEF_IN_ADDR 1 165#define __UAPI_DEF_IN_ADDR 1
122#define __UAPI_DEF_IN_IPPROTO 1 166#define __UAPI_DEF_IN_IPPROTO 1
diff --git a/include/uapi/linux/tc_act/Kbuild b/include/uapi/linux/tc_act/Kbuild
index 242cf0c6e33d..e3969bd939e4 100644
--- a/include/uapi/linux/tc_act/Kbuild
+++ b/include/uapi/linux/tc_act/Kbuild
@@ -10,3 +10,4 @@ header-y += tc_skbedit.h
10header-y += tc_vlan.h 10header-y += tc_vlan.h
11header-y += tc_bpf.h 11header-y += tc_bpf.h
12header-y += tc_connmark.h 12header-y += tc_connmark.h
13header-y += tc_ife.h
diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index c4cc1e40b35c..e4701a3c6331 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -116,6 +116,14 @@
116#define SND_SOC_TPLG_STREAM_PLAYBACK 0 116#define SND_SOC_TPLG_STREAM_PLAYBACK 0
117#define SND_SOC_TPLG_STREAM_CAPTURE 1 117#define SND_SOC_TPLG_STREAM_CAPTURE 1
118 118
119/* vendor tuple types */
120#define SND_SOC_TPLG_TUPLE_TYPE_UUID 0
121#define SND_SOC_TPLG_TUPLE_TYPE_STRING 1
122#define SND_SOC_TPLG_TUPLE_TYPE_BOOL 2
123#define SND_SOC_TPLG_TUPLE_TYPE_BYTE 3
124#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
125#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
126
119/* 127/*
120 * Block Header. 128 * Block Header.
121 * This header precedes all object and object arrays below. 129 * This header precedes all object and object arrays below.
@@ -132,6 +140,35 @@ struct snd_soc_tplg_hdr {
132 __le32 count; /* number of elements in block */ 140 __le32 count; /* number of elements in block */
133} __attribute__((packed)); 141} __attribute__((packed));
134 142
143/* vendor tuple for uuid */
144struct snd_soc_tplg_vendor_uuid_elem {
145 __le32 token;
146 char uuid[16];
147} __attribute__((packed));
148
149/* vendor tuple for a bool/byte/short/word value */
150struct snd_soc_tplg_vendor_value_elem {
151 __le32 token;
152 __le32 value;
153} __attribute__((packed));
154
155/* vendor tuple for string */
156struct snd_soc_tplg_vendor_string_elem {
157 __le32 token;
158 char string[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
159} __attribute__((packed));
160
161struct snd_soc_tplg_vendor_array {
162 __le32 size; /* size in bytes of the array, including all elements */
163 __le32 type; /* SND_SOC_TPLG_TUPLE_TYPE_ */
164 __le32 num_elems; /* number of elements in array */
165 union {
166 struct snd_soc_tplg_vendor_uuid_elem uuid[0];
167 struct snd_soc_tplg_vendor_value_elem value[0];
168 struct snd_soc_tplg_vendor_string_elem string[0];
169 };
170} __attribute__((packed));
171
135/* 172/*
136 * Private data. 173 * Private data.
137 * All topology objects may have private data that can be used by the driver or 174 * All topology objects may have private data that can be used by the driver or
@@ -139,7 +176,10 @@ struct snd_soc_tplg_hdr {
139 */ 176 */
140struct snd_soc_tplg_private { 177struct snd_soc_tplg_private {
141 __le32 size; /* in bytes of private data */ 178 __le32 size; /* in bytes of private data */
142 char data[0]; 179 union {
180 char data[0];
181 struct snd_soc_tplg_vendor_array array[0];
182 };
143} __attribute__((packed)); 183} __attribute__((packed));
144 184
145/* 185/*
@@ -383,7 +423,7 @@ struct snd_soc_tplg_pcm {
383 __le32 size; /* in bytes of this structure */ 423 __le32 size; /* in bytes of this structure */
384 char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 424 char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
385 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 425 char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
386 __le32 pcm_id; /* unique ID - used to match */ 426 __le32 pcm_id; /* unique ID - used to match with DAI link */
387 __le32 dai_id; /* unique ID - used to match */ 427 __le32 dai_id; /* unique ID - used to match */
388 __le32 playback; /* supports playback mode */ 428 __le32 playback; /* supports playback mode */
389 __le32 capture; /* supports capture mode */ 429 __le32 capture; /* supports capture mode */
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 909a7d31ffd3..86cb5c6e8932 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1215,6 +1215,41 @@ static void cgroup_destroy_root(struct cgroup_root *root)
1215 cgroup_free_root(root); 1215 cgroup_free_root(root);
1216} 1216}
1217 1217
1218/*
1219 * look up cgroup associated with current task's cgroup namespace on the
1220 * specified hierarchy
1221 */
1222static struct cgroup *
1223current_cgns_cgroup_from_root(struct cgroup_root *root)
1224{
1225 struct cgroup *res = NULL;
1226 struct css_set *cset;
1227
1228 lockdep_assert_held(&css_set_lock);
1229
1230 rcu_read_lock();
1231
1232 cset = current->nsproxy->cgroup_ns->root_cset;
1233 if (cset == &init_css_set) {
1234 res = &root->cgrp;
1235 } else {
1236 struct cgrp_cset_link *link;
1237
1238 list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
1239 struct cgroup *c = link->cgrp;
1240
1241 if (c->root == root) {
1242 res = c;
1243 break;
1244 }
1245 }
1246 }
1247 rcu_read_unlock();
1248
1249 BUG_ON(!res);
1250 return res;
1251}
1252
1218/* look up cgroup associated with given css_set on the specified hierarchy */ 1253/* look up cgroup associated with given css_set on the specified hierarchy */
1219static struct cgroup *cset_cgroup_from_root(struct css_set *cset, 1254static struct cgroup *cset_cgroup_from_root(struct css_set *cset,
1220 struct cgroup_root *root) 1255 struct cgroup_root *root)
@@ -1593,6 +1628,33 @@ static int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
1593 return 0; 1628 return 0;
1594} 1629}
1595 1630
1631static int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node,
1632 struct kernfs_root *kf_root)
1633{
1634 int len = 0;
1635 char *buf = NULL;
1636 struct cgroup_root *kf_cgroot = cgroup_root_from_kf(kf_root);
1637 struct cgroup *ns_cgroup;
1638
1639 buf = kmalloc(PATH_MAX, GFP_KERNEL);
1640 if (!buf)
1641 return -ENOMEM;
1642
1643 spin_lock_bh(&css_set_lock);
1644 ns_cgroup = current_cgns_cgroup_from_root(kf_cgroot);
1645 len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);
1646 spin_unlock_bh(&css_set_lock);
1647
1648 if (len >= PATH_MAX)
1649 len = -ERANGE;
1650 else if (len > 0) {
1651 seq_escape(sf, buf, " \t\n\\");
1652 len = 0;
1653 }
1654 kfree(buf);
1655 return len;
1656}
1657
1596static int cgroup_show_options(struct seq_file *seq, 1658static int cgroup_show_options(struct seq_file *seq,
1597 struct kernfs_root *kf_root) 1659 struct kernfs_root *kf_root)
1598{ 1660{
@@ -5433,6 +5495,7 @@ static struct kernfs_syscall_ops cgroup_kf_syscall_ops = {
5433 .mkdir = cgroup_mkdir, 5495 .mkdir = cgroup_mkdir,
5434 .rmdir = cgroup_rmdir, 5496 .rmdir = cgroup_rmdir,
5435 .rename = cgroup_rename, 5497 .rename = cgroup_rename,
5498 .show_path = cgroup_show_path,
5436}; 5499};
5437 5500
5438static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early) 5501static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4e2ebf6f2f1f..c0ded2416615 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -351,7 +351,7 @@ static struct srcu_struct pmus_srcu;
351 * 1 - disallow cpu events for unpriv 351 * 1 - disallow cpu events for unpriv
352 * 2 - disallow kernel profiling for unpriv 352 * 2 - disallow kernel profiling for unpriv
353 */ 353 */
354int sysctl_perf_event_paranoid __read_mostly = 1; 354int sysctl_perf_event_paranoid __read_mostly = 2;
355 355
356/* Minimum for 512 kiB + 1 user control page */ 356/* Minimum for 512 kiB + 1 user control page */
357int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */ 357int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index c61f0cbd308b..7611d0f66cf8 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -347,6 +347,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
347 bool truncated) 347 bool truncated)
348{ 348{
349 struct ring_buffer *rb = handle->rb; 349 struct ring_buffer *rb = handle->rb;
350 bool wakeup = truncated;
350 unsigned long aux_head; 351 unsigned long aux_head;
351 u64 flags = 0; 352 u64 flags = 0;
352 353
@@ -375,9 +376,16 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size,
375 aux_head = rb->user_page->aux_head = local_read(&rb->aux_head); 376 aux_head = rb->user_page->aux_head = local_read(&rb->aux_head);
376 377
377 if (aux_head - local_read(&rb->aux_wakeup) >= rb->aux_watermark) { 378 if (aux_head - local_read(&rb->aux_wakeup) >= rb->aux_watermark) {
378 perf_output_wakeup(handle); 379 wakeup = true;
379 local_add(rb->aux_watermark, &rb->aux_wakeup); 380 local_add(rb->aux_watermark, &rb->aux_wakeup);
380 } 381 }
382
383 if (wakeup) {
384 if (truncated)
385 handle->event->pending_disable = 1;
386 perf_output_wakeup(handle);
387 }
388
381 handle->event = NULL; 389 handle->event = NULL;
382 390
383 local_set(&rb->aux_nest, 0); 391 local_set(&rb->aux_nest, 0);
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index affd97ec9f65..686ec8adf952 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1394,6 +1394,7 @@ static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq)
1394 !cpumask_test_cpu(later_rq->cpu, 1394 !cpumask_test_cpu(later_rq->cpu,
1395 &task->cpus_allowed) || 1395 &task->cpus_allowed) ||
1396 task_running(rq, task) || 1396 task_running(rq, task) ||
1397 !dl_task(task) ||
1397 !task_on_rq_queued(task))) { 1398 !task_on_rq_queued(task))) {
1398 double_unlock_balance(rq, later_rq); 1399 double_unlock_balance(rq, later_rq);
1399 later_rq = NULL; 1400 later_rq = NULL;
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0fe30e66aff1..e7dd0ec169be 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3030,7 +3030,14 @@ static int idle_balance(struct rq *this_rq);
3030 3030
3031#else /* CONFIG_SMP */ 3031#else /* CONFIG_SMP */
3032 3032
3033static inline void update_load_avg(struct sched_entity *se, int update_tg) {} 3033static inline void update_load_avg(struct sched_entity *se, int not_used)
3034{
3035 struct cfs_rq *cfs_rq = cfs_rq_of(se);
3036 struct rq *rq = rq_of(cfs_rq);
3037
3038 cpufreq_trigger_update(rq_clock(rq));
3039}
3040
3034static inline void 3041static inline void
3035enqueue_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) {} 3042enqueue_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) {}
3036static inline void 3043static inline void
@@ -3181,25 +3188,17 @@ static inline void check_schedstat_required(void)
3181static void 3188static void
3182enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) 3189enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
3183{ 3190{
3184 bool renorm = !(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_WAKING);
3185 bool curr = cfs_rq->curr == se;
3186
3187 /* 3191 /*
3188 * If we're the current task, we must renormalise before calling 3192 * Update the normalized vruntime before updating min_vruntime
3189 * update_curr(). 3193 * through calling update_curr().
3190 */ 3194 */
3191 if (renorm && curr) 3195 if (!(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_WAKING))
3192 se->vruntime += cfs_rq->min_vruntime; 3196 se->vruntime += cfs_rq->min_vruntime;
3193 3197
3194 update_curr(cfs_rq);
3195
3196 /* 3198 /*
3197 * Otherwise, renormalise after, such that we're placed at the current 3199 * Update run-time statistics of the 'current'.
3198 * moment in time, instead of some random moment in the past.
3199 */ 3200 */
3200 if (renorm && !curr) 3201 update_curr(cfs_rq);
3201 se->vruntime += cfs_rq->min_vruntime;
3202
3203 enqueue_entity_load_avg(cfs_rq, se); 3202 enqueue_entity_load_avg(cfs_rq, se);
3204 account_entity_enqueue(cfs_rq, se); 3203 account_entity_enqueue(cfs_rq, se);
3205 update_cfs_shares(cfs_rq); 3204 update_cfs_shares(cfs_rq);
@@ -3215,7 +3214,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
3215 update_stats_enqueue(cfs_rq, se); 3214 update_stats_enqueue(cfs_rq, se);
3216 check_spread(cfs_rq, se); 3215 check_spread(cfs_rq, se);
3217 } 3216 }
3218 if (!curr) 3217 if (se != cfs_rq->curr)
3219 __enqueue_entity(cfs_rq, se); 3218 __enqueue_entity(cfs_rq, se);
3220 se->on_rq = 1; 3219 se->on_rq = 1;
3221 3220
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index c41ea7ac1764..ec4f538d4396 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1729,6 +1729,7 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
1729 !cpumask_test_cpu(lowest_rq->cpu, 1729 !cpumask_test_cpu(lowest_rq->cpu,
1730 tsk_cpus_allowed(task)) || 1730 tsk_cpus_allowed(task)) ||
1731 task_running(rq, task) || 1731 task_running(rq, task) ||
1732 !rt_task(task) ||
1732 !task_on_rq_queued(task))) { 1733 !task_on_rq_queued(task))) {
1733 1734
1734 double_unlock_balance(rq, lowest_rq); 1735 double_unlock_balance(rq, lowest_rq);
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3bfdff06eea7..5f5068e94003 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4554,6 +4554,17 @@ static void rebind_workers(struct worker_pool *pool)
4554 pool->attrs->cpumask) < 0); 4554 pool->attrs->cpumask) < 0);
4555 4555
4556 spin_lock_irq(&pool->lock); 4556 spin_lock_irq(&pool->lock);
4557
4558 /*
4559 * XXX: CPU hotplug notifiers are weird and can call DOWN_FAILED
4560 * w/o preceding DOWN_PREPARE. Work around it. CPU hotplug is
4561 * being reworked and this can go away in time.
4562 */
4563 if (!(pool->flags & POOL_DISASSOCIATED)) {
4564 spin_unlock_irq(&pool->lock);
4565 return;
4566 }
4567
4557 pool->flags &= ~POOL_DISASSOCIATED; 4568 pool->flags &= ~POOL_DISASSOCIATED;
4558 4569
4559 for_each_pool_worker(worker, pool) { 4570 for_each_pool_worker(worker, pool) {
diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
index 2b3f46c049d4..554522934c44 100644
--- a/lib/asn1_decoder.c
+++ b/lib/asn1_decoder.c
@@ -74,7 +74,7 @@ next_tag:
74 74
75 /* Extract a tag from the data */ 75 /* Extract a tag from the data */
76 tag = data[dp++]; 76 tag = data[dp++];
77 if (tag == 0) { 77 if (tag == ASN1_EOC) {
78 /* It appears to be an EOC. */ 78 /* It appears to be an EOC. */
79 if (data[dp++] != 0) 79 if (data[dp++] != 0)
80 goto invalid_eoc; 80 goto invalid_eoc;
@@ -96,10 +96,8 @@ next_tag:
96 96
97 /* Extract the length */ 97 /* Extract the length */
98 len = data[dp++]; 98 len = data[dp++];
99 if (len <= 0x7f) { 99 if (len <= 0x7f)
100 dp += len; 100 goto check_length;
101 goto next_tag;
102 }
103 101
104 if (unlikely(len == ASN1_INDEFINITE_LENGTH)) { 102 if (unlikely(len == ASN1_INDEFINITE_LENGTH)) {
105 /* Indefinite length */ 103 /* Indefinite length */
@@ -110,14 +108,18 @@ next_tag:
110 } 108 }
111 109
112 n = len - 0x80; 110 n = len - 0x80;
113 if (unlikely(n > sizeof(size_t) - 1)) 111 if (unlikely(n > sizeof(len) - 1))
114 goto length_too_long; 112 goto length_too_long;
115 if (unlikely(n > datalen - dp)) 113 if (unlikely(n > datalen - dp))
116 goto data_overrun_error; 114 goto data_overrun_error;
117 for (len = 0; n > 0; n--) { 115 len = 0;
116 for (; n > 0; n--) {
118 len <<= 8; 117 len <<= 8;
119 len |= data[dp++]; 118 len |= data[dp++];
120 } 119 }
120check_length:
121 if (len > datalen - dp)
122 goto data_overrun_error;
121 dp += len; 123 dp += len;
122 goto next_tag; 124 goto next_tag;
123 125
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 5fecddc32b1b..ca5316e0087b 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -569,6 +569,25 @@ unsigned long iov_iter_alignment(const struct iov_iter *i)
569} 569}
570EXPORT_SYMBOL(iov_iter_alignment); 570EXPORT_SYMBOL(iov_iter_alignment);
571 571
572unsigned long iov_iter_gap_alignment(const struct iov_iter *i)
573{
574 unsigned long res = 0;
575 size_t size = i->count;
576 if (!size)
577 return 0;
578
579 iterate_all_kinds(i, size, v,
580 (res |= (!res ? 0 : (unsigned long)v.iov_base) |
581 (size != v.iov_len ? size : 0), 0),
582 (res |= (!res ? 0 : (unsigned long)v.bv_offset) |
583 (size != v.bv_len ? size : 0)),
584 (res |= (!res ? 0 : (unsigned long)v.iov_base) |
585 (size != v.iov_len ? size : 0))
586 );
587 return res;
588}
589EXPORT_SYMBOL(iov_iter_gap_alignment);
590
572ssize_t iov_iter_get_pages(struct iov_iter *i, 591ssize_t iov_iter_get_pages(struct iov_iter *i,
573 struct page **pages, size_t maxsize, unsigned maxpages, 592 struct page **pages, size_t maxsize, unsigned maxpages,
574 size_t *start) 593 size_t *start)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f7daa7de8f48..b49ee126d4d1 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1298,15 +1298,9 @@ int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
1298 VM_BUG_ON_PAGE(!PageCompound(page) || !PageHead(page), page); 1298 VM_BUG_ON_PAGE(!PageCompound(page) || !PageHead(page), page);
1299 /* 1299 /*
1300 * We can only reuse the page if nobody else maps the huge page or it's 1300 * We can only reuse the page if nobody else maps the huge page or it's
1301 * part. We can do it by checking page_mapcount() on each sub-page, but 1301 * part.
1302 * it's expensive.
1303 * The cheaper way is to check page_count() to be equal 1: every
1304 * mapcount takes page reference reference, so this way we can
1305 * guarantee, that the PMD is the only mapping.
1306 * This can give false negative if somebody pinned the page, but that's
1307 * fine.
1308 */ 1302 */
1309 if (page_mapcount(page) == 1 && page_count(page) == 1) { 1303 if (page_trans_huge_mapcount(page, NULL) == 1) {
1310 pmd_t entry; 1304 pmd_t entry;
1311 entry = pmd_mkyoung(orig_pmd); 1305 entry = pmd_mkyoung(orig_pmd);
1312 entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); 1306 entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
@@ -2079,7 +2073,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
2079 if (pte_write(pteval)) { 2073 if (pte_write(pteval)) {
2080 writable = true; 2074 writable = true;
2081 } else { 2075 } else {
2082 if (PageSwapCache(page) && !reuse_swap_page(page)) { 2076 if (PageSwapCache(page) &&
2077 !reuse_swap_page(page, NULL)) {
2083 unlock_page(page); 2078 unlock_page(page);
2084 result = SCAN_SWAP_CACHE_PAGE; 2079 result = SCAN_SWAP_CACHE_PAGE;
2085 goto out; 2080 goto out;
@@ -3223,6 +3218,64 @@ int total_mapcount(struct page *page)
3223} 3218}
3224 3219
3225/* 3220/*
3221 * This calculates accurately how many mappings a transparent hugepage
3222 * has (unlike page_mapcount() which isn't fully accurate). This full
3223 * accuracy is primarily needed to know if copy-on-write faults can
3224 * reuse the page and change the mapping to read-write instead of
3225 * copying them. At the same time this returns the total_mapcount too.
3226 *
3227 * The function returns the highest mapcount any one of the subpages
3228 * has. If the return value is one, even if different processes are
3229 * mapping different subpages of the transparent hugepage, they can
3230 * all reuse it, because each process is reusing a different subpage.
3231 *
3232 * The total_mapcount is instead counting all virtual mappings of the
3233 * subpages. If the total_mapcount is equal to "one", it tells the
3234 * caller all mappings belong to the same "mm" and in turn the
3235 * anon_vma of the transparent hugepage can become the vma->anon_vma
3236 * local one as no other process may be mapping any of the subpages.
3237 *
3238 * It would be more accurate to replace page_mapcount() with
3239 * page_trans_huge_mapcount(), however we only use
3240 * page_trans_huge_mapcount() in the copy-on-write faults where we
3241 * need full accuracy to avoid breaking page pinning, because
3242 * page_trans_huge_mapcount() is slower than page_mapcount().
3243 */
3244int page_trans_huge_mapcount(struct page *page, int *total_mapcount)
3245{
3246 int i, ret, _total_mapcount, mapcount;
3247
3248 /* hugetlbfs shouldn't call it */
3249 VM_BUG_ON_PAGE(PageHuge(page), page);
3250
3251 if (likely(!PageTransCompound(page))) {
3252 mapcount = atomic_read(&page->_mapcount) + 1;
3253 if (total_mapcount)
3254 *total_mapcount = mapcount;
3255 return mapcount;
3256 }
3257
3258 page = compound_head(page);
3259
3260 _total_mapcount = ret = 0;
3261 for (i = 0; i < HPAGE_PMD_NR; i++) {
3262 mapcount = atomic_read(&page[i]._mapcount) + 1;
3263 ret = max(ret, mapcount);
3264 _total_mapcount += mapcount;
3265 }
3266 if (PageDoubleMap(page)) {
3267 ret -= 1;
3268 _total_mapcount -= HPAGE_PMD_NR;
3269 }
3270 mapcount = compound_mapcount(page);
3271 ret += mapcount;
3272 _total_mapcount += mapcount;
3273 if (total_mapcount)
3274 *total_mapcount = _total_mapcount;
3275 return ret;
3276}
3277
3278/*
3226 * This function splits huge page into normal pages. @page can point to any 3279 * This function splits huge page into normal pages. @page can point to any
3227 * subpage of huge page to split. Split doesn't change the position of @page. 3280 * subpage of huge page to split. Split doesn't change the position of @page.
3228 * 3281 *
diff --git a/mm/ksm.c b/mm/ksm.c
index b99e828172f6..4786b4150f62 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -783,6 +783,7 @@ static int unmerge_and_remove_all_rmap_items(void)
783 } 783 }
784 784
785 remove_trailing_rmap_items(mm_slot, &mm_slot->rmap_list); 785 remove_trailing_rmap_items(mm_slot, &mm_slot->rmap_list);
786 up_read(&mm->mmap_sem);
786 787
787 spin_lock(&ksm_mmlist_lock); 788 spin_lock(&ksm_mmlist_lock);
788 ksm_scan.mm_slot = list_entry(mm_slot->mm_list.next, 789 ksm_scan.mm_slot = list_entry(mm_slot->mm_list.next,
@@ -794,12 +795,9 @@ static int unmerge_and_remove_all_rmap_items(void)
794 795
795 free_mm_slot(mm_slot); 796 free_mm_slot(mm_slot);
796 clear_bit(MMF_VM_MERGEABLE, &mm->flags); 797 clear_bit(MMF_VM_MERGEABLE, &mm->flags);
797 up_read(&mm->mmap_sem);
798 mmdrop(mm); 798 mmdrop(mm);
799 } else { 799 } else
800 spin_unlock(&ksm_mmlist_lock); 800 spin_unlock(&ksm_mmlist_lock);
801 up_read(&mm->mmap_sem);
802 }
803 } 801 }
804 802
805 /* Clean up stable nodes, but don't worry if some are still busy */ 803 /* Clean up stable nodes, but don't worry if some are still busy */
@@ -1663,8 +1661,15 @@ next_mm:
1663 up_read(&mm->mmap_sem); 1661 up_read(&mm->mmap_sem);
1664 mmdrop(mm); 1662 mmdrop(mm);
1665 } else { 1663 } else {
1666 spin_unlock(&ksm_mmlist_lock);
1667 up_read(&mm->mmap_sem); 1664 up_read(&mm->mmap_sem);
1665 /*
1666 * up_read(&mm->mmap_sem) first because after
1667 * spin_unlock(&ksm_mmlist_lock) run, the "mm" may
1668 * already have been freed under us by __ksm_exit()
1669 * because the "mm_slot" is still hashed and
1670 * ksm_scan.mm_slot doesn't point to it anymore.
1671 */
1672 spin_unlock(&ksm_mmlist_lock);
1668 } 1673 }
1669 1674
1670 /* Repeat until we've completed scanning the whole list */ 1675 /* Repeat until we've completed scanning the whole list */
diff --git a/mm/memory.c b/mm/memory.c
index 52c218e2b724..07493e34ab7e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2373,6 +2373,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
2373 * not dirty accountable. 2373 * not dirty accountable.
2374 */ 2374 */
2375 if (PageAnon(old_page) && !PageKsm(old_page)) { 2375 if (PageAnon(old_page) && !PageKsm(old_page)) {
2376 int total_mapcount;
2376 if (!trylock_page(old_page)) { 2377 if (!trylock_page(old_page)) {
2377 get_page(old_page); 2378 get_page(old_page);
2378 pte_unmap_unlock(page_table, ptl); 2379 pte_unmap_unlock(page_table, ptl);
@@ -2387,13 +2388,18 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
2387 } 2388 }
2388 put_page(old_page); 2389 put_page(old_page);
2389 } 2390 }
2390 if (reuse_swap_page(old_page)) { 2391 if (reuse_swap_page(old_page, &total_mapcount)) {
2391 /* 2392 if (total_mapcount == 1) {
2392 * The page is all ours. Move it to our anon_vma so 2393 /*
2393 * the rmap code will not search our parent or siblings. 2394 * The page is all ours. Move it to
2394 * Protected against the rmap code by the page lock. 2395 * our anon_vma so the rmap code will
2395 */ 2396 * not search our parent or siblings.
2396 page_move_anon_rmap(old_page, vma, address); 2397 * Protected against the rmap code by
2398 * the page lock.
2399 */
2400 page_move_anon_rmap(compound_head(old_page),
2401 vma, address);
2402 }
2397 unlock_page(old_page); 2403 unlock_page(old_page);
2398 return wp_page_reuse(mm, vma, address, page_table, ptl, 2404 return wp_page_reuse(mm, vma, address, page_table, ptl,
2399 orig_pte, old_page, 0, 0); 2405 orig_pte, old_page, 0, 0);
@@ -2617,7 +2623,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
2617 inc_mm_counter_fast(mm, MM_ANONPAGES); 2623 inc_mm_counter_fast(mm, MM_ANONPAGES);
2618 dec_mm_counter_fast(mm, MM_SWAPENTS); 2624 dec_mm_counter_fast(mm, MM_SWAPENTS);
2619 pte = mk_pte(page, vma->vm_page_prot); 2625 pte = mk_pte(page, vma->vm_page_prot);
2620 if ((flags & FAULT_FLAG_WRITE) && reuse_swap_page(page)) { 2626 if ((flags & FAULT_FLAG_WRITE) && reuse_swap_page(page, NULL)) {
2621 pte = maybe_mkwrite(pte_mkdirty(pte), vma); 2627 pte = maybe_mkwrite(pte_mkdirty(pte), vma);
2622 flags &= ~FAULT_FLAG_WRITE; 2628 flags &= ~FAULT_FLAG_WRITE;
2623 ret |= VM_FAULT_WRITE; 2629 ret |= VM_FAULT_WRITE;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 83874eced5bf..031713ab40ce 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -922,18 +922,19 @@ out:
922 * to it. And as a side-effect, free up its swap: because the old content 922 * to it. And as a side-effect, free up its swap: because the old content
923 * on disk will never be read, and seeking back there to write new content 923 * on disk will never be read, and seeking back there to write new content
924 * later would only waste time away from clustering. 924 * later would only waste time away from clustering.
925 *
926 * NOTE: total_mapcount should not be relied upon by the caller if
927 * reuse_swap_page() returns false, but it may be always overwritten
928 * (see the other implementation for CONFIG_SWAP=n).
925 */ 929 */
926int reuse_swap_page(struct page *page) 930bool reuse_swap_page(struct page *page, int *total_mapcount)
927{ 931{
928 int count; 932 int count;
929 933
930 VM_BUG_ON_PAGE(!PageLocked(page), page); 934 VM_BUG_ON_PAGE(!PageLocked(page), page);
931 if (unlikely(PageKsm(page))) 935 if (unlikely(PageKsm(page)))
932 return 0; 936 return false;
933 /* The page is part of THP and cannot be reused */ 937 count = page_trans_huge_mapcount(page, total_mapcount);
934 if (PageTransCompound(page))
935 return 0;
936 count = page_mapcount(page);
937 if (count <= 1 && PageSwapCache(page)) { 938 if (count <= 1 && PageSwapCache(page)) {
938 count += page_swapcount(page); 939 count += page_swapcount(page);
939 if (count == 1 && !PageWriteback(page)) { 940 if (count == 1 && !PageWriteback(page)) {
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index e72efb109fde..fe47fbba995a 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1735,10 +1735,13 @@ static struct page *isolate_source_page(struct size_class *class)
1735static unsigned long zs_can_compact(struct size_class *class) 1735static unsigned long zs_can_compact(struct size_class *class)
1736{ 1736{
1737 unsigned long obj_wasted; 1737 unsigned long obj_wasted;
1738 unsigned long obj_allocated = zs_stat_get(class, OBJ_ALLOCATED);
1739 unsigned long obj_used = zs_stat_get(class, OBJ_USED);
1738 1740
1739 obj_wasted = zs_stat_get(class, OBJ_ALLOCATED) - 1741 if (obj_allocated <= obj_used)
1740 zs_stat_get(class, OBJ_USED); 1742 return 0;
1741 1743
1744 obj_wasted = obj_allocated - obj_used;
1742 obj_wasted /= get_maxobj_per_zspage(class->size, 1745 obj_wasted /= get_maxobj_per_zspage(class->size,
1743 class->pages_per_zspage); 1746 class->pages_per_zspage);
1744 1747
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index 263b4de4de57..60a3dbfca8a1 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -21,18 +21,19 @@
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22#include "br_private.h" 22#include "br_private.h"
23 23
24/* called with RTNL */
25static int get_bridge_ifindices(struct net *net, int *indices, int num) 24static int get_bridge_ifindices(struct net *net, int *indices, int num)
26{ 25{
27 struct net_device *dev; 26 struct net_device *dev;
28 int i = 0; 27 int i = 0;
29 28
30 for_each_netdev(net, dev) { 29 rcu_read_lock();
30 for_each_netdev_rcu(net, dev) {
31 if (i >= num) 31 if (i >= num)
32 break; 32 break;
33 if (dev->priv_flags & IFF_EBRIDGE) 33 if (dev->priv_flags & IFF_EBRIDGE)
34 indices[i++] = dev->ifindex; 34 indices[i++] = dev->ifindex;
35 } 35 }
36 rcu_read_unlock();
36 37
37 return i; 38 return i;
38} 39}
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 191ea66e4d92..6852f3c7009c 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1279,6 +1279,7 @@ static int br_ip4_multicast_query(struct net_bridge *br,
1279 struct br_ip saddr; 1279 struct br_ip saddr;
1280 unsigned long max_delay; 1280 unsigned long max_delay;
1281 unsigned long now = jiffies; 1281 unsigned long now = jiffies;
1282 unsigned int offset = skb_transport_offset(skb);
1282 __be32 group; 1283 __be32 group;
1283 int err = 0; 1284 int err = 0;
1284 1285
@@ -1289,14 +1290,14 @@ static int br_ip4_multicast_query(struct net_bridge *br,
1289 1290
1290 group = ih->group; 1291 group = ih->group;
1291 1292
1292 if (skb->len == sizeof(*ih)) { 1293 if (skb->len == offset + sizeof(*ih)) {
1293 max_delay = ih->code * (HZ / IGMP_TIMER_SCALE); 1294 max_delay = ih->code * (HZ / IGMP_TIMER_SCALE);
1294 1295
1295 if (!max_delay) { 1296 if (!max_delay) {
1296 max_delay = 10 * HZ; 1297 max_delay = 10 * HZ;
1297 group = 0; 1298 group = 0;
1298 } 1299 }
1299 } else if (skb->len >= sizeof(*ih3)) { 1300 } else if (skb->len >= offset + sizeof(*ih3)) {
1300 ih3 = igmpv3_query_hdr(skb); 1301 ih3 = igmpv3_query_hdr(skb);
1301 if (ih3->nsrcs) 1302 if (ih3->nsrcs)
1302 goto out; 1303 goto out;
@@ -1357,6 +1358,7 @@ static int br_ip6_multicast_query(struct net_bridge *br,
1357 struct br_ip saddr; 1358 struct br_ip saddr;
1358 unsigned long max_delay; 1359 unsigned long max_delay;
1359 unsigned long now = jiffies; 1360 unsigned long now = jiffies;
1361 unsigned int offset = skb_transport_offset(skb);
1360 const struct in6_addr *group = NULL; 1362 const struct in6_addr *group = NULL;
1361 bool is_general_query; 1363 bool is_general_query;
1362 int err = 0; 1364 int err = 0;
@@ -1366,8 +1368,8 @@ static int br_ip6_multicast_query(struct net_bridge *br,
1366 (port && port->state == BR_STATE_DISABLED)) 1368 (port && port->state == BR_STATE_DISABLED))
1367 goto out; 1369 goto out;
1368 1370
1369 if (skb->len == sizeof(*mld)) { 1371 if (skb->len == offset + sizeof(*mld)) {
1370 if (!pskb_may_pull(skb, sizeof(*mld))) { 1372 if (!pskb_may_pull(skb, offset + sizeof(*mld))) {
1371 err = -EINVAL; 1373 err = -EINVAL;
1372 goto out; 1374 goto out;
1373 } 1375 }
@@ -1376,7 +1378,7 @@ static int br_ip6_multicast_query(struct net_bridge *br,
1376 if (max_delay) 1378 if (max_delay)
1377 group = &mld->mld_mca; 1379 group = &mld->mld_mca;
1378 } else { 1380 } else {
1379 if (!pskb_may_pull(skb, sizeof(*mld2q))) { 1381 if (!pskb_may_pull(skb, offset + sizeof(*mld2q))) {
1380 err = -EINVAL; 1382 err = -EINVAL;
1381 goto out; 1383 goto out;
1382 } 1384 }
diff --git a/net/core/flow.c b/net/core/flow.c
index 1033725be40b..3937b1b68d5b 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -92,8 +92,11 @@ static void flow_cache_gc_task(struct work_struct *work)
92 list_splice_tail_init(&xfrm->flow_cache_gc_list, &gc_list); 92 list_splice_tail_init(&xfrm->flow_cache_gc_list, &gc_list);
93 spin_unlock_bh(&xfrm->flow_cache_gc_lock); 93 spin_unlock_bh(&xfrm->flow_cache_gc_lock);
94 94
95 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) 95 list_for_each_entry_safe(fce, n, &gc_list, u.gc_list) {
96 flow_entry_kill(fce, xfrm); 96 flow_entry_kill(fce, xfrm);
97 atomic_dec(&xfrm->flow_cache_gc_count);
98 WARN_ON(atomic_read(&xfrm->flow_cache_gc_count) < 0);
99 }
97} 100}
98 101
99static void flow_cache_queue_garbage(struct flow_cache_percpu *fcp, 102static void flow_cache_queue_garbage(struct flow_cache_percpu *fcp,
@@ -101,6 +104,7 @@ static void flow_cache_queue_garbage(struct flow_cache_percpu *fcp,
101 struct netns_xfrm *xfrm) 104 struct netns_xfrm *xfrm)
102{ 105{
103 if (deleted) { 106 if (deleted) {
107 atomic_add(deleted, &xfrm->flow_cache_gc_count);
104 fcp->hash_count -= deleted; 108 fcp->hash_count -= deleted;
105 spin_lock_bh(&xfrm->flow_cache_gc_lock); 109 spin_lock_bh(&xfrm->flow_cache_gc_lock);
106 list_splice_tail(gc_list, &xfrm->flow_cache_gc_list); 110 list_splice_tail(gc_list, &xfrm->flow_cache_gc_list);
@@ -232,6 +236,13 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
232 if (fcp->hash_count > fc->high_watermark) 236 if (fcp->hash_count > fc->high_watermark)
233 flow_cache_shrink(fc, fcp); 237 flow_cache_shrink(fc, fcp);
234 238
239 if (fcp->hash_count > 2 * fc->high_watermark ||
240 atomic_read(&net->xfrm.flow_cache_gc_count) > fc->high_watermark) {
241 atomic_inc(&net->xfrm.flow_cache_genid);
242 flo = ERR_PTR(-ENOBUFS);
243 goto ret_object;
244 }
245
235 fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC); 246 fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
236 if (fle) { 247 if (fle) {
237 fle->net = net; 248 fle->net = net;
@@ -446,6 +457,7 @@ int flow_cache_init(struct net *net)
446 INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task); 457 INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task);
447 INIT_WORK(&net->xfrm.flow_cache_flush_work, flow_cache_flush_task); 458 INIT_WORK(&net->xfrm.flow_cache_flush_work, flow_cache_flush_task);
448 mutex_init(&net->xfrm.flow_flush_sem); 459 mutex_init(&net->xfrm.flow_flush_sem);
460 atomic_set(&net->xfrm.flow_cache_gc_count, 0);
449 461
450 fc->hash_shift = 10; 462 fc->hash_shift = 10;
451 fc->low_watermark = 2 * flow_cache_hash_size(fc); 463 fc->low_watermark = 2 * flow_cache_hash_size(fc);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a75f7e94b445..65763c29f845 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1180,14 +1180,16 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
1180 1180
1181static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev) 1181static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)
1182{ 1182{
1183 struct rtnl_link_ifmap map = { 1183 struct rtnl_link_ifmap map;
1184 .mem_start = dev->mem_start, 1184
1185 .mem_end = dev->mem_end, 1185 memset(&map, 0, sizeof(map));
1186 .base_addr = dev->base_addr, 1186 map.mem_start = dev->mem_start;
1187 .irq = dev->irq, 1187 map.mem_end = dev->mem_end;
1188 .dma = dev->dma, 1188 map.base_addr = dev->base_addr;
1189 .port = dev->if_port, 1189 map.irq = dev->irq;
1190 }; 1190 map.dma = dev->dma;
1191 map.port = dev->if_port;
1192
1191 if (nla_put(skb, IFLA_MAP, sizeof(map), &map)) 1193 if (nla_put(skb, IFLA_MAP, sizeof(map), &map))
1192 return -EMSGSIZE; 1194 return -EMSGSIZE;
1193 1195
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index d97268e8ff10..2b68418c7198 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -975,6 +975,8 @@ fib_convert_metrics(struct fib_info *fi, const struct fib_config *cfg)
975 val = 65535 - 40; 975 val = 65535 - 40;
976 if (type == RTAX_MTU && val > 65535 - 15) 976 if (type == RTAX_MTU && val > 65535 - 15)
977 val = 65535 - 15; 977 val = 65535 - 15;
978 if (type == RTAX_HOPLIMIT && val > 255)
979 val = 255;
978 if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK)) 980 if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK))
979 return -EINVAL; 981 return -EINVAL;
980 fi->fib_metrics[type - 1] = val; 982 fi->fib_metrics[type - 1] = val;
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index a39068b4a4d9..a6962ccad98a 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -228,8 +228,6 @@ static int fou_gro_complete(struct sk_buff *skb, int nhoff,
228 int err = -ENOSYS; 228 int err = -ENOSYS;
229 const struct net_offload **offloads; 229 const struct net_offload **offloads;
230 230
231 udp_tunnel_gro_complete(skb, nhoff);
232
233 rcu_read_lock(); 231 rcu_read_lock();
234 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; 232 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
235 ops = rcu_dereference(offloads[proto]); 233 ops = rcu_dereference(offloads[proto]);
@@ -238,6 +236,8 @@ static int fou_gro_complete(struct sk_buff *skb, int nhoff,
238 236
239 err = ops->callbacks.gro_complete(skb, nhoff); 237 err = ops->callbacks.gro_complete(skb, nhoff);
240 238
239 skb_set_inner_mac_header(skb, nhoff);
240
241out_unlock: 241out_unlock:
242 rcu_read_unlock(); 242 rcu_read_unlock();
243 243
@@ -414,6 +414,8 @@ static int gue_gro_complete(struct sk_buff *skb, int nhoff,
414 414
415 err = ops->callbacks.gro_complete(skb, nhoff + guehlen); 415 err = ops->callbacks.gro_complete(skb, nhoff + guehlen);
416 416
417 skb_set_inner_mac_header(skb, nhoff + guehlen);
418
417out_unlock: 419out_unlock:
418 rcu_read_unlock(); 420 rcu_read_unlock();
419 return err; 421 return err;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 205a2b8a5a84..4cc84212cce1 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -398,7 +398,10 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
398 iph->saddr, iph->daddr, tpi->key); 398 iph->saddr, iph->daddr, tpi->key);
399 399
400 if (tunnel) { 400 if (tunnel) {
401 skb_pop_mac_header(skb); 401 if (tunnel->dev->type != ARPHRD_NONE)
402 skb_pop_mac_header(skb);
403 else
404 skb_reset_mac_header(skb);
402 if (tunnel->collect_md) { 405 if (tunnel->collect_md) {
403 __be16 flags; 406 __be16 flags;
404 __be64 tun_id; 407 __be64 tun_id;
@@ -1031,6 +1034,8 @@ static void ipgre_netlink_parms(struct net_device *dev,
1031 struct ip_tunnel *t = netdev_priv(dev); 1034 struct ip_tunnel *t = netdev_priv(dev);
1032 1035
1033 t->collect_md = true; 1036 t->collect_md = true;
1037 if (dev->type == ARPHRD_IPGRE)
1038 dev->type = ARPHRD_NONE;
1034 } 1039 }
1035} 1040}
1036 1041
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 5cf10b777b7e..a917903d5e97 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -156,6 +156,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
156 struct dst_entry *dst = skb_dst(skb); 156 struct dst_entry *dst = skb_dst(skb);
157 struct net_device *tdev; /* Device to other host */ 157 struct net_device *tdev; /* Device to other host */
158 int err; 158 int err;
159 int mtu;
159 160
160 if (!dst) { 161 if (!dst) {
161 dev->stats.tx_carrier_errors++; 162 dev->stats.tx_carrier_errors++;
@@ -192,6 +193,23 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
192 tunnel->err_count = 0; 193 tunnel->err_count = 0;
193 } 194 }
194 195
196 mtu = dst_mtu(dst);
197 if (skb->len > mtu) {
198 skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
199 if (skb->protocol == htons(ETH_P_IP)) {
200 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
201 htonl(mtu));
202 } else {
203 if (mtu < IPV6_MIN_MTU)
204 mtu = IPV6_MIN_MTU;
205
206 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
207 }
208
209 dst_release(dst);
210 goto tx_error;
211 }
212
195 skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(dev))); 213 skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(dev)));
196 skb_dst_set(skb, dst); 214 skb_dst_set(skb, dst);
197 skb->dev = skb_dst(skb)->dev; 215 skb->dev = skb_dst(skb)->dev;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 441ae9da3a23..79a03b87a771 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2640,8 +2640,10 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2640 */ 2640 */
2641 if (unlikely((NET_IP_ALIGN && ((unsigned long)skb->data & 3)) || 2641 if (unlikely((NET_IP_ALIGN && ((unsigned long)skb->data & 3)) ||
2642 skb_headroom(skb) >= 0xFFFF)) { 2642 skb_headroom(skb) >= 0xFFFF)) {
2643 struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER, 2643 struct sk_buff *nskb;
2644 GFP_ATOMIC); 2644
2645 skb_mstamp_get(&skb->skb_mstamp);
2646 nskb = __pskb_copy(skb, MAX_TCP_HEADER, GFP_ATOMIC);
2645 err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) : 2647 err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
2646 -ENOBUFS; 2648 -ENOBUFS;
2647 } else { 2649 } else {
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 0ed2dafb7cc4..e330c0e56b11 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -399,6 +399,11 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff)
399 399
400 uh->len = newlen; 400 uh->len = newlen;
401 401
402 /* Set encapsulation before calling into inner gro_complete() functions
403 * to make them set up the inner offsets.
404 */
405 skb->encapsulation = 1;
406
402 rcu_read_lock(); 407 rcu_read_lock();
403 408
404 uo_priv = rcu_dereference(udp_offload_base); 409 uo_priv = rcu_dereference(udp_offload_base);
@@ -421,9 +426,6 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff)
421 if (skb->remcsum_offload) 426 if (skb->remcsum_offload)
422 skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM; 427 skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM;
423 428
424 skb->encapsulation = 1;
425 skb_set_inner_mac_header(skb, nhoff + sizeof(struct udphdr));
426
427 return err; 429 return err;
428} 430}
429 431
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 0a37ddc7af51..0013cacf7164 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -445,6 +445,8 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
445 445
446 if (__ipv6_addr_needs_scope_id(addr_type)) 446 if (__ipv6_addr_needs_scope_id(addr_type))
447 iif = skb->dev->ifindex; 447 iif = skb->dev->ifindex;
448 else
449 iif = l3mdev_master_ifindex(skb->dev);
448 450
449 /* 451 /*
450 * Must not send error if the source does not uniquely 452 * Must not send error if the source does not uniquely
@@ -499,9 +501,6 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
499 else if (!fl6.flowi6_oif) 501 else if (!fl6.flowi6_oif)
500 fl6.flowi6_oif = np->ucast_oif; 502 fl6.flowi6_oif = np->ucast_oif;
501 503
502 if (!fl6.flowi6_oif)
503 fl6.flowi6_oif = l3mdev_master_ifindex(skb->dev);
504
505 dst = icmpv6_route_lookup(net, skb, sk, &fl6); 504 dst = icmpv6_route_lookup(net, skb, sk, &fl6);
506 if (IS_ERR(dst)) 505 if (IS_ERR(dst))
507 goto out; 506 goto out;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d916d6ab9ad2..6f32944e0223 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1750,6 +1750,8 @@ static int ip6_convert_metrics(struct mx6_config *mxc,
1750 } else { 1750 } else {
1751 val = nla_get_u32(nla); 1751 val = nla_get_u32(nla);
1752 } 1752 }
1753 if (type == RTAX_HOPLIMIT && val > 255)
1754 val = 255;
1753 if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK)) 1755 if (type == RTAX_FEATURES && (val & ~RTAX_FEATURE_MASK))
1754 goto err; 1756 goto err;
1755 1757
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 711d209f9124..f443c6b0ce16 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -810,8 +810,13 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32
810 fl6.flowi6_proto = IPPROTO_TCP; 810 fl6.flowi6_proto = IPPROTO_TCP;
811 if (rt6_need_strict(&fl6.daddr) && !oif) 811 if (rt6_need_strict(&fl6.daddr) && !oif)
812 fl6.flowi6_oif = tcp_v6_iif(skb); 812 fl6.flowi6_oif = tcp_v6_iif(skb);
813 else 813 else {
814 if (!oif && netif_index_is_l3_master(net, skb->skb_iif))
815 oif = skb->skb_iif;
816
814 fl6.flowi6_oif = oif; 817 fl6.flowi6_oif = oif;
818 }
819
815 fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark); 820 fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark);
816 fl6.fl6_dport = t1->dest; 821 fl6.fl6_dport = t1->dest;
817 fl6.fl6_sport = t1->source; 822 fl6.fl6_sport = t1->source;
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index b3c52e3f689a..8ae3ed97d95c 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -626,6 +626,7 @@ static void llc_cmsg_rcv(struct msghdr *msg, struct sk_buff *skb)
626 if (llc->cmsg_flags & LLC_CMSG_PKTINFO) { 626 if (llc->cmsg_flags & LLC_CMSG_PKTINFO) {
627 struct llc_pktinfo info; 627 struct llc_pktinfo info;
628 628
629 memset(&info, 0, sizeof(info));
629 info.lpi_ifindex = llc_sk(skb->sk)->dev->ifindex; 630 info.lpi_ifindex = llc_sk(skb->sk)->dev->ifindex;
630 llc_pdu_decode_dsap(skb, &info.lpi_sap); 631 llc_pdu_decode_dsap(skb, &info.lpi_sap);
631 llc_pdu_decode_da(skb, info.lpi_mac); 632 llc_pdu_decode_da(skb, info.lpi_mac);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index afde5f5e728a..e27fd17c6743 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -66,7 +66,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_locks);
66__cacheline_aligned_in_smp DEFINE_SPINLOCK(nf_conntrack_expect_lock); 66__cacheline_aligned_in_smp DEFINE_SPINLOCK(nf_conntrack_expect_lock);
67EXPORT_SYMBOL_GPL(nf_conntrack_expect_lock); 67EXPORT_SYMBOL_GPL(nf_conntrack_expect_lock);
68 68
69static __read_mostly spinlock_t nf_conntrack_locks_all_lock; 69static __read_mostly DEFINE_SPINLOCK(nf_conntrack_locks_all_lock);
70static __read_mostly bool nf_conntrack_locks_all; 70static __read_mostly bool nf_conntrack_locks_all;
71 71
72void nf_conntrack_lock(spinlock_t *lock) __acquires(lock) 72void nf_conntrack_lock(spinlock_t *lock) __acquires(lock)
@@ -1778,6 +1778,7 @@ void nf_conntrack_init_end(void)
1778 1778
1779int nf_conntrack_init_net(struct net *net) 1779int nf_conntrack_init_net(struct net *net)
1780{ 1780{
1781 static atomic64_t unique_id;
1781 int ret = -ENOMEM; 1782 int ret = -ENOMEM;
1782 int cpu; 1783 int cpu;
1783 1784
@@ -1800,7 +1801,8 @@ int nf_conntrack_init_net(struct net *net)
1800 if (!net->ct.stat) 1801 if (!net->ct.stat)
1801 goto err_pcpu_lists; 1802 goto err_pcpu_lists;
1802 1803
1803 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net); 1804 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%llu",
1805 (u64)atomic64_inc_return(&unique_id));
1804 if (!net->ct.slabname) 1806 if (!net->ct.slabname)
1805 goto err_slabname; 1807 goto err_slabname;
1806 1808
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index 4c2b4c0c4d5f..dbd0803b1827 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -96,6 +96,8 @@ static int nfnl_acct_new(struct net *net, struct sock *nfnl,
96 return -EINVAL; 96 return -EINVAL;
97 if (flags & NFACCT_F_OVERQUOTA) 97 if (flags & NFACCT_F_OVERQUOTA)
98 return -EINVAL; 98 return -EINVAL;
99 if ((flags & NFACCT_F_QUOTA) && !tb[NFACCT_QUOTA])
100 return -EINVAL;
99 101
100 size += sizeof(u64); 102 size += sizeof(u64);
101 } 103 }
diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
index 29d2c31f406c..daf45da448fa 100644
--- a/net/netfilter/xt_IDLETIMER.c
+++ b/net/netfilter/xt_IDLETIMER.c
@@ -236,6 +236,7 @@ static void idletimer_tg_destroy(const struct xt_tgdtor_param *par)
236 236
237 list_del(&info->timer->entry); 237 list_del(&info->timer->entry);
238 del_timer_sync(&info->timer->timer); 238 del_timer_sync(&info->timer->timer);
239 cancel_work_sync(&info->timer->work);
239 sysfs_remove_file(idletimer_tg_kobj, &info->timer->attr.attr); 240 sysfs_remove_file(idletimer_tg_kobj, &info->timer->attr.attr);
240 kfree(info->timer->attr.attr.name); 241 kfree(info->timer->attr.attr.name);
241 kfree(info->timer); 242 kfree(info->timer);
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index b5fea1101faa..10c84d882881 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -776,6 +776,19 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
776 return -EINVAL; 776 return -EINVAL;
777 } 777 }
778 778
779 /* Userspace may decide to perform a ct lookup without a helper
780 * specified followed by a (recirculate and) commit with one.
781 * Therefore, for unconfirmed connections which we will commit,
782 * we need to attach the helper here.
783 */
784 if (!nf_ct_is_confirmed(ct) && info->commit &&
785 info->helper && !nfct_help(ct)) {
786 int err = __nf_ct_try_assign_helper(ct, info->ct,
787 GFP_ATOMIC);
788 if (err)
789 return err;
790 }
791
779 /* Call the helper only if: 792 /* Call the helper only if:
780 * - nf_conntrack_in() was executed above ("!cached") for a 793 * - nf_conntrack_in() was executed above ("!cached") for a
781 * confirmed connection, or 794 * confirmed connection, or
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index c589a9ba506a..343d011aa818 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -423,7 +423,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
423 u16 ife_type = 0; 423 u16 ife_type = 0;
424 u8 *daddr = NULL; 424 u8 *daddr = NULL;
425 u8 *saddr = NULL; 425 u8 *saddr = NULL;
426 int ret = 0; 426 int ret = 0, exists = 0;
427 int err; 427 int err;
428 428
429 err = nla_parse_nested(tb, TCA_IFE_MAX, nla, ife_policy); 429 err = nla_parse_nested(tb, TCA_IFE_MAX, nla, ife_policy);
@@ -435,25 +435,29 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
435 435
436 parm = nla_data(tb[TCA_IFE_PARMS]); 436 parm = nla_data(tb[TCA_IFE_PARMS]);
437 437
438 exists = tcf_hash_check(tn, parm->index, a, bind);
439 if (exists && bind)
440 return 0;
441
438 if (parm->flags & IFE_ENCODE) { 442 if (parm->flags & IFE_ENCODE) {
439 /* Until we get issued the ethertype, we cant have 443 /* Until we get issued the ethertype, we cant have
440 * a default.. 444 * a default..
441 **/ 445 **/
442 if (!tb[TCA_IFE_TYPE]) { 446 if (!tb[TCA_IFE_TYPE]) {
447 if (exists)
448 tcf_hash_release(a, bind);
443 pr_info("You MUST pass etherype for encoding\n"); 449 pr_info("You MUST pass etherype for encoding\n");
444 return -EINVAL; 450 return -EINVAL;
445 } 451 }
446 } 452 }
447 453
448 if (!tcf_hash_check(tn, parm->index, a, bind)) { 454 if (!exists) {
449 ret = tcf_hash_create(tn, parm->index, est, a, sizeof(*ife), 455 ret = tcf_hash_create(tn, parm->index, est, a, sizeof(*ife),
450 bind, false); 456 bind, false);
451 if (ret) 457 if (ret)
452 return ret; 458 return ret;
453 ret = ACT_P_CREATED; 459 ret = ACT_P_CREATED;
454 } else { 460 } else {
455 if (bind) /* dont override defaults */
456 return 0;
457 tcf_hash_release(a, bind); 461 tcf_hash_release(a, bind);
458 if (!ovr) 462 if (!ovr)
459 return -EEXIST; 463 return -EEXIST;
@@ -495,6 +499,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
495 NULL); 499 NULL);
496 if (err) { 500 if (err) {
497metadata_parse_err: 501metadata_parse_err:
502 if (exists)
503 tcf_hash_release(a, bind);
498 if (ret == ACT_P_CREATED) 504 if (ret == ACT_P_CREATED)
499 _tcf_ife_cleanup(a, bind); 505 _tcf_ife_cleanup(a, bind);
500 506
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 350e134cffb3..8b5270008a6e 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -96,7 +96,7 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
96 struct tcf_ipt *ipt; 96 struct tcf_ipt *ipt;
97 struct xt_entry_target *td, *t; 97 struct xt_entry_target *td, *t;
98 char *tname; 98 char *tname;
99 int ret = 0, err; 99 int ret = 0, err, exists = 0;
100 u32 hook = 0; 100 u32 hook = 0;
101 u32 index = 0; 101 u32 index = 0;
102 102
@@ -107,18 +107,23 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
107 if (err < 0) 107 if (err < 0)
108 return err; 108 return err;
109 109
110 if (tb[TCA_IPT_HOOK] == NULL) 110 if (tb[TCA_IPT_INDEX] != NULL)
111 return -EINVAL; 111 index = nla_get_u32(tb[TCA_IPT_INDEX]);
112 if (tb[TCA_IPT_TARG] == NULL) 112
113 exists = tcf_hash_check(tn, index, a, bind);
114 if (exists && bind)
115 return 0;
116
117 if (tb[TCA_IPT_HOOK] == NULL || tb[TCA_IPT_TARG] == NULL) {
118 if (exists)
119 tcf_hash_release(a, bind);
113 return -EINVAL; 120 return -EINVAL;
121 }
114 122
115 td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]); 123 td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]);
116 if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) 124 if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size)
117 return -EINVAL; 125 return -EINVAL;
118 126
119 if (tb[TCA_IPT_INDEX] != NULL)
120 index = nla_get_u32(tb[TCA_IPT_INDEX]);
121
122 if (!tcf_hash_check(tn, index, a, bind)) { 127 if (!tcf_hash_check(tn, index, a, bind)) {
123 ret = tcf_hash_create(tn, index, est, a, sizeof(*ipt), bind, 128 ret = tcf_hash_create(tn, index, est, a, sizeof(*ipt), bind,
124 false); 129 false);
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index e8a760cf7775..8f3948dd38b8 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -61,7 +61,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
61 struct tc_mirred *parm; 61 struct tc_mirred *parm;
62 struct tcf_mirred *m; 62 struct tcf_mirred *m;
63 struct net_device *dev; 63 struct net_device *dev;
64 int ret, ok_push = 0; 64 int ret, ok_push = 0, exists = 0;
65 65
66 if (nla == NULL) 66 if (nla == NULL)
67 return -EINVAL; 67 return -EINVAL;
@@ -71,17 +71,27 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
71 if (tb[TCA_MIRRED_PARMS] == NULL) 71 if (tb[TCA_MIRRED_PARMS] == NULL)
72 return -EINVAL; 72 return -EINVAL;
73 parm = nla_data(tb[TCA_MIRRED_PARMS]); 73 parm = nla_data(tb[TCA_MIRRED_PARMS]);
74
75 exists = tcf_hash_check(tn, parm->index, a, bind);
76 if (exists && bind)
77 return 0;
78
74 switch (parm->eaction) { 79 switch (parm->eaction) {
75 case TCA_EGRESS_MIRROR: 80 case TCA_EGRESS_MIRROR:
76 case TCA_EGRESS_REDIR: 81 case TCA_EGRESS_REDIR:
77 break; 82 break;
78 default: 83 default:
84 if (exists)
85 tcf_hash_release(a, bind);
79 return -EINVAL; 86 return -EINVAL;
80 } 87 }
81 if (parm->ifindex) { 88 if (parm->ifindex) {
82 dev = __dev_get_by_index(net, parm->ifindex); 89 dev = __dev_get_by_index(net, parm->ifindex);
83 if (dev == NULL) 90 if (dev == NULL) {
91 if (exists)
92 tcf_hash_release(a, bind);
84 return -ENODEV; 93 return -ENODEV;
94 }
85 switch (dev->type) { 95 switch (dev->type) {
86 case ARPHRD_TUNNEL: 96 case ARPHRD_TUNNEL:
87 case ARPHRD_TUNNEL6: 97 case ARPHRD_TUNNEL6:
@@ -99,7 +109,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
99 dev = NULL; 109 dev = NULL;
100 } 110 }
101 111
102 if (!tcf_hash_check(tn, parm->index, a, bind)) { 112 if (!exists) {
103 if (dev == NULL) 113 if (dev == NULL)
104 return -EINVAL; 114 return -EINVAL;
105 ret = tcf_hash_create(tn, parm->index, est, a, 115 ret = tcf_hash_create(tn, parm->index, est, a,
@@ -108,9 +118,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
108 return ret; 118 return ret;
109 ret = ACT_P_CREATED; 119 ret = ACT_P_CREATED;
110 } else { 120 } else {
111 if (bind)
112 return 0;
113
114 tcf_hash_release(a, bind); 121 tcf_hash_release(a, bind);
115 if (!ovr) 122 if (!ovr)
116 return -EEXIST; 123 return -EEXIST;
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index 75b2be13fbcc..3a33fb648a6d 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -87,7 +87,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
87 struct tc_defact *parm; 87 struct tc_defact *parm;
88 struct tcf_defact *d; 88 struct tcf_defact *d;
89 char *defdata; 89 char *defdata;
90 int ret = 0, err; 90 int ret = 0, err, exists = 0;
91 91
92 if (nla == NULL) 92 if (nla == NULL)
93 return -EINVAL; 93 return -EINVAL;
@@ -99,13 +99,21 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
99 if (tb[TCA_DEF_PARMS] == NULL) 99 if (tb[TCA_DEF_PARMS] == NULL)
100 return -EINVAL; 100 return -EINVAL;
101 101
102 if (tb[TCA_DEF_DATA] == NULL)
103 return -EINVAL;
104 102
105 parm = nla_data(tb[TCA_DEF_PARMS]); 103 parm = nla_data(tb[TCA_DEF_PARMS]);
104 exists = tcf_hash_check(tn, parm->index, a, bind);
105 if (exists && bind)
106 return 0;
107
108 if (tb[TCA_DEF_DATA] == NULL) {
109 if (exists)
110 tcf_hash_release(a, bind);
111 return -EINVAL;
112 }
113
106 defdata = nla_data(tb[TCA_DEF_DATA]); 114 defdata = nla_data(tb[TCA_DEF_DATA]);
107 115
108 if (!tcf_hash_check(tn, parm->index, a, bind)) { 116 if (!exists) {
109 ret = tcf_hash_create(tn, parm->index, est, a, 117 ret = tcf_hash_create(tn, parm->index, est, a,
110 sizeof(*d), bind, false); 118 sizeof(*d), bind, false);
111 if (ret) 119 if (ret)
@@ -122,8 +130,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
122 } else { 130 } else {
123 d = to_defact(a); 131 d = to_defact(a);
124 132
125 if (bind)
126 return 0;
127 tcf_hash_release(a, bind); 133 tcf_hash_release(a, bind);
128 if (!ovr) 134 if (!ovr)
129 return -EEXIST; 135 return -EEXIST;
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index cfcdbdc00c9b..69da5a8f0034 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -69,7 +69,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
69 struct tcf_skbedit *d; 69 struct tcf_skbedit *d;
70 u32 flags = 0, *priority = NULL, *mark = NULL; 70 u32 flags = 0, *priority = NULL, *mark = NULL;
71 u16 *queue_mapping = NULL; 71 u16 *queue_mapping = NULL;
72 int ret = 0, err; 72 int ret = 0, err, exists = 0;
73 73
74 if (nla == NULL) 74 if (nla == NULL)
75 return -EINVAL; 75 return -EINVAL;
@@ -96,12 +96,18 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
96 mark = nla_data(tb[TCA_SKBEDIT_MARK]); 96 mark = nla_data(tb[TCA_SKBEDIT_MARK]);
97 } 97 }
98 98
99 if (!flags)
100 return -EINVAL;
101
102 parm = nla_data(tb[TCA_SKBEDIT_PARMS]); 99 parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
103 100
104 if (!tcf_hash_check(tn, parm->index, a, bind)) { 101 exists = tcf_hash_check(tn, parm->index, a, bind);
102 if (exists && bind)
103 return 0;
104
105 if (!flags) {
106 tcf_hash_release(a, bind);
107 return -EINVAL;
108 }
109
110 if (!exists) {
105 ret = tcf_hash_create(tn, parm->index, est, a, 111 ret = tcf_hash_create(tn, parm->index, est, a,
106 sizeof(*d), bind, false); 112 sizeof(*d), bind, false);
107 if (ret) 113 if (ret)
@@ -111,8 +117,6 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
111 ret = ACT_P_CREATED; 117 ret = ACT_P_CREATED;
112 } else { 118 } else {
113 d = to_skbedit(a); 119 d = to_skbedit(a);
114 if (bind)
115 return 0;
116 tcf_hash_release(a, bind); 120 tcf_hash_release(a, bind);
117 if (!ovr) 121 if (!ovr)
118 return -EEXIST; 122 return -EEXIST;
diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
index bab8ae0cefc0..c45f926dafb9 100644
--- a/net/sched/act_vlan.c
+++ b/net/sched/act_vlan.c
@@ -77,7 +77,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
77 int action; 77 int action;
78 __be16 push_vid = 0; 78 __be16 push_vid = 0;
79 __be16 push_proto = 0; 79 __be16 push_proto = 0;
80 int ret = 0; 80 int ret = 0, exists = 0;
81 int err; 81 int err;
82 82
83 if (!nla) 83 if (!nla)
@@ -90,15 +90,25 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
90 if (!tb[TCA_VLAN_PARMS]) 90 if (!tb[TCA_VLAN_PARMS])
91 return -EINVAL; 91 return -EINVAL;
92 parm = nla_data(tb[TCA_VLAN_PARMS]); 92 parm = nla_data(tb[TCA_VLAN_PARMS]);
93 exists = tcf_hash_check(tn, parm->index, a, bind);
94 if (exists && bind)
95 return 0;
96
93 switch (parm->v_action) { 97 switch (parm->v_action) {
94 case TCA_VLAN_ACT_POP: 98 case TCA_VLAN_ACT_POP:
95 break; 99 break;
96 case TCA_VLAN_ACT_PUSH: 100 case TCA_VLAN_ACT_PUSH:
97 if (!tb[TCA_VLAN_PUSH_VLAN_ID]) 101 if (!tb[TCA_VLAN_PUSH_VLAN_ID]) {
102 if (exists)
103 tcf_hash_release(a, bind);
98 return -EINVAL; 104 return -EINVAL;
105 }
99 push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]); 106 push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
100 if (push_vid >= VLAN_VID_MASK) 107 if (push_vid >= VLAN_VID_MASK) {
108 if (exists)
109 tcf_hash_release(a, bind);
101 return -ERANGE; 110 return -ERANGE;
111 }
102 112
103 if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) { 113 if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) {
104 push_proto = nla_get_be16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]); 114 push_proto = nla_get_be16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]);
@@ -114,11 +124,13 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
114 } 124 }
115 break; 125 break;
116 default: 126 default:
127 if (exists)
128 tcf_hash_release(a, bind);
117 return -EINVAL; 129 return -EINVAL;
118 } 130 }
119 action = parm->v_action; 131 action = parm->v_action;
120 132
121 if (!tcf_hash_check(tn, parm->index, a, bind)) { 133 if (!exists) {
122 ret = tcf_hash_create(tn, parm->index, est, a, 134 ret = tcf_hash_create(tn, parm->index, est, a,
123 sizeof(*v), bind, false); 135 sizeof(*v), bind, false);
124 if (ret) 136 if (ret)
@@ -126,8 +138,6 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
126 138
127 ret = ACT_P_CREATED; 139 ret = ACT_P_CREATED;
128 } else { 140 } else {
129 if (bind)
130 return 0;
131 tcf_hash_release(a, bind); 141 tcf_hash_release(a, bind);
132 if (!ovr) 142 if (!ovr)
133 return -EEXIST; 143 return -EEXIST;
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 3dce53ebea92..b5f1221f48d4 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1808,27 +1808,8 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
1808 else if (sk->sk_shutdown & RCV_SHUTDOWN) 1808 else if (sk->sk_shutdown & RCV_SHUTDOWN)
1809 err = 0; 1809 err = 0;
1810 1810
1811 if (copied > 0) { 1811 if (copied > 0)
1812 /* We only do these additional bookkeeping/notification steps
1813 * if we actually copied something out of the queue pair
1814 * instead of just peeking ahead.
1815 */
1816
1817 if (!(flags & MSG_PEEK)) {
1818 /* If the other side has shutdown for sending and there
1819 * is nothing more to read, then modify the socket
1820 * state.
1821 */
1822 if (vsk->peer_shutdown & SEND_SHUTDOWN) {
1823 if (vsock_stream_has_data(vsk) <= 0) {
1824 sk->sk_state = SS_UNCONNECTED;
1825 sock_set_flag(sk, SOCK_DONE);
1826 sk->sk_state_change(sk);
1827 }
1828 }
1829 }
1830 err = copied; 1812 err = copied;
1831 }
1832 1813
1833out: 1814out:
1834 release_sock(sk); 1815 release_sock(sk);
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c
index 7ecd04c21360..997ff7b2509b 100644
--- a/net/x25/x25_facilities.c
+++ b/net/x25/x25_facilities.c
@@ -277,6 +277,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
277 277
278 memset(&theirs, 0, sizeof(theirs)); 278 memset(&theirs, 0, sizeof(theirs));
279 memcpy(new, ours, sizeof(*new)); 279 memcpy(new, ours, sizeof(*new));
280 memset(dte, 0, sizeof(*dte));
280 281
281 len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask); 282 len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask);
282 if (len < 0) 283 if (len < 0)
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index ff4a91fcab9f..637387bbaaea 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -99,6 +99,9 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
99 99
100 skb_dst_force(skb); 100 skb_dst_force(skb);
101 101
102 /* Inner headers are invalid now. */
103 skb->encapsulation = 0;
104
102 err = x->type->output(x, skb); 105 err = x->type->output(x, skb);
103 if (err == -EINPROGRESS) 106 if (err == -EINPROGRESS)
104 goto out; 107 goto out;
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index b3afae990e39..4d82a58ff6b0 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -43,6 +43,7 @@ config SND_SOC_ALL_CODECS
43 select SND_SOC_AK5386 43 select SND_SOC_AK5386
44 select SND_SOC_ALC5623 if I2C 44 select SND_SOC_ALC5623 if I2C
45 select SND_SOC_ALC5632 if I2C 45 select SND_SOC_ALC5632 if I2C
46 select SND_SOC_BT_SCO
46 select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC 47 select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC
47 select SND_SOC_CS35L32 if I2C 48 select SND_SOC_CS35L32 if I2C
48 select SND_SOC_CS42L51_I2C if I2C 49 select SND_SOC_CS42L51_I2C if I2C
@@ -64,7 +65,6 @@ config SND_SOC_ALL_CODECS
64 select SND_SOC_DA732X if I2C 65 select SND_SOC_DA732X if I2C
65 select SND_SOC_DA9055 if I2C 66 select SND_SOC_DA9055 if I2C
66 select SND_SOC_DMIC 67 select SND_SOC_DMIC
67 select SND_SOC_BT_SCO
68 select SND_SOC_ES8328_SPI if SPI_MASTER 68 select SND_SOC_ES8328_SPI if SPI_MASTER
69 select SND_SOC_ES8328_I2C if I2C 69 select SND_SOC_ES8328_I2C if I2C
70 select SND_SOC_GTM601 70 select SND_SOC_GTM601
@@ -79,6 +79,7 @@ config SND_SOC_ALL_CODECS
79 select SND_SOC_MAX98090 if I2C 79 select SND_SOC_MAX98090 if I2C
80 select SND_SOC_MAX98095 if I2C 80 select SND_SOC_MAX98095 if I2C
81 select SND_SOC_MAX98357A if GPIOLIB 81 select SND_SOC_MAX98357A if GPIOLIB
82 select SND_SOC_MAX98371 if I2C
82 select SND_SOC_MAX9867 if I2C 83 select SND_SOC_MAX9867 if I2C
83 select SND_SOC_MAX98925 if I2C 84 select SND_SOC_MAX98925 if I2C
84 select SND_SOC_MAX98926 if I2C 85 select SND_SOC_MAX98926 if I2C
@@ -126,12 +127,14 @@ config SND_SOC_ALL_CODECS
126 select SND_SOC_TAS2552 if I2C 127 select SND_SOC_TAS2552 if I2C
127 select SND_SOC_TAS5086 if I2C 128 select SND_SOC_TAS5086 if I2C
128 select SND_SOC_TAS571X if I2C 129 select SND_SOC_TAS571X if I2C
130 select SND_SOC_TAS5720 if I2C
129 select SND_SOC_TFA9879 if I2C 131 select SND_SOC_TFA9879 if I2C
130 select SND_SOC_TLV320AIC23_I2C if I2C 132 select SND_SOC_TLV320AIC23_I2C if I2C
131 select SND_SOC_TLV320AIC23_SPI if SPI_MASTER 133 select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
132 select SND_SOC_TLV320AIC26 if SPI_MASTER 134 select SND_SOC_TLV320AIC26 if SPI_MASTER
133 select SND_SOC_TLV320AIC31XX if I2C 135 select SND_SOC_TLV320AIC31XX if I2C
134 select SND_SOC_TLV320AIC32X4 if I2C 136 select SND_SOC_TLV320AIC32X4_I2C if I2C
137 select SND_SOC_TLV320AIC32X4_SPI if SPI_MASTER
135 select SND_SOC_TLV320AIC3X if I2C 138 select SND_SOC_TLV320AIC3X if I2C
136 select SND_SOC_TPA6130A2 if I2C 139 select SND_SOC_TPA6130A2 if I2C
137 select SND_SOC_TLV320DAC33 if I2C 140 select SND_SOC_TLV320DAC33 if I2C
@@ -367,6 +370,9 @@ config SND_SOC_ALC5623
367config SND_SOC_ALC5632 370config SND_SOC_ALC5632
368 tristate 371 tristate
369 372
373config SND_SOC_BT_SCO
374 tristate
375
370config SND_SOC_CQ0093VC 376config SND_SOC_CQ0093VC
371 tristate 377 tristate
372 378
@@ -473,9 +479,6 @@ config SND_SOC_DA732X
473config SND_SOC_DA9055 479config SND_SOC_DA9055
474 tristate 480 tristate
475 481
476config SND_SOC_BT_SCO
477 tristate
478
479config SND_SOC_DMIC 482config SND_SOC_DMIC
480 tristate 483 tristate
481 484
@@ -529,6 +532,9 @@ config SND_SOC_MAX98095
529config SND_SOC_MAX98357A 532config SND_SOC_MAX98357A
530 tristate 533 tristate
531 534
535config SND_SOC_MAX98371
536 tristate
537
532config SND_SOC_MAX9867 538config SND_SOC_MAX9867
533 tristate 539 tristate
534 540
@@ -748,9 +754,16 @@ config SND_SOC_TAS5086
748 depends on I2C 754 depends on I2C
749 755
750config SND_SOC_TAS571X 756config SND_SOC_TAS571X
751 tristate "Texas Instruments TAS5711/TAS5717/TAS5719 power amplifiers" 757 tristate "Texas Instruments TAS5711/TAS5717/TAS5719/TAS5721 power amplifiers"
752 depends on I2C 758 depends on I2C
753 759
760config SND_SOC_TAS5720
761 tristate "Texas Instruments TAS5720 Mono Audio amplifier"
762 depends on I2C
763 help
764 Enable support for Texas Instruments TAS5720L/M high-efficiency mono
765 Class-D audio power amplifiers.
766
754config SND_SOC_TFA9879 767config SND_SOC_TFA9879
755 tristate "NXP Semiconductors TFA9879 amplifier" 768 tristate "NXP Semiconductors TFA9879 amplifier"
756 depends on I2C 769 depends on I2C
@@ -780,6 +793,16 @@ config SND_SOC_TLV320AIC31XX
780config SND_SOC_TLV320AIC32X4 793config SND_SOC_TLV320AIC32X4
781 tristate 794 tristate
782 795
796config SND_SOC_TLV320AIC32X4_I2C
797 tristate
798 depends on I2C
799 select SND_SOC_TLV320AIC32X4
800
801config SND_SOC_TLV320AIC32X4_SPI
802 tristate
803 depends on SPI_MASTER
804 select SND_SOC_TLV320AIC32X4
805
783config SND_SOC_TLV320AIC3X 806config SND_SOC_TLV320AIC3X
784 tristate "Texas Instruments TLV320AIC3x CODECs" 807 tristate "Texas Instruments TLV320AIC3x CODECs"
785 depends on I2C 808 depends on I2C
@@ -920,7 +943,8 @@ config SND_SOC_WM8955
920 tristate 943 tristate
921 944
922config SND_SOC_WM8960 945config SND_SOC_WM8960
923 tristate 946 tristate "Wolfson Microelectronics WM8960 CODEC"
947 depends on I2C
924 948
925config SND_SOC_WM8961 949config SND_SOC_WM8961
926 tristate 950 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index b7b99416537f..0f548fd34ca3 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -32,6 +32,7 @@ snd-soc-ak4642-objs := ak4642.o
32snd-soc-ak4671-objs := ak4671.o 32snd-soc-ak4671-objs := ak4671.o
33snd-soc-ak5386-objs := ak5386.o 33snd-soc-ak5386-objs := ak5386.o
34snd-soc-arizona-objs := arizona.o 34snd-soc-arizona-objs := arizona.o
35snd-soc-bt-sco-objs := bt-sco.o
35snd-soc-cq93vc-objs := cq93vc.o 36snd-soc-cq93vc-objs := cq93vc.o
36snd-soc-cs35l32-objs := cs35l32.o 37snd-soc-cs35l32-objs := cs35l32.o
37snd-soc-cs42l51-objs := cs42l51.o 38snd-soc-cs42l51-objs := cs42l51.o
@@ -55,7 +56,6 @@ snd-soc-da7218-objs := da7218.o
55snd-soc-da7219-objs := da7219.o da7219-aad.o 56snd-soc-da7219-objs := da7219.o da7219-aad.o
56snd-soc-da732x-objs := da732x.o 57snd-soc-da732x-objs := da732x.o
57snd-soc-da9055-objs := da9055.o 58snd-soc-da9055-objs := da9055.o
58snd-soc-bt-sco-objs := bt-sco.o
59snd-soc-dmic-objs := dmic.o 59snd-soc-dmic-objs := dmic.o
60snd-soc-es8328-objs := es8328.o 60snd-soc-es8328-objs := es8328.o
61snd-soc-es8328-i2c-objs := es8328-i2c.o 61snd-soc-es8328-i2c-objs := es8328-i2c.o
@@ -74,6 +74,7 @@ snd-soc-max98088-objs := max98088.o
74snd-soc-max98090-objs := max98090.o 74snd-soc-max98090-objs := max98090.o
75snd-soc-max98095-objs := max98095.o 75snd-soc-max98095-objs := max98095.o
76snd-soc-max98357a-objs := max98357a.o 76snd-soc-max98357a-objs := max98357a.o
77snd-soc-max98371-objs := max98371.o
77snd-soc-max9867-objs := max9867.o 78snd-soc-max9867-objs := max9867.o
78snd-soc-max98925-objs := max98925.o 79snd-soc-max98925-objs := max98925.o
79snd-soc-max98926-objs := max98926.o 80snd-soc-max98926-objs := max98926.o
@@ -131,6 +132,7 @@ snd-soc-stac9766-objs := stac9766.o
131snd-soc-sti-sas-objs := sti-sas.o 132snd-soc-sti-sas-objs := sti-sas.o
132snd-soc-tas5086-objs := tas5086.o 133snd-soc-tas5086-objs := tas5086.o
133snd-soc-tas571x-objs := tas571x.o 134snd-soc-tas571x-objs := tas571x.o
135snd-soc-tas5720-objs := tas5720.o
134snd-soc-tfa9879-objs := tfa9879.o 136snd-soc-tfa9879-objs := tfa9879.o
135snd-soc-tlv320aic23-objs := tlv320aic23.o 137snd-soc-tlv320aic23-objs := tlv320aic23.o
136snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o 138snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
@@ -138,6 +140,8 @@ snd-soc-tlv320aic23-spi-objs := tlv320aic23-spi.o
138snd-soc-tlv320aic26-objs := tlv320aic26.o 140snd-soc-tlv320aic26-objs := tlv320aic26.o
139snd-soc-tlv320aic31xx-objs := tlv320aic31xx.o 141snd-soc-tlv320aic31xx-objs := tlv320aic31xx.o
140snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o 142snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o
143snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
144snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
141snd-soc-tlv320aic3x-objs := tlv320aic3x.o 145snd-soc-tlv320aic3x-objs := tlv320aic3x.o
142snd-soc-tlv320dac33-objs := tlv320dac33.o 146snd-soc-tlv320dac33-objs := tlv320dac33.o
143snd-soc-ts3a227e-objs := ts3a227e.o 147snd-soc-ts3a227e-objs := ts3a227e.o
@@ -243,6 +247,7 @@ obj-$(CONFIG_SND_SOC_AK5386) += snd-soc-ak5386.o
243obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o 247obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o
244obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o 248obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o
245obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o 249obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o
250obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o
246obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o 251obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o
247obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o 252obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o
248obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o 253obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o
@@ -266,7 +271,6 @@ obj-$(CONFIG_SND_SOC_DA7218) += snd-soc-da7218.o
266obj-$(CONFIG_SND_SOC_DA7219) += snd-soc-da7219.o 271obj-$(CONFIG_SND_SOC_DA7219) += snd-soc-da7219.o
267obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o 272obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o
268obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o 273obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o
269obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o
270obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o 274obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o
271obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o 275obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
272obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o 276obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
@@ -339,6 +343,7 @@ obj-$(CONFIG_SND_SOC_STI_SAS) += snd-soc-sti-sas.o
339obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o 343obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o
340obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o 344obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o
341obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o 345obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o
346obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o
342obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o 347obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o
343obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o 348obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o
344obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o 349obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
@@ -346,6 +351,8 @@ obj-$(CONFIG_SND_SOC_TLV320AIC23_SPI) += snd-soc-tlv320aic23-spi.o
346obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o 351obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o
347obj-$(CONFIG_SND_SOC_TLV320AIC31XX) += snd-soc-tlv320aic31xx.o 352obj-$(CONFIG_SND_SOC_TLV320AIC31XX) += snd-soc-tlv320aic31xx.o
348obj-$(CONFIG_SND_SOC_TLV320AIC32X4) += snd-soc-tlv320aic32x4.o 353obj-$(CONFIG_SND_SOC_TLV320AIC32X4) += snd-soc-tlv320aic32x4.o
354obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += snd-soc-tlv320aic32x4-i2c.o
355obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI) += snd-soc-tlv320aic32x4-spi.o
349obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o 356obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o
350obj-$(CONFIG_SND_SOC_TLV320DAC33) += snd-soc-tlv320dac33.o 357obj-$(CONFIG_SND_SOC_TLV320DAC33) += snd-soc-tlv320dac33.o
351obj-$(CONFIG_SND_SOC_TS3A227E) += snd-soc-ts3a227e.o 358obj-$(CONFIG_SND_SOC_TS3A227E) += snd-soc-ts3a227e.o
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 1ee8506c06c7..4d8b9e49e8d6 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -560,6 +560,7 @@ static const struct regmap_config ak4642_regmap = {
560 .max_register = FIL1_3, 560 .max_register = FIL1_3,
561 .reg_defaults = ak4642_reg, 561 .reg_defaults = ak4642_reg,
562 .num_reg_defaults = NUM_AK4642_REG_DEFAULTS, 562 .num_reg_defaults = NUM_AK4642_REG_DEFAULTS,
563 .cache_type = REGCACHE_RBTREE,
563}; 564};
564 565
565static const struct regmap_config ak4643_regmap = { 566static const struct regmap_config ak4643_regmap = {
@@ -568,6 +569,7 @@ static const struct regmap_config ak4643_regmap = {
568 .max_register = SPK_MS, 569 .max_register = SPK_MS,
569 .reg_defaults = ak4643_reg, 570 .reg_defaults = ak4643_reg,
570 .num_reg_defaults = ARRAY_SIZE(ak4643_reg), 571 .num_reg_defaults = ARRAY_SIZE(ak4643_reg),
572 .cache_type = REGCACHE_RBTREE,
571}; 573};
572 574
573static const struct regmap_config ak4648_regmap = { 575static const struct regmap_config ak4648_regmap = {
@@ -576,6 +578,7 @@ static const struct regmap_config ak4648_regmap = {
576 .max_register = EQ_FBEQE, 578 .max_register = EQ_FBEQE,
577 .reg_defaults = ak4648_reg, 579 .reg_defaults = ak4648_reg,
578 .num_reg_defaults = ARRAY_SIZE(ak4648_reg), 580 .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
581 .cache_type = REGCACHE_RBTREE,
579}; 582};
580 583
581static const struct ak4642_drvdata ak4642_drvdata = { 584static const struct ak4642_drvdata ak4642_drvdata = {
diff --git a/sound/soc/codecs/max98371.c b/sound/soc/codecs/max98371.c
new file mode 100644
index 000000000000..cf0a39bb631a
--- /dev/null
+++ b/sound/soc/codecs/max98371.c
@@ -0,0 +1,441 @@
1/*
2 * max98371.c -- ALSA SoC Stereo MAX98371 driver
3 *
4 * Copyright 2015-16 Maxim Integrated Products
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/i2c.h>
12#include <linux/module.h>
13#include <linux/regmap.h>
14#include <linux/slab.h>
15#include <sound/pcm.h>
16#include <sound/pcm_params.h>
17#include <sound/soc.h>
18#include <sound/tlv.h>
19#include "max98371.h"
20
21static const char *const monomix_text[] = {
22 "Left", "Right", "LeftRightDiv2",
23};
24
25static const char *const hpf_cutoff_txt[] = {
26 "Disable", "DC Block", "50Hz",
27 "100Hz", "200Hz", "400Hz", "800Hz",
28};
29
30static SOC_ENUM_SINGLE_DECL(max98371_monomix, MAX98371_MONOMIX_CFG, 0,
31 monomix_text);
32
33static SOC_ENUM_SINGLE_DECL(max98371_hpf_cutoff, MAX98371_HPF, 0,
34 hpf_cutoff_txt);
35
36static const DECLARE_TLV_DB_RANGE(max98371_dht_min_gain,
37 0, 1, TLV_DB_SCALE_ITEM(537, 66, 0),
38 2, 3, TLV_DB_SCALE_ITEM(677, 82, 0),
39 4, 5, TLV_DB_SCALE_ITEM(852, 104, 0),
40 6, 7, TLV_DB_SCALE_ITEM(1072, 131, 0),
41 8, 9, TLV_DB_SCALE_ITEM(1350, 165, 0),
42 10, 11, TLV_DB_SCALE_ITEM(1699, 101, 0),
43);
44
45static const DECLARE_TLV_DB_RANGE(max98371_dht_max_gain,
46 0, 1, TLV_DB_SCALE_ITEM(537, 66, 0),
47 2, 3, TLV_DB_SCALE_ITEM(677, 82, 0),
48 4, 5, TLV_DB_SCALE_ITEM(852, 104, 0),
49 6, 7, TLV_DB_SCALE_ITEM(1072, 131, 0),
50 8, 9, TLV_DB_SCALE_ITEM(1350, 165, 0),
51 10, 11, TLV_DB_SCALE_ITEM(1699, 208, 0),
52);
53
54static const DECLARE_TLV_DB_RANGE(max98371_dht_rot_gain,
55 0, 1, TLV_DB_SCALE_ITEM(-50, -50, 0),
56 2, 6, TLV_DB_SCALE_ITEM(-100, -100, 0),
57 7, 8, TLV_DB_SCALE_ITEM(-800, -200, 0),
58 9, 11, TLV_DB_SCALE_ITEM(-1200, -300, 0),
59 12, 13, TLV_DB_SCALE_ITEM(-2000, -200, 0),
60 14, 15, TLV_DB_SCALE_ITEM(-2500, -500, 0),
61);
62
63static const struct reg_default max98371_reg[] = {
64 { 0x01, 0x00 },
65 { 0x02, 0x00 },
66 { 0x03, 0x00 },
67 { 0x04, 0x00 },
68 { 0x05, 0x00 },
69 { 0x06, 0x00 },
70 { 0x07, 0x00 },
71 { 0x08, 0x00 },
72 { 0x09, 0x00 },
73 { 0x0A, 0x00 },
74 { 0x10, 0x06 },
75 { 0x11, 0x08 },
76 { 0x14, 0x80 },
77 { 0x15, 0x00 },
78 { 0x16, 0x00 },
79 { 0x18, 0x00 },
80 { 0x19, 0x00 },
81 { 0x1C, 0x00 },
82 { 0x1D, 0x00 },
83 { 0x1E, 0x00 },
84 { 0x1F, 0x00 },
85 { 0x20, 0x00 },
86 { 0x21, 0x00 },
87 { 0x22, 0x00 },
88 { 0x23, 0x00 },
89 { 0x24, 0x00 },
90 { 0x25, 0x00 },
91 { 0x26, 0x00 },
92 { 0x27, 0x00 },
93 { 0x28, 0x00 },
94 { 0x29, 0x00 },
95 { 0x2A, 0x00 },
96 { 0x2B, 0x00 },
97 { 0x2C, 0x00 },
98 { 0x2D, 0x00 },
99 { 0x2E, 0x0B },
100 { 0x31, 0x00 },
101 { 0x32, 0x18 },
102 { 0x33, 0x00 },
103 { 0x34, 0x00 },
104 { 0x36, 0x00 },
105 { 0x37, 0x00 },
106 { 0x38, 0x00 },
107 { 0x39, 0x00 },
108 { 0x3A, 0x00 },
109 { 0x3B, 0x00 },
110 { 0x3C, 0x00 },
111 { 0x3D, 0x00 },
112 { 0x3E, 0x00 },
113 { 0x3F, 0x00 },
114 { 0x40, 0x00 },
115 { 0x41, 0x00 },
116 { 0x42, 0x00 },
117 { 0x43, 0x00 },
118 { 0x4A, 0x00 },
119 { 0x4B, 0x00 },
120 { 0x4C, 0x00 },
121 { 0x4D, 0x00 },
122 { 0x4E, 0x00 },
123 { 0x50, 0x00 },
124 { 0x51, 0x00 },
125 { 0x55, 0x00 },
126 { 0x58, 0x00 },
127 { 0x59, 0x00 },
128 { 0x5C, 0x00 },
129 { 0xFF, 0x43 },
130};
131
132static bool max98371_volatile_register(struct device *dev, unsigned int reg)
133{
134 switch (reg) {
135 case MAX98371_IRQ_CLEAR1:
136 case MAX98371_IRQ_CLEAR2:
137 case MAX98371_IRQ_CLEAR3:
138 case MAX98371_VERSION:
139 return true;
140 default:
141 return false;
142 }
143}
144
145static bool max98371_readable_register(struct device *dev, unsigned int reg)
146{
147 switch (reg) {
148 case MAX98371_SOFT_RESET:
149 return false;
150 default:
151 return true;
152 }
153};
154
155static const DECLARE_TLV_DB_RANGE(max98371_gain_tlv,
156 0, 7, TLV_DB_SCALE_ITEM(0, 50, 0),
157 8, 10, TLV_DB_SCALE_ITEM(400, 100, 0)
158);
159
160static const DECLARE_TLV_DB_RANGE(max98371_noload_gain_tlv,
161 0, 11, TLV_DB_SCALE_ITEM(950, 100, 0),
162);
163
164static const DECLARE_TLV_DB_SCALE(digital_tlv, -6300, 50, 1);
165
166static const struct snd_kcontrol_new max98371_snd_controls[] = {
167 SOC_SINGLE_TLV("Speaker Volume", MAX98371_GAIN,
168 MAX98371_GAIN_SHIFT, (1<<MAX98371_GAIN_WIDTH)-1, 0,
169 max98371_gain_tlv),
170 SOC_SINGLE_TLV("Digital Volume", MAX98371_DIGITAL_GAIN, 0,
171 (1<<MAX98371_DIGITAL_GAIN_WIDTH)-1, 1, digital_tlv),
172 SOC_SINGLE_TLV("Speaker DHT Max Volume", MAX98371_GAIN,
173 0, (1<<MAX98371_DHT_MAX_WIDTH)-1, 0,
174 max98371_dht_max_gain),
175 SOC_SINGLE_TLV("Speaker DHT Min Volume", MAX98371_DHT_GAIN,
176 0, (1<<MAX98371_DHT_GAIN_WIDTH)-1, 0,
177 max98371_dht_min_gain),
178 SOC_SINGLE_TLV("Speaker DHT Rotation Volume", MAX98371_DHT_GAIN,
179 0, (1<<MAX98371_DHT_ROT_WIDTH)-1, 0,
180 max98371_dht_rot_gain),
181 SOC_SINGLE("DHT Attack Step", MAX98371_DHT, MAX98371_DHT_STEP, 3, 0),
182 SOC_SINGLE("DHT Attack Rate", MAX98371_DHT, 0, 7, 0),
183 SOC_ENUM("Monomix Select", max98371_monomix),
184 SOC_ENUM("HPF Cutoff", max98371_hpf_cutoff),
185};
186
187static int max98371_dai_set_fmt(struct snd_soc_dai *codec_dai,
188 unsigned int fmt)
189{
190 struct snd_soc_codec *codec = codec_dai->codec;
191 struct max98371_priv *max98371 = snd_soc_codec_get_drvdata(codec);
192 unsigned int val = 0;
193
194 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
195 case SND_SOC_DAIFMT_CBS_CFS:
196 break;
197 default:
198 dev_err(codec->dev, "DAI clock mode unsupported");
199 return -EINVAL;
200 }
201
202 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
203 case SND_SOC_DAIFMT_I2S:
204 val |= 0;
205 break;
206 case SND_SOC_DAIFMT_RIGHT_J:
207 val |= MAX98371_DAI_RIGHT;
208 break;
209 case SND_SOC_DAIFMT_LEFT_J:
210 val |= MAX98371_DAI_LEFT;
211 break;
212 default:
213 dev_err(codec->dev, "DAI wrong mode unsupported");
214 return -EINVAL;
215 }
216 regmap_update_bits(max98371->regmap, MAX98371_FMT,
217 MAX98371_FMT_MODE_MASK, val);
218 return 0;
219}
220
221static int max98371_dai_hw_params(struct snd_pcm_substream *substream,
222 struct snd_pcm_hw_params *params,
223 struct snd_soc_dai *dai)
224{
225 struct snd_soc_codec *codec = dai->codec;
226 struct max98371_priv *max98371 = snd_soc_codec_get_drvdata(codec);
227 int blr_clk_ratio, ch_size, channels = params_channels(params);
228 int rate = params_rate(params);
229
230 switch (params_format(params)) {
231 case SNDRV_PCM_FORMAT_S8:
232 regmap_update_bits(max98371->regmap, MAX98371_FMT,
233 MAX98371_FMT_MASK, MAX98371_DAI_CHANSZ_16);
234 ch_size = 8;
235 break;
236 case SNDRV_PCM_FORMAT_S16_LE:
237 regmap_update_bits(max98371->regmap, MAX98371_FMT,
238 MAX98371_FMT_MASK, MAX98371_DAI_CHANSZ_16);
239 ch_size = 16;
240 break;
241 case SNDRV_PCM_FORMAT_S24_LE:
242 regmap_update_bits(max98371->regmap, MAX98371_FMT,
243 MAX98371_FMT_MASK, MAX98371_DAI_CHANSZ_32);
244 ch_size = 24;
245 break;
246 case SNDRV_PCM_FORMAT_S32_LE:
247 regmap_update_bits(max98371->regmap, MAX98371_FMT,
248 MAX98371_FMT_MASK, MAX98371_DAI_CHANSZ_32);
249 ch_size = 32;
250 break;
251 default:
252 return -EINVAL;
253 }
254
255 /* BCLK/LRCLK ratio calculation */
256 blr_clk_ratio = channels * ch_size;
257 switch (blr_clk_ratio) {
258 case 32:
259 regmap_update_bits(max98371->regmap,
260 MAX98371_DAI_CLK,
261 MAX98371_DAI_BSEL_MASK, MAX98371_DAI_BSEL_32);
262 break;
263 case 48:
264 regmap_update_bits(max98371->regmap,
265 MAX98371_DAI_CLK,
266 MAX98371_DAI_BSEL_MASK, MAX98371_DAI_BSEL_48);
267 break;
268 case 64:
269 regmap_update_bits(max98371->regmap,
270 MAX98371_DAI_CLK,
271 MAX98371_DAI_BSEL_MASK, MAX98371_DAI_BSEL_64);
272 break;
273 default:
274 return -EINVAL;
275 }
276
277 switch (rate) {
278 case 32000:
279 regmap_update_bits(max98371->regmap,
280 MAX98371_SPK_SR,
281 MAX98371_SPK_SR_MASK, MAX98371_SPK_SR_32);
282 break;
283 case 44100:
284 regmap_update_bits(max98371->regmap,
285 MAX98371_SPK_SR,
286 MAX98371_SPK_SR_MASK, MAX98371_SPK_SR_44);
287 break;
288 case 48000:
289 regmap_update_bits(max98371->regmap,
290 MAX98371_SPK_SR,
291 MAX98371_SPK_SR_MASK, MAX98371_SPK_SR_48);
292 break;
293 case 88200:
294 regmap_update_bits(max98371->regmap,
295 MAX98371_SPK_SR,
296 MAX98371_SPK_SR_MASK, MAX98371_SPK_SR_88);
297 break;
298 case 96000:
299 regmap_update_bits(max98371->regmap,
300 MAX98371_SPK_SR,
301 MAX98371_SPK_SR_MASK, MAX98371_SPK_SR_96);
302 break;
303 default:
304 return -EINVAL;
305 }
306
307 /* enabling both the RX channels*/
308 regmap_update_bits(max98371->regmap, MAX98371_MONOMIX_SRC,
309 MAX98371_MONOMIX_SRC_MASK, MONOMIX_RX_0_1);
310 regmap_update_bits(max98371->regmap, MAX98371_DAI_CHANNEL,
311 MAX98371_CHANNEL_MASK, MAX98371_CHANNEL_MASK);
312 return 0;
313}
314
315static const struct snd_soc_dapm_widget max98371_dapm_widgets[] = {
316 SND_SOC_DAPM_DAC("DAC", NULL, MAX98371_SPK_ENABLE, 0, 0),
317 SND_SOC_DAPM_SUPPLY("Global Enable", MAX98371_GLOBAL_ENABLE,
318 0, 0, NULL, 0),
319 SND_SOC_DAPM_OUTPUT("SPK_OUT"),
320};
321
322static const struct snd_soc_dapm_route max98371_audio_map[] = {
323 {"DAC", NULL, "HiFi Playback"},
324 {"SPK_OUT", NULL, "DAC"},
325 {"SPK_OUT", NULL, "Global Enable"},
326};
327
328#define MAX98371_RATES SNDRV_PCM_RATE_8000_48000
329#define MAX98371_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | \
330 SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE)
331
332static const struct snd_soc_dai_ops max98371_dai_ops = {
333 .set_fmt = max98371_dai_set_fmt,
334 .hw_params = max98371_dai_hw_params,
335};
336
337static struct snd_soc_dai_driver max98371_dai[] = {
338 {
339 .name = "max98371-aif1",
340 .playback = {
341 .stream_name = "HiFi Playback",
342 .channels_min = 1,
343 .channels_max = 2,
344 .rates = SNDRV_PCM_RATE_8000_48000,
345 .formats = MAX98371_FORMATS,
346 },
347 .ops = &max98371_dai_ops,
348 }
349};
350
351static const struct snd_soc_codec_driver max98371_codec = {
352 .controls = max98371_snd_controls,
353 .num_controls = ARRAY_SIZE(max98371_snd_controls),
354 .dapm_routes = max98371_audio_map,
355 .num_dapm_routes = ARRAY_SIZE(max98371_audio_map),
356 .dapm_widgets = max98371_dapm_widgets,
357 .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets),
358};
359
360static const struct regmap_config max98371_regmap = {
361 .reg_bits = 8,
362 .val_bits = 8,
363 .max_register = MAX98371_VERSION,
364 .reg_defaults = max98371_reg,
365 .num_reg_defaults = ARRAY_SIZE(max98371_reg),
366 .volatile_reg = max98371_volatile_register,
367 .readable_reg = max98371_readable_register,
368 .cache_type = REGCACHE_RBTREE,
369};
370
371static int max98371_i2c_probe(struct i2c_client *i2c,
372 const struct i2c_device_id *id)
373{
374 struct max98371_priv *max98371;
375 int ret, reg;
376
377 max98371 = devm_kzalloc(&i2c->dev,
378 sizeof(*max98371), GFP_KERNEL);
379 if (!max98371)
380 return -ENOMEM;
381
382 i2c_set_clientdata(i2c, max98371);
383 max98371->regmap = devm_regmap_init_i2c(i2c, &max98371_regmap);
384 if (IS_ERR(max98371->regmap)) {
385 ret = PTR_ERR(max98371->regmap);
386 dev_err(&i2c->dev,
387 "Failed to allocate regmap: %d\n", ret);
388 return ret;
389 }
390
391 ret = regmap_read(max98371->regmap, MAX98371_VERSION, &reg);
392 if (ret < 0) {
393 dev_info(&i2c->dev, "device error %d\n", ret);
394 return ret;
395 }
396 dev_info(&i2c->dev, "device version %x\n", reg);
397
398 ret = snd_soc_register_codec(&i2c->dev, &max98371_codec,
399 max98371_dai, ARRAY_SIZE(max98371_dai));
400 if (ret < 0) {
401 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
402 return ret;
403 }
404 return ret;
405}
406
407static int max98371_i2c_remove(struct i2c_client *client)
408{
409 snd_soc_unregister_codec(&client->dev);
410 return 0;
411}
412
413static const struct i2c_device_id max98371_i2c_id[] = {
414 { "max98371", 0 },
415};
416
417MODULE_DEVICE_TABLE(i2c, max98371_i2c_id);
418
419static const struct of_device_id max98371_of_match[] = {
420 { .compatible = "maxim,max98371", },
421 { }
422};
423MODULE_DEVICE_TABLE(of, max98371_of_match);
424
425static struct i2c_driver max98371_i2c_driver = {
426 .driver = {
427 .name = "max98371",
428 .owner = THIS_MODULE,
429 .pm = NULL,
430 .of_match_table = of_match_ptr(max98371_of_match),
431 },
432 .probe = max98371_i2c_probe,
433 .remove = max98371_i2c_remove,
434 .id_table = max98371_i2c_id,
435};
436
437module_i2c_driver(max98371_i2c_driver);
438
439MODULE_AUTHOR("anish kumar <yesanishhere@gmail.com>");
440MODULE_DESCRIPTION("ALSA SoC MAX98371 driver");
441MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/max98371.h b/sound/soc/codecs/max98371.h
new file mode 100644
index 000000000000..9f6330964d98
--- /dev/null
+++ b/sound/soc/codecs/max98371.h
@@ -0,0 +1,67 @@
1/*
2 * max98371.h -- MAX98371 ALSA SoC Audio driver
3 *
4 * Copyright 2011-2012 Maxim Integrated Products
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _MAX98371_H
12#define _MAX98371_H
13
14#define MAX98371_IRQ_CLEAR1 0x01
15#define MAX98371_IRQ_CLEAR2 0x02
16#define MAX98371_IRQ_CLEAR3 0x03
17#define MAX98371_DAI_CLK 0x10
18#define MAX98371_DAI_BSEL_MASK 0xF
19#define MAX98371_DAI_BSEL_32 2
20#define MAX98371_DAI_BSEL_48 3
21#define MAX98371_DAI_BSEL_64 4
22#define MAX98371_SPK_SR 0x11
23#define MAX98371_SPK_SR_MASK 0xF
24#define MAX98371_SPK_SR_32 6
25#define MAX98371_SPK_SR_44 7
26#define MAX98371_SPK_SR_48 8
27#define MAX98371_SPK_SR_88 10
28#define MAX98371_SPK_SR_96 11
29#define MAX98371_DAI_CHANNEL 0x15
30#define MAX98371_CHANNEL_MASK 0x3
31#define MAX98371_MONOMIX_SRC 0x18
32#define MAX98371_MONOMIX_CFG 0x19
33#define MAX98371_HPF 0x1C
34#define MAX98371_MONOMIX_SRC_MASK 0xFF
35#define MONOMIX_RX_0_1 ((0x1)<<(4))
36#define M98371_DAI_CHANNEL_I2S 0x3
37#define MAX98371_DIGITAL_GAIN 0x2D
38#define MAX98371_DIGITAL_GAIN_WIDTH 0x7
39#define MAX98371_GAIN 0x2E
40#define MAX98371_GAIN_SHIFT 0x4
41#define MAX98371_GAIN_WIDTH 0x4
42#define MAX98371_DHT_MAX_WIDTH 4
43#define MAX98371_FMT 0x14
44#define MAX98371_CHANSZ_WIDTH 6
45#define MAX98371_FMT_MASK ((0x3)<<(MAX98371_CHANSZ_WIDTH))
46#define MAX98371_FMT_MODE_MASK ((0x7)<<(3))
47#define MAX98371_DAI_LEFT ((0x1)<<(3))
48#define MAX98371_DAI_RIGHT ((0x2)<<(3))
49#define MAX98371_DAI_CHANSZ_16 ((1)<<(MAX98371_CHANSZ_WIDTH))
50#define MAX98371_DAI_CHANSZ_24 ((2)<<(MAX98371_CHANSZ_WIDTH))
51#define MAX98371_DAI_CHANSZ_32 ((3)<<(MAX98371_CHANSZ_WIDTH))
52#define MAX98371_DHT 0x32
53#define MAX98371_DHT_STEP 0x3
54#define MAX98371_DHT_GAIN 0x31
55#define MAX98371_DHT_GAIN_WIDTH 0x4
56#define MAX98371_DHT_ROT_WIDTH 0x4
57#define MAX98371_SPK_ENABLE 0x4A
58#define MAX98371_GLOBAL_ENABLE 0x50
59#define MAX98371_SOFT_RESET 0x51
60#define MAX98371_VERSION 0xFF
61
62
63struct max98371_priv {
64 struct regmap *regmap;
65 struct snd_soc_codec *codec;
66};
67#endif
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index a1aaffc20862..f80cfe4d2ef2 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -276,6 +276,8 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic)
276 } else { 276 } else {
277 *mic = false; 277 *mic = false;
278 regmap_write(rt298->regmap, RT298_SET_MIC1, 0x20); 278 regmap_write(rt298->regmap, RT298_SET_MIC1, 0x20);
279 regmap_update_bits(rt298->regmap,
280 RT298_CBJ_CTRL1, 0x0400, 0x0000);
279 } 281 }
280 } else { 282 } else {
281 regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); 283 regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf);
@@ -482,6 +484,26 @@ static int rt298_adc_event(struct snd_soc_dapm_widget *w,
482 snd_soc_update_bits(codec, 484 snd_soc_update_bits(codec,
483 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), 485 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
484 0x7080, 0x7000); 486 0x7080, 0x7000);
487 /* If MCLK doesn't exist, reset AD filter */
488 if (!(snd_soc_read(codec, RT298_VAD_CTRL) & 0x200)) {
489 pr_info("NO MCLK\n");
490 switch (nid) {
491 case RT298_ADC_IN1:
492 snd_soc_update_bits(codec,
493 RT298_D_FILTER_CTRL, 0x2, 0x2);
494 mdelay(10);
495 snd_soc_update_bits(codec,
496 RT298_D_FILTER_CTRL, 0x2, 0x0);
497 break;
498 case RT298_ADC_IN2:
499 snd_soc_update_bits(codec,
500 RT298_D_FILTER_CTRL, 0x4, 0x4);
501 mdelay(10);
502 snd_soc_update_bits(codec,
503 RT298_D_FILTER_CTRL, 0x4, 0x0);
504 break;
505 }
506 }
485 break; 507 break;
486 case SND_SOC_DAPM_PRE_PMD: 508 case SND_SOC_DAPM_PRE_PMD:
487 snd_soc_update_bits(codec, 509 snd_soc_update_bits(codec,
@@ -520,30 +542,12 @@ static int rt298_mic1_event(struct snd_soc_dapm_widget *w,
520 return 0; 542 return 0;
521} 543}
522 544
523static int rt298_vref_event(struct snd_soc_dapm_widget *w,
524 struct snd_kcontrol *kcontrol, int event)
525{
526 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
527
528 switch (event) {
529 case SND_SOC_DAPM_PRE_PMU:
530 snd_soc_update_bits(codec,
531 RT298_CBJ_CTRL1, 0x0400, 0x0000);
532 mdelay(50);
533 break;
534 default:
535 return 0;
536 }
537
538 return 0;
539}
540
541static const struct snd_soc_dapm_widget rt298_dapm_widgets[] = { 545static const struct snd_soc_dapm_widget rt298_dapm_widgets[] = {
542 546
543 SND_SOC_DAPM_SUPPLY_S("HV", 1, RT298_POWER_CTRL1, 547 SND_SOC_DAPM_SUPPLY_S("HV", 1, RT298_POWER_CTRL1,
544 12, 1, NULL, 0), 548 12, 1, NULL, 0),
545 SND_SOC_DAPM_SUPPLY("VREF", RT298_POWER_CTRL1, 549 SND_SOC_DAPM_SUPPLY("VREF", RT298_POWER_CTRL1,
546 0, 1, rt298_vref_event, SND_SOC_DAPM_PRE_PMU), 550 0, 1, NULL, 0),
547 SND_SOC_DAPM_SUPPLY_S("BG_MBIAS", 1, RT298_POWER_CTRL2, 551 SND_SOC_DAPM_SUPPLY_S("BG_MBIAS", 1, RT298_POWER_CTRL2,
548 1, 0, NULL, 0), 552 1, 0, NULL, 0),
549 SND_SOC_DAPM_SUPPLY_S("LDO1", 1, RT298_POWER_CTRL2, 553 SND_SOC_DAPM_SUPPLY_S("LDO1", 1, RT298_POWER_CTRL2,
@@ -934,18 +938,9 @@ static int rt298_set_bias_level(struct snd_soc_codec *codec,
934 } 938 }
935 break; 939 break;
936 940
937 case SND_SOC_BIAS_ON:
938 mdelay(30);
939 snd_soc_update_bits(codec,
940 RT298_CBJ_CTRL1, 0x0400, 0x0400);
941
942 break;
943
944 case SND_SOC_BIAS_STANDBY: 941 case SND_SOC_BIAS_STANDBY:
945 snd_soc_write(codec, 942 snd_soc_write(codec,
946 RT298_SET_AUDIO_POWER, AC_PWRST_D3); 943 RT298_SET_AUDIO_POWER, AC_PWRST_D3);
947 snd_soc_update_bits(codec,
948 RT298_CBJ_CTRL1, 0x0400, 0x0000);
949 break; 944 break;
950 945
951 default: 946 default:
diff --git a/sound/soc/codecs/rt298.h b/sound/soc/codecs/rt298.h
index d66f8847b676..3638f3d61209 100644
--- a/sound/soc/codecs/rt298.h
+++ b/sound/soc/codecs/rt298.h
@@ -137,6 +137,7 @@
137#define RT298_A_BIAS_CTRL2 0x02 137#define RT298_A_BIAS_CTRL2 0x02
138#define RT298_POWER_CTRL1 0x03 138#define RT298_POWER_CTRL1 0x03
139#define RT298_A_BIAS_CTRL3 0x04 139#define RT298_A_BIAS_CTRL3 0x04
140#define RT298_D_FILTER_CTRL 0x05
140#define RT298_POWER_CTRL2 0x08 141#define RT298_POWER_CTRL2 0x08
141#define RT298_I2S_CTRL1 0x09 142#define RT298_I2S_CTRL1 0x09
142#define RT298_I2S_CTRL2 0x0a 143#define RT298_I2S_CTRL2 0x0a
@@ -148,6 +149,7 @@
148#define RT298_IRQ_CTRL 0x33 149#define RT298_IRQ_CTRL 0x33
149#define RT298_WIND_FILTER_CTRL 0x46 150#define RT298_WIND_FILTER_CTRL 0x46
150#define RT298_PLL_CTRL1 0x49 151#define RT298_PLL_CTRL1 0x49
152#define RT298_VAD_CTRL 0x4e
151#define RT298_CBJ_CTRL1 0x4f 153#define RT298_CBJ_CTRL1 0x4f
152#define RT298_CBJ_CTRL2 0x50 154#define RT298_CBJ_CTRL2 0x50
153#define RT298_PLL_CTRL 0x63 155#define RT298_PLL_CTRL 0x63
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 33e290b703df..b3f1db5bae4a 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -1241,60 +1241,46 @@ static int rt5677_dmic_use_asrc(struct snd_soc_dapm_widget *source,
1241 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); 1241 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1242 asrc_setting = (asrc_setting & RT5677_AD_STO1_CLK_SEL_MASK) >> 1242 asrc_setting = (asrc_setting & RT5677_AD_STO1_CLK_SEL_MASK) >>
1243 RT5677_AD_STO1_CLK_SEL_SFT; 1243 RT5677_AD_STO1_CLK_SEL_SFT;
1244 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1245 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1246 return 1;
1247 break; 1244 break;
1248 1245
1249 case 10: 1246 case 10:
1250 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); 1247 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1251 asrc_setting = (asrc_setting & RT5677_AD_STO2_CLK_SEL_MASK) >> 1248 asrc_setting = (asrc_setting & RT5677_AD_STO2_CLK_SEL_MASK) >>
1252 RT5677_AD_STO2_CLK_SEL_SFT; 1249 RT5677_AD_STO2_CLK_SEL_SFT;
1253 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1254 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1255 return 1;
1256 break; 1250 break;
1257 1251
1258 case 9: 1252 case 9:
1259 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); 1253 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1260 asrc_setting = (asrc_setting & RT5677_AD_STO3_CLK_SEL_MASK) >> 1254 asrc_setting = (asrc_setting & RT5677_AD_STO3_CLK_SEL_MASK) >>
1261 RT5677_AD_STO3_CLK_SEL_SFT; 1255 RT5677_AD_STO3_CLK_SEL_SFT;
1262 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1263 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1264 return 1;
1265 break; 1256 break;
1266 1257
1267 case 8: 1258 case 8:
1268 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting); 1259 regmap_read(rt5677->regmap, RT5677_ASRC_5, &asrc_setting);
1269 asrc_setting = (asrc_setting & RT5677_AD_STO4_CLK_SEL_MASK) >> 1260 asrc_setting = (asrc_setting & RT5677_AD_STO4_CLK_SEL_MASK) >>
1270 RT5677_AD_STO4_CLK_SEL_SFT; 1261 RT5677_AD_STO4_CLK_SEL_SFT;
1271 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1272 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1273 return 1;
1274 break; 1262 break;
1275 1263
1276 case 7: 1264 case 7:
1277 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting); 1265 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting);
1278 asrc_setting = (asrc_setting & RT5677_AD_MONOL_CLK_SEL_MASK) >> 1266 asrc_setting = (asrc_setting & RT5677_AD_MONOL_CLK_SEL_MASK) >>
1279 RT5677_AD_MONOL_CLK_SEL_SFT; 1267 RT5677_AD_MONOL_CLK_SEL_SFT;
1280 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1281 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1282 return 1;
1283 break; 1268 break;
1284 1269
1285 case 6: 1270 case 6:
1286 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting); 1271 regmap_read(rt5677->regmap, RT5677_ASRC_6, &asrc_setting);
1287 asrc_setting = (asrc_setting & RT5677_AD_MONOR_CLK_SEL_MASK) >> 1272 asrc_setting = (asrc_setting & RT5677_AD_MONOR_CLK_SEL_MASK) >>
1288 RT5677_AD_MONOR_CLK_SEL_SFT; 1273 RT5677_AD_MONOR_CLK_SEL_SFT;
1289 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1290 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1291 return 1;
1292 break; 1274 break;
1293 1275
1294 default: 1276 default:
1295 break; 1277 return 0;
1296 } 1278 }
1297 1279
1280 if (asrc_setting >= RT5677_CLK_SEL_I2S1_ASRC &&
1281 asrc_setting <= RT5677_CLK_SEL_I2S6_ASRC)
1282 return 1;
1283
1298 return 0; 1284 return 0;
1299} 1285}
1300 1286
diff --git a/sound/soc/codecs/tas571x.c b/sound/soc/codecs/tas571x.c
index 39307ad41a34..b8d19b77bde9 100644
--- a/sound/soc/codecs/tas571x.c
+++ b/sound/soc/codecs/tas571x.c
@@ -4,6 +4,9 @@
4 * Copyright (C) 2015 Google, Inc. 4 * Copyright (C) 2015 Google, Inc.
5 * Copyright (c) 2013 Daniel Mack <zonque@gmail.com> 5 * Copyright (c) 2013 Daniel Mack <zonque@gmail.com>
6 * 6 *
7 * TAS5721 support:
8 * Copyright (C) 2016 Petr Kulhavy, Barix AG <petr@barix.com>
9 *
7 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
@@ -57,6 +60,10 @@ static int tas571x_register_size(struct tas571x_private *priv, unsigned int reg)
57 case TAS571X_CH1_VOL_REG: 60 case TAS571X_CH1_VOL_REG:
58 case TAS571X_CH2_VOL_REG: 61 case TAS571X_CH2_VOL_REG:
59 return priv->chip->vol_reg_size; 62 return priv->chip->vol_reg_size;
63 case TAS571X_INPUT_MUX_REG:
64 case TAS571X_CH4_SRC_SELECT_REG:
65 case TAS571X_PWM_MUX_REG:
66 return 4;
60 default: 67 default:
61 return 1; 68 return 1;
62 } 69 }
@@ -167,6 +174,23 @@ static int tas571x_hw_params(struct snd_pcm_substream *substream,
167 TAS571X_SDI_FMT_MASK, val); 174 TAS571X_SDI_FMT_MASK, val);
168} 175}
169 176
177static int tas571x_mute(struct snd_soc_dai *dai, int mute)
178{
179 struct snd_soc_codec *codec = dai->codec;
180 u8 sysctl2;
181 int ret;
182
183 sysctl2 = mute ? TAS571X_SYS_CTRL_2_SDN_MASK : 0;
184
185 ret = snd_soc_update_bits(codec,
186 TAS571X_SYS_CTRL_2_REG,
187 TAS571X_SYS_CTRL_2_SDN_MASK,
188 sysctl2);
189 usleep_range(1000, 2000);
190
191 return ret;
192}
193
170static int tas571x_set_bias_level(struct snd_soc_codec *codec, 194static int tas571x_set_bias_level(struct snd_soc_codec *codec,
171 enum snd_soc_bias_level level) 195 enum snd_soc_bias_level level)
172{ 196{
@@ -214,6 +238,7 @@ static int tas571x_set_bias_level(struct snd_soc_codec *codec,
214static const struct snd_soc_dai_ops tas571x_dai_ops = { 238static const struct snd_soc_dai_ops tas571x_dai_ops = {
215 .set_fmt = tas571x_set_dai_fmt, 239 .set_fmt = tas571x_set_dai_fmt,
216 .hw_params = tas571x_hw_params, 240 .hw_params = tas571x_hw_params,
241 .digital_mute = tas571x_mute,
217}; 242};
218 243
219static const char *const tas5711_supply_names[] = { 244static const char *const tas5711_supply_names[] = {
@@ -241,6 +266,26 @@ static const struct snd_kcontrol_new tas5711_controls[] = {
241 1, 1), 266 1, 1),
242}; 267};
243 268
269static const struct regmap_range tas571x_readonly_regs_range[] = {
270 regmap_reg_range(TAS571X_CLK_CTRL_REG, TAS571X_DEV_ID_REG),
271};
272
273static const struct regmap_range tas571x_volatile_regs_range[] = {
274 regmap_reg_range(TAS571X_CLK_CTRL_REG, TAS571X_ERR_STATUS_REG),
275 regmap_reg_range(TAS571X_OSC_TRIM_REG, TAS571X_OSC_TRIM_REG),
276};
277
278static const struct regmap_access_table tas571x_write_regs = {
279 .no_ranges = tas571x_readonly_regs_range,
280 .n_no_ranges = ARRAY_SIZE(tas571x_readonly_regs_range),
281};
282
283static const struct regmap_access_table tas571x_volatile_regs = {
284 .yes_ranges = tas571x_volatile_regs_range,
285 .n_yes_ranges = ARRAY_SIZE(tas571x_volatile_regs_range),
286
287};
288
244static const struct reg_default tas5711_reg_defaults[] = { 289static const struct reg_default tas5711_reg_defaults[] = {
245 { 0x04, 0x05 }, 290 { 0x04, 0x05 },
246 { 0x05, 0x40 }, 291 { 0x05, 0x40 },
@@ -260,6 +305,8 @@ static const struct regmap_config tas5711_regmap_config = {
260 .reg_defaults = tas5711_reg_defaults, 305 .reg_defaults = tas5711_reg_defaults,
261 .num_reg_defaults = ARRAY_SIZE(tas5711_reg_defaults), 306 .num_reg_defaults = ARRAY_SIZE(tas5711_reg_defaults),
262 .cache_type = REGCACHE_RBTREE, 307 .cache_type = REGCACHE_RBTREE,
308 .wr_table = &tas571x_write_regs,
309 .volatile_table = &tas571x_volatile_regs,
263}; 310};
264 311
265static const struct tas571x_chip tas5711_chip = { 312static const struct tas571x_chip tas5711_chip = {
@@ -314,6 +361,8 @@ static const struct regmap_config tas5717_regmap_config = {
314 .reg_defaults = tas5717_reg_defaults, 361 .reg_defaults = tas5717_reg_defaults,
315 .num_reg_defaults = ARRAY_SIZE(tas5717_reg_defaults), 362 .num_reg_defaults = ARRAY_SIZE(tas5717_reg_defaults),
316 .cache_type = REGCACHE_RBTREE, 363 .cache_type = REGCACHE_RBTREE,
364 .wr_table = &tas571x_write_regs,
365 .volatile_table = &tas571x_volatile_regs,
317}; 366};
318 367
319/* This entry is reused for tas5719 as the software interface is identical. */ 368/* This entry is reused for tas5719 as the software interface is identical. */
@@ -326,6 +375,77 @@ static const struct tas571x_chip tas5717_chip = {
326 .vol_reg_size = 2, 375 .vol_reg_size = 2,
327}; 376};
328 377
378static const char *const tas5721_supply_names[] = {
379 "AVDD",
380 "DVDD",
381 "DRVDD",
382 "PVDD",
383};
384
385static const struct snd_kcontrol_new tas5721_controls[] = {
386 SOC_SINGLE_TLV("Master Volume",
387 TAS571X_MVOL_REG,
388 0, 0xff, 1, tas5711_volume_tlv),
389 SOC_DOUBLE_R_TLV("Speaker Volume",
390 TAS571X_CH1_VOL_REG,
391 TAS571X_CH2_VOL_REG,
392 0, 0xff, 1, tas5711_volume_tlv),
393 SOC_DOUBLE("Speaker Switch",
394 TAS571X_SOFT_MUTE_REG,
395 TAS571X_SOFT_MUTE_CH1_SHIFT, TAS571X_SOFT_MUTE_CH2_SHIFT,
396 1, 1),
397};
398
399static const struct reg_default tas5721_reg_defaults[] = {
400 {TAS571X_CLK_CTRL_REG, 0x6c},
401 {TAS571X_DEV_ID_REG, 0x00},
402 {TAS571X_ERR_STATUS_REG, 0x00},
403 {TAS571X_SYS_CTRL_1_REG, 0xa0},
404 {TAS571X_SDI_REG, 0x05},
405 {TAS571X_SYS_CTRL_2_REG, 0x40},
406 {TAS571X_SOFT_MUTE_REG, 0x00},
407 {TAS571X_MVOL_REG, 0xff},
408 {TAS571X_CH1_VOL_REG, 0x30},
409 {TAS571X_CH2_VOL_REG, 0x30},
410 {TAS571X_CH3_VOL_REG, 0x30},
411 {TAS571X_VOL_CFG_REG, 0x91},
412 {TAS571X_MODULATION_LIMIT_REG, 0x02},
413 {TAS571X_IC_DELAY_CH1_REG, 0xac},
414 {TAS571X_IC_DELAY_CH2_REG, 0x54},
415 {TAS571X_IC_DELAY_CH3_REG, 0xac},
416 {TAS571X_IC_DELAY_CH4_REG, 0x54},
417 {TAS571X_PWM_CH_SDN_GROUP_REG, 0x30},
418 {TAS571X_START_STOP_PERIOD_REG, 0x0f},
419 {TAS571X_OSC_TRIM_REG, 0x82},
420 {TAS571X_BKND_ERR_REG, 0x02},
421 {TAS571X_INPUT_MUX_REG, 0x17772},
422 {TAS571X_CH4_SRC_SELECT_REG, 0x4303},
423 {TAS571X_PWM_MUX_REG, 0x1021345},
424};
425
426static const struct regmap_config tas5721_regmap_config = {
427 .reg_bits = 8,
428 .val_bits = 32,
429 .max_register = 0xff,
430 .reg_read = tas571x_reg_read,
431 .reg_write = tas571x_reg_write,
432 .reg_defaults = tas5721_reg_defaults,
433 .num_reg_defaults = ARRAY_SIZE(tas5721_reg_defaults),
434 .cache_type = REGCACHE_RBTREE,
435 .wr_table = &tas571x_write_regs,
436 .volatile_table = &tas571x_volatile_regs,
437};
438
439
440static const struct tas571x_chip tas5721_chip = {
441 .supply_names = tas5721_supply_names,
442 .num_supply_names = ARRAY_SIZE(tas5721_supply_names),
443 .controls = tas5711_controls,
444 .num_controls = ARRAY_SIZE(tas5711_controls),
445 .regmap_config = &tas5721_regmap_config,
446 .vol_reg_size = 1,
447};
448
329static const struct snd_soc_dapm_widget tas571x_dapm_widgets[] = { 449static const struct snd_soc_dapm_widget tas571x_dapm_widgets[] = {
330 SND_SOC_DAPM_DAC("DACL", NULL, SND_SOC_NOPM, 0, 0), 450 SND_SOC_DAPM_DAC("DACL", NULL, SND_SOC_NOPM, 0, 0),
331 SND_SOC_DAPM_DAC("DACR", NULL, SND_SOC_NOPM, 0, 0), 451 SND_SOC_DAPM_DAC("DACR", NULL, SND_SOC_NOPM, 0, 0),
@@ -386,11 +506,10 @@ static int tas571x_i2c_probe(struct i2c_client *client,
386 i2c_set_clientdata(client, priv); 506 i2c_set_clientdata(client, priv);
387 507
388 of_id = of_match_device(tas571x_of_match, dev); 508 of_id = of_match_device(tas571x_of_match, dev);
389 if (!of_id) { 509 if (of_id)
390 dev_err(dev, "Unknown device type\n"); 510 priv->chip = of_id->data;
391 return -EINVAL; 511 else
392 } 512 priv->chip = (void *) id->driver_data;
393 priv->chip = of_id->data;
394 513
395 priv->mclk = devm_clk_get(dev, "mclk"); 514 priv->mclk = devm_clk_get(dev, "mclk");
396 if (IS_ERR(priv->mclk) && PTR_ERR(priv->mclk) != -ENOENT) { 515 if (IS_ERR(priv->mclk) && PTR_ERR(priv->mclk) != -ENOENT) {
@@ -445,10 +564,6 @@ static int tas571x_i2c_probe(struct i2c_client *client,
445 if (ret) 564 if (ret)
446 return ret; 565 return ret;
447 566
448 ret = regmap_update_bits(priv->regmap, TAS571X_SYS_CTRL_2_REG,
449 TAS571X_SYS_CTRL_2_SDN_MASK, 0);
450 if (ret)
451 return ret;
452 567
453 memcpy(&priv->codec_driver, &tas571x_codec, sizeof(priv->codec_driver)); 568 memcpy(&priv->codec_driver, &tas571x_codec, sizeof(priv->codec_driver));
454 priv->codec_driver.controls = priv->chip->controls; 569 priv->codec_driver.controls = priv->chip->controls;
@@ -486,14 +601,16 @@ static const struct of_device_id tas571x_of_match[] = {
486 { .compatible = "ti,tas5711", .data = &tas5711_chip, }, 601 { .compatible = "ti,tas5711", .data = &tas5711_chip, },
487 { .compatible = "ti,tas5717", .data = &tas5717_chip, }, 602 { .compatible = "ti,tas5717", .data = &tas5717_chip, },
488 { .compatible = "ti,tas5719", .data = &tas5717_chip, }, 603 { .compatible = "ti,tas5719", .data = &tas5717_chip, },
604 { .compatible = "ti,tas5721", .data = &tas5721_chip, },
489 { } 605 { }
490}; 606};
491MODULE_DEVICE_TABLE(of, tas571x_of_match); 607MODULE_DEVICE_TABLE(of, tas571x_of_match);
492 608
493static const struct i2c_device_id tas571x_i2c_id[] = { 609static const struct i2c_device_id tas571x_i2c_id[] = {
494 { "tas5711", 0 }, 610 { "tas5711", (kernel_ulong_t) &tas5711_chip },
495 { "tas5717", 0 }, 611 { "tas5717", (kernel_ulong_t) &tas5717_chip },
496 { "tas5719", 0 }, 612 { "tas5719", (kernel_ulong_t) &tas5717_chip },
613 { "tas5721", (kernel_ulong_t) &tas5721_chip },
497 { } 614 { }
498}; 615};
499MODULE_DEVICE_TABLE(i2c, tas571x_i2c_id); 616MODULE_DEVICE_TABLE(i2c, tas571x_i2c_id);
diff --git a/sound/soc/codecs/tas571x.h b/sound/soc/codecs/tas571x.h
index 0aee471232cd..cf800c364f0f 100644
--- a/sound/soc/codecs/tas571x.h
+++ b/sound/soc/codecs/tas571x.h
@@ -13,6 +13,10 @@
13#define _TAS571X_H 13#define _TAS571X_H
14 14
15/* device registers */ 15/* device registers */
16#define TAS571X_CLK_CTRL_REG 0x00
17#define TAS571X_DEV_ID_REG 0x01
18#define TAS571X_ERR_STATUS_REG 0x02
19#define TAS571X_SYS_CTRL_1_REG 0x03
16#define TAS571X_SDI_REG 0x04 20#define TAS571X_SDI_REG 0x04
17#define TAS571X_SDI_FMT_MASK 0x0f 21#define TAS571X_SDI_FMT_MASK 0x0f
18 22
@@ -27,7 +31,25 @@
27#define TAS571X_MVOL_REG 0x07 31#define TAS571X_MVOL_REG 0x07
28#define TAS571X_CH1_VOL_REG 0x08 32#define TAS571X_CH1_VOL_REG 0x08
29#define TAS571X_CH2_VOL_REG 0x09 33#define TAS571X_CH2_VOL_REG 0x09
34#define TAS571X_CH3_VOL_REG 0x0a
35#define TAS571X_VOL_CFG_REG 0x0e
36#define TAS571X_MODULATION_LIMIT_REG 0x10
37#define TAS571X_IC_DELAY_CH1_REG 0x11
38#define TAS571X_IC_DELAY_CH2_REG 0x12
39#define TAS571X_IC_DELAY_CH3_REG 0x13
40#define TAS571X_IC_DELAY_CH4_REG 0x14
30 41
42#define TAS571X_PWM_CH_SDN_GROUP_REG 0x19 /* N/A on TAS5717, TAS5719 */
43#define TAS571X_PWM_CH1_SDN_MASK (1<<0)
44#define TAS571X_PWM_CH2_SDN_SHIFT (1<<1)
45#define TAS571X_PWM_CH3_SDN_SHIFT (1<<2)
46#define TAS571X_PWM_CH4_SDN_SHIFT (1<<3)
47
48#define TAS571X_START_STOP_PERIOD_REG 0x1a
31#define TAS571X_OSC_TRIM_REG 0x1b 49#define TAS571X_OSC_TRIM_REG 0x1b
50#define TAS571X_BKND_ERR_REG 0x1c
51#define TAS571X_INPUT_MUX_REG 0x20
52#define TAS571X_CH4_SRC_SELECT_REG 0x21
53#define TAS571X_PWM_MUX_REG 0x25
32 54
33#endif /* _TAS571X_H */ 55#endif /* _TAS571X_H */
diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c
new file mode 100644
index 000000000000..f54fb46b77c2
--- /dev/null
+++ b/sound/soc/codecs/tas5720.c
@@ -0,0 +1,620 @@
1/*
2 * tas5720.c - ALSA SoC Texas Instruments TAS5720 Mono Audio Amplifier
3 *
4 * Copyright (C)2015-2016 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Author: Andreas Dannenberg <dannenberg@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#include <linux/module.h>
19#include <linux/errno.h>
20#include <linux/device.h>
21#include <linux/i2c.h>
22#include <linux/pm_runtime.h>
23#include <linux/regmap.h>
24#include <linux/slab.h>
25#include <linux/regulator/consumer.h>
26#include <linux/delay.h>
27
28#include <sound/pcm.h>
29#include <sound/pcm_params.h>
30#include <sound/soc.h>
31#include <sound/soc-dapm.h>
32#include <sound/tlv.h>
33
34#include "tas5720.h"
35
36/* Define how often to check (and clear) the fault status register (in ms) */
37#define TAS5720_FAULT_CHECK_INTERVAL 200
38
39static const char * const tas5720_supply_names[] = {
40 "dvdd", /* Digital power supply. Connect to 3.3-V supply. */
41 "pvdd", /* Class-D amp and analog power supply (connected). */
42};
43
44#define TAS5720_NUM_SUPPLIES ARRAY_SIZE(tas5720_supply_names)
45
46struct tas5720_data {
47 struct snd_soc_codec *codec;
48 struct regmap *regmap;
49 struct i2c_client *tas5720_client;
50 struct regulator_bulk_data supplies[TAS5720_NUM_SUPPLIES];
51 struct delayed_work fault_check_work;
52 unsigned int last_fault;
53};
54
55static int tas5720_hw_params(struct snd_pcm_substream *substream,
56 struct snd_pcm_hw_params *params,
57 struct snd_soc_dai *dai)
58{
59 struct snd_soc_codec *codec = dai->codec;
60 unsigned int rate = params_rate(params);
61 bool ssz_ds;
62 int ret;
63
64 switch (rate) {
65 case 44100:
66 case 48000:
67 ssz_ds = false;
68 break;
69 case 88200:
70 case 96000:
71 ssz_ds = true;
72 break;
73 default:
74 dev_err(codec->dev, "unsupported sample rate: %u\n", rate);
75 return -EINVAL;
76 }
77
78 ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG,
79 TAS5720_SSZ_DS, ssz_ds);
80 if (ret < 0) {
81 dev_err(codec->dev, "error setting sample rate: %d\n", ret);
82 return ret;
83 }
84
85 return 0;
86}
87
88static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
89{
90 struct snd_soc_codec *codec = dai->codec;
91 u8 serial_format;
92 int ret;
93
94 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) {
95 dev_vdbg(codec->dev, "DAI Format master is not found\n");
96 return -EINVAL;
97 }
98
99 switch (fmt & (SND_SOC_DAIFMT_FORMAT_MASK |
100 SND_SOC_DAIFMT_INV_MASK)) {
101 case (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF):
102 /* 1st data bit occur one BCLK cycle after the frame sync */
103 serial_format = TAS5720_SAIF_I2S;
104 break;
105 case (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF):
106 /*
107 * Note that although the TAS5720 does not have a dedicated DSP
108 * mode it doesn't care about the LRCLK duty cycle during TDM
109 * operation. Therefore we can use the device's I2S mode with
110 * its delaying of the 1st data bit to receive DSP_A formatted
111 * data. See device datasheet for additional details.
112 */
113 serial_format = TAS5720_SAIF_I2S;
114 break;
115 case (SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF):
116 /*
117 * Similar to DSP_A, we can use the fact that the TAS5720 does
118 * not care about the LRCLK duty cycle during TDM to receive
119 * DSP_B formatted data in LEFTJ mode (no delaying of the 1st
120 * data bit).
121 */
122 serial_format = TAS5720_SAIF_LEFTJ;
123 break;
124 case (SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF):
125 /* No delay after the frame sync */
126 serial_format = TAS5720_SAIF_LEFTJ;
127 break;
128 default:
129 dev_vdbg(codec->dev, "DAI Format is not found\n");
130 return -EINVAL;
131 }
132
133 ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG,
134 TAS5720_SAIF_FORMAT_MASK,
135 serial_format);
136 if (ret < 0) {
137 dev_err(codec->dev, "error setting SAIF format: %d\n", ret);
138 return ret;
139 }
140
141 return 0;
142}
143
144static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai,
145 unsigned int tx_mask, unsigned int rx_mask,
146 int slots, int slot_width)
147{
148 struct snd_soc_codec *codec = dai->codec;
149 unsigned int first_slot;
150 int ret;
151
152 if (!tx_mask) {
153 dev_err(codec->dev, "tx masks must not be 0\n");
154 return -EINVAL;
155 }
156
157 /*
158 * Determine the first slot that is being requested. We will only
159 * use the first slot that is found since the TAS5720 is a mono
160 * amplifier.
161 */
162 first_slot = __ffs(tx_mask);
163
164 if (first_slot > 7) {
165 dev_err(codec->dev, "slot selection out of bounds (%u)\n",
166 first_slot);
167 return -EINVAL;
168 }
169
170 /* Enable manual TDM slot selection (instead of I2C ID based) */
171 ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG,
172 TAS5720_TDM_CFG_SRC, TAS5720_TDM_CFG_SRC);
173 if (ret < 0)
174 goto error_snd_soc_update_bits;
175
176 /* Configure the TDM slot to process audio from */
177 ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG,
178 TAS5720_TDM_SLOT_SEL_MASK, first_slot);
179 if (ret < 0)
180 goto error_snd_soc_update_bits;
181
182 return 0;
183
184error_snd_soc_update_bits:
185 dev_err(codec->dev, "error configuring TDM mode: %d\n", ret);
186 return ret;
187}
188
189static int tas5720_mute(struct snd_soc_dai *dai, int mute)
190{
191 struct snd_soc_codec *codec = dai->codec;
192 int ret;
193
194 ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG,
195 TAS5720_MUTE, mute ? TAS5720_MUTE : 0);
196 if (ret < 0) {
197 dev_err(codec->dev, "error (un-)muting device: %d\n", ret);
198 return ret;
199 }
200
201 return 0;
202}
203
204static void tas5720_fault_check_work(struct work_struct *work)
205{
206 struct tas5720_data *tas5720 = container_of(work, struct tas5720_data,
207 fault_check_work.work);
208 struct device *dev = tas5720->codec->dev;
209 unsigned int curr_fault;
210 int ret;
211
212 ret = regmap_read(tas5720->regmap, TAS5720_FAULT_REG, &curr_fault);
213 if (ret < 0) {
214 dev_err(dev, "failed to read FAULT register: %d\n", ret);
215 goto out;
216 }
217
218 /* Check/handle all errors except SAIF clock errors */
219 curr_fault &= TAS5720_OCE | TAS5720_DCE | TAS5720_OTE;
220
221 /*
222 * Only flag errors once for a given occurrence. This is needed as
223 * the TAS5720 will take time clearing the fault condition internally
224 * during which we don't want to bombard the system with the same
225 * error message over and over.
226 */
227 if ((curr_fault & TAS5720_OCE) && !(tas5720->last_fault & TAS5720_OCE))
228 dev_crit(dev, "experienced an over current hardware fault\n");
229
230 if ((curr_fault & TAS5720_DCE) && !(tas5720->last_fault & TAS5720_DCE))
231 dev_crit(dev, "experienced a DC detection fault\n");
232
233 if ((curr_fault & TAS5720_OTE) && !(tas5720->last_fault & TAS5720_OTE))
234 dev_crit(dev, "experienced an over temperature fault\n");
235
236 /* Store current fault value so we can detect any changes next time */
237 tas5720->last_fault = curr_fault;
238
239 if (!curr_fault)
240 goto out;
241
242 /*
243 * Periodically toggle SDZ (shutdown bit) H->L->H to clear any latching
244 * faults as long as a fault condition persists. Always going through
245 * the full sequence no matter the first return value to minimizes
246 * chances for the device to end up in shutdown mode.
247 */
248 ret = regmap_write_bits(tas5720->regmap, TAS5720_POWER_CTRL_REG,
249 TAS5720_SDZ, 0);
250 if (ret < 0)
251 dev_err(dev, "failed to write POWER_CTRL register: %d\n", ret);
252
253 ret = regmap_write_bits(tas5720->regmap, TAS5720_POWER_CTRL_REG,
254 TAS5720_SDZ, TAS5720_SDZ);
255 if (ret < 0)
256 dev_err(dev, "failed to write POWER_CTRL register: %d\n", ret);
257
258out:
259 /* Schedule the next fault check at the specified interval */
260 schedule_delayed_work(&tas5720->fault_check_work,
261 msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL));
262}
263
264static int tas5720_codec_probe(struct snd_soc_codec *codec)
265{
266 struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec);
267 unsigned int device_id;
268 int ret;
269
270 tas5720->codec = codec;
271
272 ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies),
273 tas5720->supplies);
274 if (ret != 0) {
275 dev_err(codec->dev, "failed to enable supplies: %d\n", ret);
276 return ret;
277 }
278
279 ret = regmap_read(tas5720->regmap, TAS5720_DEVICE_ID_REG, &device_id);
280 if (ret < 0) {
281 dev_err(codec->dev, "failed to read device ID register: %d\n",
282 ret);
283 goto probe_fail;
284 }
285
286 if (device_id != TAS5720_DEVICE_ID) {
287 dev_err(codec->dev, "wrong device ID. expected: %u read: %u\n",
288 TAS5720_DEVICE_ID, device_id);
289 ret = -ENODEV;
290 goto probe_fail;
291 }
292
293 /* Set device to mute */
294 ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG,
295 TAS5720_MUTE, TAS5720_MUTE);
296 if (ret < 0)
297 goto error_snd_soc_update_bits;
298
299 /*
300 * Enter shutdown mode - our default when not playing audio - to
301 * minimize current consumption. On the TAS5720 there is no real down
302 * side doing so as all device registers are preserved and the wakeup
303 * of the codec is rather quick which we do using a dapm widget.
304 */
305 ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG,
306 TAS5720_SDZ, 0);
307 if (ret < 0)
308 goto error_snd_soc_update_bits;
309
310 INIT_DELAYED_WORK(&tas5720->fault_check_work, tas5720_fault_check_work);
311
312 return 0;
313
314error_snd_soc_update_bits:
315 dev_err(codec->dev, "error configuring device registers: %d\n", ret);
316
317probe_fail:
318 regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
319 tas5720->supplies);
320 return ret;
321}
322
323static int tas5720_codec_remove(struct snd_soc_codec *codec)
324{
325 struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec);
326 int ret;
327
328 cancel_delayed_work_sync(&tas5720->fault_check_work);
329
330 ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
331 tas5720->supplies);
332 if (ret < 0)
333 dev_err(codec->dev, "failed to disable supplies: %d\n", ret);
334
335 return ret;
336};
337
338static int tas5720_dac_event(struct snd_soc_dapm_widget *w,
339 struct snd_kcontrol *kcontrol, int event)
340{
341 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
342 struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec);
343 int ret;
344
345 if (event & SND_SOC_DAPM_POST_PMU) {
346 /* Take TAS5720 out of shutdown mode */
347 ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG,
348 TAS5720_SDZ, TAS5720_SDZ);
349 if (ret < 0) {
350 dev_err(codec->dev, "error waking codec: %d\n", ret);
351 return ret;
352 }
353
354 /*
355 * Observe codec shutdown-to-active time. The datasheet only
356 * lists a nominal value however just use-it as-is without
357 * additional padding to minimize the delay introduced in
358 * starting to play audio (actually there is other setup done
359 * by the ASoC framework that will provide additional delays,
360 * so we should always be safe).
361 */
362 msleep(25);
363
364 /* Turn on TAS5720 periodic fault checking/handling */
365 tas5720->last_fault = 0;
366 schedule_delayed_work(&tas5720->fault_check_work,
367 msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL));
368 } else if (event & SND_SOC_DAPM_PRE_PMD) {
369 /* Disable TAS5720 periodic fault checking/handling */
370 cancel_delayed_work_sync(&tas5720->fault_check_work);
371
372 /* Place TAS5720 in shutdown mode to minimize current draw */
373 ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG,
374 TAS5720_SDZ, 0);
375 if (ret < 0) {
376 dev_err(codec->dev, "error shutting down codec: %d\n",
377 ret);
378 return ret;
379 }
380 }
381
382 return 0;
383}
384
385#ifdef CONFIG_PM
386static int tas5720_suspend(struct snd_soc_codec *codec)
387{
388 struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec);
389 int ret;
390
391 regcache_cache_only(tas5720->regmap, true);
392 regcache_mark_dirty(tas5720->regmap);
393
394 ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
395 tas5720->supplies);
396 if (ret < 0)
397 dev_err(codec->dev, "failed to disable supplies: %d\n", ret);
398
399 return ret;
400}
401
402static int tas5720_resume(struct snd_soc_codec *codec)
403{
404 struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec);
405 int ret;
406
407 ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies),
408 tas5720->supplies);
409 if (ret < 0) {
410 dev_err(codec->dev, "failed to enable supplies: %d\n", ret);
411 return ret;
412 }
413
414 regcache_cache_only(tas5720->regmap, false);
415
416 ret = regcache_sync(tas5720->regmap);
417 if (ret < 0) {
418 dev_err(codec->dev, "failed to sync regcache: %d\n", ret);
419 return ret;
420 }
421
422 return 0;
423}
424#else
425#define tas5720_suspend NULL
426#define tas5720_resume NULL
427#endif
428
429static bool tas5720_is_volatile_reg(struct device *dev, unsigned int reg)
430{
431 switch (reg) {
432 case TAS5720_DEVICE_ID_REG:
433 case TAS5720_FAULT_REG:
434 return true;
435 default:
436 return false;
437 }
438}
439
440static const struct regmap_config tas5720_regmap_config = {
441 .reg_bits = 8,
442 .val_bits = 8,
443
444 .max_register = TAS5720_MAX_REG,
445 .cache_type = REGCACHE_RBTREE,
446 .volatile_reg = tas5720_is_volatile_reg,
447};
448
449/*
450 * DAC analog gain. There are four discrete values to select from, ranging
451 * from 19.2 dB to 26.3dB.
452 */
453static const DECLARE_TLV_DB_RANGE(dac_analog_tlv,
454 0x0, 0x0, TLV_DB_SCALE_ITEM(1920, 0, 0),
455 0x1, 0x1, TLV_DB_SCALE_ITEM(2070, 0, 0),
456 0x2, 0x2, TLV_DB_SCALE_ITEM(2350, 0, 0),
457 0x3, 0x3, TLV_DB_SCALE_ITEM(2630, 0, 0),
458);
459
460/*
461 * DAC digital volumes. From -103.5 to 24 dB in 0.5 dB steps. Note that
462 * setting the gain below -100 dB (register value <0x7) is effectively a MUTE
463 * as per device datasheet.
464 */
465static DECLARE_TLV_DB_SCALE(dac_tlv, -10350, 50, 0);
466
467static const struct snd_kcontrol_new tas5720_snd_controls[] = {
468 SOC_SINGLE_TLV("Speaker Driver Playback Volume",
469 TAS5720_VOLUME_CTRL_REG, 0, 0xff, 0, dac_tlv),
470 SOC_SINGLE_TLV("Speaker Driver Analog Gain", TAS5720_ANALOG_CTRL_REG,
471 TAS5720_ANALOG_GAIN_SHIFT, 3, 0, dac_analog_tlv),
472};
473
474static const struct snd_soc_dapm_widget tas5720_dapm_widgets[] = {
475 SND_SOC_DAPM_AIF_IN("DAC IN", "Playback", 0, SND_SOC_NOPM, 0, 0),
476 SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas5720_dac_event,
477 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
478 SND_SOC_DAPM_OUTPUT("OUT")
479};
480
481static const struct snd_soc_dapm_route tas5720_audio_map[] = {
482 { "DAC", NULL, "DAC IN" },
483 { "OUT", NULL, "DAC" },
484};
485
486static struct snd_soc_codec_driver soc_codec_dev_tas5720 = {
487 .probe = tas5720_codec_probe,
488 .remove = tas5720_codec_remove,
489 .suspend = tas5720_suspend,
490 .resume = tas5720_resume,
491
492 .controls = tas5720_snd_controls,
493 .num_controls = ARRAY_SIZE(tas5720_snd_controls),
494 .dapm_widgets = tas5720_dapm_widgets,
495 .num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets),
496 .dapm_routes = tas5720_audio_map,
497 .num_dapm_routes = ARRAY_SIZE(tas5720_audio_map),
498};
499
500/* PCM rates supported by the TAS5720 driver */
501#define TAS5720_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
502 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
503
504/* Formats supported by TAS5720 driver */
505#define TAS5720_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |\
506 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE)
507
508static struct snd_soc_dai_ops tas5720_speaker_dai_ops = {
509 .hw_params = tas5720_hw_params,
510 .set_fmt = tas5720_set_dai_fmt,
511 .set_tdm_slot = tas5720_set_dai_tdm_slot,
512 .digital_mute = tas5720_mute,
513};
514
515/*
516 * TAS5720 DAI structure
517 *
518 * Note that were are advertising .playback.channels_max = 2 despite this being
519 * a mono amplifier. The reason for that is that some serial ports such as TI's
520 * McASP module have a minimum number of channels (2) that they can output.
521 * Advertising more channels than we have will allow us to interface with such
522 * a serial port without really any negative side effects as the TAS5720 will
523 * simply ignore any extra channel(s) asides from the one channel that is
524 * configured to be played back.
525 */
526static struct snd_soc_dai_driver tas5720_dai[] = {
527 {
528 .name = "tas5720-amplifier",
529 .playback = {
530 .stream_name = "Playback",
531 .channels_min = 1,
532 .channels_max = 2,
533 .rates = TAS5720_RATES,
534 .formats = TAS5720_FORMATS,
535 },
536 .ops = &tas5720_speaker_dai_ops,
537 },
538};
539
540static int tas5720_probe(struct i2c_client *client,
541 const struct i2c_device_id *id)
542{
543 struct device *dev = &client->dev;
544 struct tas5720_data *data;
545 int ret;
546 int i;
547
548 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
549 if (!data)
550 return -ENOMEM;
551
552 data->tas5720_client = client;
553 data->regmap = devm_regmap_init_i2c(client, &tas5720_regmap_config);
554 if (IS_ERR(data->regmap)) {
555 ret = PTR_ERR(data->regmap);
556 dev_err(dev, "failed to allocate register map: %d\n", ret);
557 return ret;
558 }
559
560 for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
561 data->supplies[i].supply = tas5720_supply_names[i];
562
563 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies),
564 data->supplies);
565 if (ret != 0) {
566 dev_err(dev, "failed to request supplies: %d\n", ret);
567 return ret;
568 }
569
570 dev_set_drvdata(dev, data);
571
572 ret = snd_soc_register_codec(&client->dev,
573 &soc_codec_dev_tas5720,
574 tas5720_dai, ARRAY_SIZE(tas5720_dai));
575 if (ret < 0) {
576 dev_err(dev, "failed to register codec: %d\n", ret);
577 return ret;
578 }
579
580 return 0;
581}
582
583static int tas5720_remove(struct i2c_client *client)
584{
585 struct device *dev = &client->dev;
586
587 snd_soc_unregister_codec(dev);
588
589 return 0;
590}
591
592static const struct i2c_device_id tas5720_id[] = {
593 { "tas5720", 0 },
594 { }
595};
596MODULE_DEVICE_TABLE(i2c, tas5720_id);
597
598#if IS_ENABLED(CONFIG_OF)
599static const struct of_device_id tas5720_of_match[] = {
600 { .compatible = "ti,tas5720", },
601 { },
602};
603MODULE_DEVICE_TABLE(of, tas5720_of_match);
604#endif
605
606static struct i2c_driver tas5720_i2c_driver = {
607 .driver = {
608 .name = "tas5720",
609 .of_match_table = of_match_ptr(tas5720_of_match),
610 },
611 .probe = tas5720_probe,
612 .remove = tas5720_remove,
613 .id_table = tas5720_id,
614};
615
616module_i2c_driver(tas5720_i2c_driver);
617
618MODULE_AUTHOR("Andreas Dannenberg <dannenberg@ti.com>");
619MODULE_DESCRIPTION("TAS5720 Audio amplifier driver");
620MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/tas5720.h b/sound/soc/codecs/tas5720.h
new file mode 100644
index 000000000000..3d077c779b12
--- /dev/null
+++ b/sound/soc/codecs/tas5720.h
@@ -0,0 +1,90 @@
1/*
2 * tas5720.h - ALSA SoC Texas Instruments TAS5720 Mono Audio Amplifier
3 *
4 * Copyright (C)2015-2016 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Author: Andreas Dannenberg <dannenberg@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __TAS5720_H__
19#define __TAS5720_H__
20
21/* Register Address Map */
22#define TAS5720_DEVICE_ID_REG 0x00
23#define TAS5720_POWER_CTRL_REG 0x01
24#define TAS5720_DIGITAL_CTRL1_REG 0x02
25#define TAS5720_DIGITAL_CTRL2_REG 0x03
26#define TAS5720_VOLUME_CTRL_REG 0x04
27#define TAS5720_ANALOG_CTRL_REG 0x06
28#define TAS5720_FAULT_REG 0x08
29#define TAS5720_DIGITAL_CLIP2_REG 0x10
30#define TAS5720_DIGITAL_CLIP1_REG 0x11
31#define TAS5720_MAX_REG TAS5720_DIGITAL_CLIP1_REG
32
33/* TAS5720_DEVICE_ID_REG */
34#define TAS5720_DEVICE_ID 0x01
35
36/* TAS5720_POWER_CTRL_REG */
37#define TAS5720_DIG_CLIP_MASK GENMASK(7, 2)
38#define TAS5720_SLEEP BIT(1)
39#define TAS5720_SDZ BIT(0)
40
41/* TAS5720_DIGITAL_CTRL1_REG */
42#define TAS5720_HPF_BYPASS BIT(7)
43#define TAS5720_TDM_CFG_SRC BIT(6)
44#define TAS5720_SSZ_DS BIT(3)
45#define TAS5720_SAIF_RIGHTJ_24BIT (0x0)
46#define TAS5720_SAIF_RIGHTJ_20BIT (0x1)
47#define TAS5720_SAIF_RIGHTJ_18BIT (0x2)
48#define TAS5720_SAIF_RIGHTJ_16BIT (0x3)
49#define TAS5720_SAIF_I2S (0x4)
50#define TAS5720_SAIF_LEFTJ (0x5)
51#define TAS5720_SAIF_FORMAT_MASK GENMASK(2, 0)
52
53/* TAS5720_DIGITAL_CTRL2_REG */
54#define TAS5720_MUTE BIT(4)
55#define TAS5720_TDM_SLOT_SEL_MASK GENMASK(2, 0)
56
57/* TAS5720_ANALOG_CTRL_REG */
58#define TAS5720_PWM_RATE_6_3_FSYNC (0x0 << 4)
59#define TAS5720_PWM_RATE_8_4_FSYNC (0x1 << 4)
60#define TAS5720_PWM_RATE_10_5_FSYNC (0x2 << 4)
61#define TAS5720_PWM_RATE_12_6_FSYNC (0x3 << 4)
62#define TAS5720_PWM_RATE_14_7_FSYNC (0x4 << 4)
63#define TAS5720_PWM_RATE_16_8_FSYNC (0x5 << 4)
64#define TAS5720_PWM_RATE_20_10_FSYNC (0x6 << 4)
65#define TAS5720_PWM_RATE_24_12_FSYNC (0x7 << 4)
66#define TAS5720_PWM_RATE_MASK GENMASK(6, 4)
67#define TAS5720_ANALOG_GAIN_19_2DBV (0x0 << 2)
68#define TAS5720_ANALOG_GAIN_20_7DBV (0x1 << 2)
69#define TAS5720_ANALOG_GAIN_23_5DBV (0x2 << 2)
70#define TAS5720_ANALOG_GAIN_26_3DBV (0x3 << 2)
71#define TAS5720_ANALOG_GAIN_MASK GENMASK(3, 2)
72#define TAS5720_ANALOG_GAIN_SHIFT (0x2)
73
74/* TAS5720_FAULT_REG */
75#define TAS5720_OC_THRESH_100PCT (0x0 << 4)
76#define TAS5720_OC_THRESH_75PCT (0x1 << 4)
77#define TAS5720_OC_THRESH_50PCT (0x2 << 4)
78#define TAS5720_OC_THRESH_25PCT (0x3 << 4)
79#define TAS5720_OC_THRESH_MASK GENMASK(5, 4)
80#define TAS5720_CLKE BIT(3)
81#define TAS5720_OCE BIT(2)
82#define TAS5720_DCE BIT(1)
83#define TAS5720_OTE BIT(0)
84#define TAS5720_FAULT_MASK GENMASK(3, 0)
85
86/* TAS5720_DIGITAL_CLIP1_REG */
87#define TAS5720_CLIP1_MASK GENMASK(7, 2)
88#define TAS5720_CLIP1_SHIFT (0x2)
89
90#endif /* __TAS5720_H__ */
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index ee4def4f819f..3c5e1df01c19 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -28,6 +28,7 @@
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/regulator/consumer.h> 30#include <linux/regulator/consumer.h>
31#include <linux/acpi.h>
31#include <linux/of.h> 32#include <linux/of.h>
32#include <linux/of_gpio.h> 33#include <linux/of_gpio.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
@@ -1280,10 +1281,19 @@ static const struct i2c_device_id aic31xx_i2c_id[] = {
1280}; 1281};
1281MODULE_DEVICE_TABLE(i2c, aic31xx_i2c_id); 1282MODULE_DEVICE_TABLE(i2c, aic31xx_i2c_id);
1282 1283
1284#ifdef CONFIG_ACPI
1285static const struct acpi_device_id aic31xx_acpi_match[] = {
1286 { "10TI3100", 0 },
1287 { }
1288};
1289MODULE_DEVICE_TABLE(acpi, aic31xx_acpi_match);
1290#endif
1291
1283static struct i2c_driver aic31xx_i2c_driver = { 1292static struct i2c_driver aic31xx_i2c_driver = {
1284 .driver = { 1293 .driver = {
1285 .name = "tlv320aic31xx-codec", 1294 .name = "tlv320aic31xx-codec",
1286 .of_match_table = of_match_ptr(tlv320aic31xx_of_match), 1295 .of_match_table = of_match_ptr(tlv320aic31xx_of_match),
1296 .acpi_match_table = ACPI_PTR(aic31xx_acpi_match),
1287 }, 1297 },
1288 .probe = aic31xx_i2c_probe, 1298 .probe = aic31xx_i2c_probe,
1289 .remove = aic31xx_i2c_remove, 1299 .remove = aic31xx_i2c_remove,
diff --git a/sound/soc/codecs/tlv320aic32x4-i2c.c b/sound/soc/codecs/tlv320aic32x4-i2c.c
new file mode 100644
index 000000000000..59606cf3008f
--- /dev/null
+++ b/sound/soc/codecs/tlv320aic32x4-i2c.c
@@ -0,0 +1,74 @@
1/*
2 * linux/sound/soc/codecs/tlv320aic32x4-i2c.c
3 *
4 * Copyright 2011 NW Digital Radio
5 *
6 * Author: Jeremy McDermond <nh6z@nh6z.net>
7 *
8 * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 */
20
21#include <linux/i2c.h>
22#include <linux/module.h>
23#include <linux/of.h>
24#include <linux/regmap.h>
25#include <sound/soc.h>
26
27#include "tlv320aic32x4.h"
28
29static int aic32x4_i2c_probe(struct i2c_client *i2c,
30 const struct i2c_device_id *id)
31{
32 struct regmap *regmap;
33 struct regmap_config config;
34
35 config = aic32x4_regmap_config;
36 config.reg_bits = 8;
37 config.val_bits = 8;
38
39 regmap = devm_regmap_init_i2c(i2c, &config);
40 return aic32x4_probe(&i2c->dev, regmap);
41}
42
43static int aic32x4_i2c_remove(struct i2c_client *i2c)
44{
45 return aic32x4_remove(&i2c->dev);
46}
47
48static const struct i2c_device_id aic32x4_i2c_id[] = {
49 { "tlv320aic32x4", 0 },
50 { /* sentinel */ }
51};
52MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
53
54static const struct of_device_id aic32x4_of_id[] = {
55 { .compatible = "ti,tlv320aic32x4", },
56 { /* senitel */ }
57};
58MODULE_DEVICE_TABLE(of, aic32x4_of_id);
59
60static struct i2c_driver aic32x4_i2c_driver = {
61 .driver = {
62 .name = "tlv320aic32x4",
63 .of_match_table = aic32x4_of_id,
64 },
65 .probe = aic32x4_i2c_probe,
66 .remove = aic32x4_i2c_remove,
67 .id_table = aic32x4_i2c_id,
68};
69
70module_i2c_driver(aic32x4_i2c_driver);
71
72MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C");
73MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>");
74MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/tlv320aic32x4-spi.c b/sound/soc/codecs/tlv320aic32x4-spi.c
new file mode 100644
index 000000000000..724fcdd491b2
--- /dev/null
+++ b/sound/soc/codecs/tlv320aic32x4-spi.c
@@ -0,0 +1,76 @@
1/*
2 * linux/sound/soc/codecs/tlv320aic32x4-spi.c
3 *
4 * Copyright 2011 NW Digital Radio
5 *
6 * Author: Jeremy McDermond <nh6z@nh6z.net>
7 *
8 * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 */
20
21#include <linux/spi/spi.h>
22#include <linux/module.h>
23#include <linux/of.h>
24#include <linux/regmap.h>
25#include <sound/soc.h>
26
27#include "tlv320aic32x4.h"
28
29static int aic32x4_spi_probe(struct spi_device *spi)
30{
31 struct regmap *regmap;
32 struct regmap_config config;
33
34 config = aic32x4_regmap_config;
35 config.reg_bits = 7;
36 config.pad_bits = 1;
37 config.val_bits = 8;
38 config.read_flag_mask = 0x01;
39
40 regmap = devm_regmap_init_spi(spi, &config);
41 return aic32x4_probe(&spi->dev, regmap);
42}
43
44static int aic32x4_spi_remove(struct spi_device *spi)
45{
46 return aic32x4_remove(&spi->dev);
47}
48
49static const struct spi_device_id aic32x4_spi_id[] = {
50 { "tlv320aic32x4", 0 },
51 { /* sentinel */ }
52};
53MODULE_DEVICE_TABLE(spi, aic32x4_spi_id);
54
55static const struct of_device_id aic32x4_of_id[] = {
56 { .compatible = "ti,tlv320aic32x4", },
57 { /* senitel */ }
58};
59MODULE_DEVICE_TABLE(of, aic32x4_of_id);
60
61static struct spi_driver aic32x4_spi_driver = {
62 .driver = {
63 .name = "tlv320aic32x4",
64 .owner = THIS_MODULE,
65 .of_match_table = aic32x4_of_id,
66 },
67 .probe = aic32x4_spi_probe,
68 .remove = aic32x4_spi_remove,
69 .id_table = aic32x4_spi_id,
70};
71
72module_spi_driver(aic32x4_spi_driver);
73
74MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver SPI");
75MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>");
76MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index f2d3191961e1..85d4978d0384 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -30,7 +30,6 @@
30#include <linux/pm.h> 30#include <linux/pm.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/of_gpio.h> 32#include <linux/of_gpio.h>
33#include <linux/i2c.h>
34#include <linux/cdev.h> 33#include <linux/cdev.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/clk.h> 35#include <linux/clk.h>
@@ -160,7 +159,10 @@ static const struct aic32x4_rate_divs aic32x4_divs[] = {
160 /* 48k rate */ 159 /* 48k rate */
161 {AIC32X4_FREQ_12000000, 48000, 1, 8, 1920, 128, 2, 8, 128, 2, 8, 4}, 160 {AIC32X4_FREQ_12000000, 48000, 1, 8, 1920, 128, 2, 8, 128, 2, 8, 4},
162 {AIC32X4_FREQ_24000000, 48000, 2, 8, 1920, 128, 8, 2, 64, 8, 4, 4}, 161 {AIC32X4_FREQ_24000000, 48000, 2, 8, 1920, 128, 8, 2, 64, 8, 4, 4},
163 {AIC32X4_FREQ_25000000, 48000, 2, 7, 8643, 128, 8, 2, 64, 8, 4, 4} 162 {AIC32X4_FREQ_25000000, 48000, 2, 7, 8643, 128, 8, 2, 64, 8, 4, 4},
163
164 /* 96k rate */
165 {AIC32X4_FREQ_25000000, 96000, 2, 7, 8643, 64, 4, 4, 64, 4, 4, 1},
164}; 166};
165 167
166static const struct snd_kcontrol_new hpl_output_mixer_controls[] = { 168static const struct snd_kcontrol_new hpl_output_mixer_controls[] = {
@@ -181,16 +183,71 @@ static const struct snd_kcontrol_new lor_output_mixer_controls[] = {
181 SOC_DAPM_SINGLE("R_DAC Switch", AIC32X4_LORROUTE, 3, 1, 0), 183 SOC_DAPM_SINGLE("R_DAC Switch", AIC32X4_LORROUTE, 3, 1, 0),
182}; 184};
183 185
184static const struct snd_kcontrol_new left_input_mixer_controls[] = { 186static const char * const resistor_text[] = {
185 SOC_DAPM_SINGLE("IN1_L P Switch", AIC32X4_LMICPGAPIN, 6, 1, 0), 187 "Off", "10 kOhm", "20 kOhm", "40 kOhm",
186 SOC_DAPM_SINGLE("IN2_L P Switch", AIC32X4_LMICPGAPIN, 4, 1, 0),
187 SOC_DAPM_SINGLE("IN3_L P Switch", AIC32X4_LMICPGAPIN, 2, 1, 0),
188}; 188};
189 189
190static const struct snd_kcontrol_new right_input_mixer_controls[] = { 190/* Left mixer pins */
191 SOC_DAPM_SINGLE("IN1_R P Switch", AIC32X4_RMICPGAPIN, 6, 1, 0), 191static SOC_ENUM_SINGLE_DECL(in1l_lpga_p_enum, AIC32X4_LMICPGAPIN, 6, resistor_text);
192 SOC_DAPM_SINGLE("IN2_R P Switch", AIC32X4_RMICPGAPIN, 4, 1, 0), 192static SOC_ENUM_SINGLE_DECL(in2l_lpga_p_enum, AIC32X4_LMICPGAPIN, 4, resistor_text);
193 SOC_DAPM_SINGLE("IN3_R P Switch", AIC32X4_RMICPGAPIN, 2, 1, 0), 193static SOC_ENUM_SINGLE_DECL(in3l_lpga_p_enum, AIC32X4_LMICPGAPIN, 2, resistor_text);
194static SOC_ENUM_SINGLE_DECL(in1r_lpga_p_enum, AIC32X4_LMICPGAPIN, 0, resistor_text);
195
196static SOC_ENUM_SINGLE_DECL(cml_lpga_n_enum, AIC32X4_LMICPGANIN, 6, resistor_text);
197static SOC_ENUM_SINGLE_DECL(in2r_lpga_n_enum, AIC32X4_LMICPGANIN, 4, resistor_text);
198static SOC_ENUM_SINGLE_DECL(in3r_lpga_n_enum, AIC32X4_LMICPGANIN, 2, resistor_text);
199
200static const struct snd_kcontrol_new in1l_to_lmixer_controls[] = {
201 SOC_DAPM_ENUM("IN1_L L+ Switch", in1l_lpga_p_enum),
202};
203static const struct snd_kcontrol_new in2l_to_lmixer_controls[] = {
204 SOC_DAPM_ENUM("IN2_L L+ Switch", in2l_lpga_p_enum),
205};
206static const struct snd_kcontrol_new in3l_to_lmixer_controls[] = {
207 SOC_DAPM_ENUM("IN3_L L+ Switch", in3l_lpga_p_enum),
208};
209static const struct snd_kcontrol_new in1r_to_lmixer_controls[] = {
210 SOC_DAPM_ENUM("IN1_R L+ Switch", in1r_lpga_p_enum),
211};
212static const struct snd_kcontrol_new cml_to_lmixer_controls[] = {
213 SOC_DAPM_ENUM("CM_L L- Switch", cml_lpga_n_enum),
214};
215static const struct snd_kcontrol_new in2r_to_lmixer_controls[] = {
216 SOC_DAPM_ENUM("IN2_R L- Switch", in2r_lpga_n_enum),
217};
218static const struct snd_kcontrol_new in3r_to_lmixer_controls[] = {
219 SOC_DAPM_ENUM("IN3_R L- Switch", in3r_lpga_n_enum),
220};
221
222/* Right mixer pins */
223static SOC_ENUM_SINGLE_DECL(in1r_rpga_p_enum, AIC32X4_RMICPGAPIN, 6, resistor_text);
224static SOC_ENUM_SINGLE_DECL(in2r_rpga_p_enum, AIC32X4_RMICPGAPIN, 4, resistor_text);
225static SOC_ENUM_SINGLE_DECL(in3r_rpga_p_enum, AIC32X4_RMICPGAPIN, 2, resistor_text);
226static SOC_ENUM_SINGLE_DECL(in2l_rpga_p_enum, AIC32X4_RMICPGAPIN, 0, resistor_text);
227static SOC_ENUM_SINGLE_DECL(cmr_rpga_n_enum, AIC32X4_RMICPGANIN, 6, resistor_text);
228static SOC_ENUM_SINGLE_DECL(in1l_rpga_n_enum, AIC32X4_RMICPGANIN, 4, resistor_text);
229static SOC_ENUM_SINGLE_DECL(in3l_rpga_n_enum, AIC32X4_RMICPGANIN, 2, resistor_text);
230
231static const struct snd_kcontrol_new in1r_to_rmixer_controls[] = {
232 SOC_DAPM_ENUM("IN1_R R+ Switch", in1r_rpga_p_enum),
233};
234static const struct snd_kcontrol_new in2r_to_rmixer_controls[] = {
235 SOC_DAPM_ENUM("IN2_R R+ Switch", in2r_rpga_p_enum),
236};
237static const struct snd_kcontrol_new in3r_to_rmixer_controls[] = {
238 SOC_DAPM_ENUM("IN3_R R+ Switch", in3r_rpga_p_enum),
239};
240static const struct snd_kcontrol_new in2l_to_rmixer_controls[] = {
241 SOC_DAPM_ENUM("IN2_L R+ Switch", in2l_rpga_p_enum),
242};
243static const struct snd_kcontrol_new cmr_to_rmixer_controls[] = {
244 SOC_DAPM_ENUM("CM_R R- Switch", cmr_rpga_n_enum),
245};
246static const struct snd_kcontrol_new in1l_to_rmixer_controls[] = {
247 SOC_DAPM_ENUM("IN1_L R- Switch", in1l_rpga_n_enum),
248};
249static const struct snd_kcontrol_new in3l_to_rmixer_controls[] = {
250 SOC_DAPM_ENUM("IN3_L R- Switch", in3l_rpga_n_enum),
194}; 251};
195 252
196static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { 253static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
@@ -214,14 +271,39 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
214 &lor_output_mixer_controls[0], 271 &lor_output_mixer_controls[0],
215 ARRAY_SIZE(lor_output_mixer_controls)), 272 ARRAY_SIZE(lor_output_mixer_controls)),
216 SND_SOC_DAPM_PGA("LOR Power", AIC32X4_OUTPWRCTL, 2, 0, NULL, 0), 273 SND_SOC_DAPM_PGA("LOR Power", AIC32X4_OUTPWRCTL, 2, 0, NULL, 0),
217 SND_SOC_DAPM_MIXER("Left Input Mixer", SND_SOC_NOPM, 0, 0, 274
218 &left_input_mixer_controls[0],
219 ARRAY_SIZE(left_input_mixer_controls)),
220 SND_SOC_DAPM_MIXER("Right Input Mixer", SND_SOC_NOPM, 0, 0,
221 &right_input_mixer_controls[0],
222 ARRAY_SIZE(right_input_mixer_controls)),
223 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", AIC32X4_ADCSETUP, 7, 0),
224 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", AIC32X4_ADCSETUP, 6, 0), 275 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", AIC32X4_ADCSETUP, 6, 0),
276 SND_SOC_DAPM_MUX("IN1_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
277 in1r_to_rmixer_controls),
278 SND_SOC_DAPM_MUX("IN2_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
279 in2r_to_rmixer_controls),
280 SND_SOC_DAPM_MUX("IN3_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
281 in3r_to_rmixer_controls),
282 SND_SOC_DAPM_MUX("IN2_L to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
283 in2l_to_rmixer_controls),
284 SND_SOC_DAPM_MUX("CM_R to Right Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
285 cmr_to_rmixer_controls),
286 SND_SOC_DAPM_MUX("IN1_L to Right Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
287 in1l_to_rmixer_controls),
288 SND_SOC_DAPM_MUX("IN3_L to Right Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
289 in3l_to_rmixer_controls),
290
291 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", AIC32X4_ADCSETUP, 7, 0),
292 SND_SOC_DAPM_MUX("IN1_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
293 in1l_to_lmixer_controls),
294 SND_SOC_DAPM_MUX("IN2_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
295 in2l_to_lmixer_controls),
296 SND_SOC_DAPM_MUX("IN3_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
297 in3l_to_lmixer_controls),
298 SND_SOC_DAPM_MUX("IN1_R to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
299 in1r_to_lmixer_controls),
300 SND_SOC_DAPM_MUX("CM_L to Left Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
301 cml_to_lmixer_controls),
302 SND_SOC_DAPM_MUX("IN2_R to Left Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
303 in2r_to_lmixer_controls),
304 SND_SOC_DAPM_MUX("IN3_R to Left Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
305 in3r_to_lmixer_controls),
306
225 SND_SOC_DAPM_MICBIAS("Mic Bias", AIC32X4_MICBIAS, 6, 0), 307 SND_SOC_DAPM_MICBIAS("Mic Bias", AIC32X4_MICBIAS, 6, 0),
226 308
227 SND_SOC_DAPM_OUTPUT("HPL"), 309 SND_SOC_DAPM_OUTPUT("HPL"),
@@ -261,19 +343,77 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
261 {"LOR Power", NULL, "LOR Output Mixer"}, 343 {"LOR Power", NULL, "LOR Output Mixer"},
262 {"LOR", NULL, "LOR Power"}, 344 {"LOR", NULL, "LOR Power"},
263 345
264 /* Left input */
265 {"Left Input Mixer", "IN1_L P Switch", "IN1_L"},
266 {"Left Input Mixer", "IN2_L P Switch", "IN2_L"},
267 {"Left Input Mixer", "IN3_L P Switch", "IN3_L"},
268
269 {"Left ADC", NULL, "Left Input Mixer"},
270
271 /* Right Input */ 346 /* Right Input */
272 {"Right Input Mixer", "IN1_R P Switch", "IN1_R"}, 347 {"Right ADC", NULL, "IN1_R to Right Mixer Positive Resistor"},
273 {"Right Input Mixer", "IN2_R P Switch", "IN2_R"}, 348 {"IN1_R to Right Mixer Positive Resistor", "10 kOhm", "IN1_R"},
274 {"Right Input Mixer", "IN3_R P Switch", "IN3_R"}, 349 {"IN1_R to Right Mixer Positive Resistor", "20 kOhm", "IN1_R"},
275 350 {"IN1_R to Right Mixer Positive Resistor", "40 kOhm", "IN1_R"},
276 {"Right ADC", NULL, "Right Input Mixer"}, 351
352 {"Right ADC", NULL, "IN2_R to Right Mixer Positive Resistor"},
353 {"IN2_R to Right Mixer Positive Resistor", "10 kOhm", "IN2_R"},
354 {"IN2_R to Right Mixer Positive Resistor", "20 kOhm", "IN2_R"},
355 {"IN2_R to Right Mixer Positive Resistor", "40 kOhm", "IN2_R"},
356
357 {"Right ADC", NULL, "IN3_R to Right Mixer Positive Resistor"},
358 {"IN3_R to Right Mixer Positive Resistor", "10 kOhm", "IN3_R"},
359 {"IN3_R to Right Mixer Positive Resistor", "20 kOhm", "IN3_R"},
360 {"IN3_R to Right Mixer Positive Resistor", "40 kOhm", "IN3_R"},
361
362 {"Right ADC", NULL, "IN2_L to Right Mixer Positive Resistor"},
363 {"IN2_L to Right Mixer Positive Resistor", "10 kOhm", "IN2_L"},
364 {"IN2_L to Right Mixer Positive Resistor", "20 kOhm", "IN2_L"},
365 {"IN2_L to Right Mixer Positive Resistor", "40 kOhm", "IN2_L"},
366
367 {"Right ADC", NULL, "CM_R to Right Mixer Negative Resistor"},
368 {"CM_R to Right Mixer Negative Resistor", "10 kOhm", "CM_R"},
369 {"CM_R to Right Mixer Negative Resistor", "20 kOhm", "CM_R"},
370 {"CM_R to Right Mixer Negative Resistor", "40 kOhm", "CM_R"},
371
372 {"Right ADC", NULL, "IN1_L to Right Mixer Negative Resistor"},
373 {"IN1_L to Right Mixer Negative Resistor", "10 kOhm", "IN1_L"},
374 {"IN1_L to Right Mixer Negative Resistor", "20 kOhm", "IN1_L"},
375 {"IN1_L to Right Mixer Negative Resistor", "40 kOhm", "IN1_L"},
376
377 {"Right ADC", NULL, "IN3_L to Right Mixer Negative Resistor"},
378 {"IN3_L to Right Mixer Negative Resistor", "10 kOhm", "IN3_L"},
379 {"IN3_L to Right Mixer Negative Resistor", "20 kOhm", "IN3_L"},
380 {"IN3_L to Right Mixer Negative Resistor", "40 kOhm", "IN3_L"},
381
382 /* Left Input */
383 {"Left ADC", NULL, "IN1_L to Left Mixer Positive Resistor"},
384 {"IN1_L to Left Mixer Positive Resistor", "10 kOhm", "IN1_L"},
385 {"IN1_L to Left Mixer Positive Resistor", "20 kOhm", "IN1_L"},
386 {"IN1_L to Left Mixer Positive Resistor", "40 kOhm", "IN1_L"},
387
388 {"Left ADC", NULL, "IN2_L to Left Mixer Positive Resistor"},
389 {"IN2_L to Left Mixer Positive Resistor", "10 kOhm", "IN2_L"},
390 {"IN2_L to Left Mixer Positive Resistor", "20 kOhm", "IN2_L"},
391 {"IN2_L to Left Mixer Positive Resistor", "40 kOhm", "IN2_L"},
392
393 {"Left ADC", NULL, "IN3_L to Left Mixer Positive Resistor"},
394 {"IN3_L to Left Mixer Positive Resistor", "10 kOhm", "IN3_L"},
395 {"IN3_L to Left Mixer Positive Resistor", "20 kOhm", "IN3_L"},
396 {"IN3_L to Left Mixer Positive Resistor", "40 kOhm", "IN3_L"},
397
398 {"Left ADC", NULL, "IN1_R to Left Mixer Positive Resistor"},
399 {"IN1_R to Left Mixer Positive Resistor", "10 kOhm", "IN1_R"},
400 {"IN1_R to Left Mixer Positive Resistor", "20 kOhm", "IN1_R"},
401 {"IN1_R to Left Mixer Positive Resistor", "40 kOhm", "IN1_R"},
402
403 {"Left ADC", NULL, "CM_L to Left Mixer Negative Resistor"},
404 {"CM_L to Left Mixer Negative Resistor", "10 kOhm", "CM_L"},
405 {"CM_L to Left Mixer Negative Resistor", "20 kOhm", "CM_L"},
406 {"CM_L to Left Mixer Negative Resistor", "40 kOhm", "CM_L"},
407
408 {"Left ADC", NULL, "IN2_R to Left Mixer Negative Resistor"},
409 {"IN2_R to Left Mixer Negative Resistor", "10 kOhm", "IN2_R"},
410 {"IN2_R to Left Mixer Negative Resistor", "20 kOhm", "IN2_R"},
411 {"IN2_R to Left Mixer Negative Resistor", "40 kOhm", "IN2_R"},
412
413 {"Left ADC", NULL, "IN3_R to Left Mixer Negative Resistor"},
414 {"IN3_R to Left Mixer Negative Resistor", "10 kOhm", "IN3_R"},
415 {"IN3_R to Left Mixer Negative Resistor", "20 kOhm", "IN3_R"},
416 {"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"},
277}; 417};
278 418
279static const struct regmap_range_cfg aic32x4_regmap_pages[] = { 419static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
@@ -287,14 +427,12 @@ static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
287 }, 427 },
288}; 428};
289 429
290static const struct regmap_config aic32x4_regmap = { 430const struct regmap_config aic32x4_regmap_config = {
291 .reg_bits = 8,
292 .val_bits = 8,
293
294 .max_register = AIC32X4_RMICPGAVOL, 431 .max_register = AIC32X4_RMICPGAVOL,
295 .ranges = aic32x4_regmap_pages, 432 .ranges = aic32x4_regmap_pages,
296 .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages), 433 .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages),
297}; 434};
435EXPORT_SYMBOL(aic32x4_regmap_config);
298 436
299static inline int aic32x4_get_divs(int mclk, int rate) 437static inline int aic32x4_get_divs(int mclk, int rate)
300{ 438{
@@ -567,7 +705,7 @@ static int aic32x4_set_bias_level(struct snd_soc_codec *codec,
567 return 0; 705 return 0;
568} 706}
569 707
570#define AIC32X4_RATES SNDRV_PCM_RATE_8000_48000 708#define AIC32X4_RATES SNDRV_PCM_RATE_8000_96000
571#define AIC32X4_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \ 709#define AIC32X4_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \
572 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) 710 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)
573 711
@@ -596,7 +734,7 @@ static struct snd_soc_dai_driver aic32x4_dai = {
596 .symmetric_rates = 1, 734 .symmetric_rates = 1,
597}; 735};
598 736
599static int aic32x4_probe(struct snd_soc_codec *codec) 737static int aic32x4_codec_probe(struct snd_soc_codec *codec)
600{ 738{
601 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); 739 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
602 u32 tmp_reg; 740 u32 tmp_reg;
@@ -655,7 +793,7 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
655} 793}
656 794
657static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { 795static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = {
658 .probe = aic32x4_probe, 796 .probe = aic32x4_codec_probe,
659 .set_bias_level = aic32x4_set_bias_level, 797 .set_bias_level = aic32x4_set_bias_level,
660 .suspend_bias_off = true, 798 .suspend_bias_off = true,
661 799
@@ -777,24 +915,22 @@ error_ldo:
777 return ret; 915 return ret;
778} 916}
779 917
780static int aic32x4_i2c_probe(struct i2c_client *i2c, 918int aic32x4_probe(struct device *dev, struct regmap *regmap)
781 const struct i2c_device_id *id)
782{ 919{
783 struct aic32x4_pdata *pdata = i2c->dev.platform_data;
784 struct aic32x4_priv *aic32x4; 920 struct aic32x4_priv *aic32x4;
785 struct device_node *np = i2c->dev.of_node; 921 struct aic32x4_pdata *pdata = dev->platform_data;
922 struct device_node *np = dev->of_node;
786 int ret; 923 int ret;
787 924
788 aic32x4 = devm_kzalloc(&i2c->dev, sizeof(struct aic32x4_priv), 925 if (IS_ERR(regmap))
926 return PTR_ERR(regmap);
927
928 aic32x4 = devm_kzalloc(dev, sizeof(struct aic32x4_priv),
789 GFP_KERNEL); 929 GFP_KERNEL);
790 if (aic32x4 == NULL) 930 if (aic32x4 == NULL)
791 return -ENOMEM; 931 return -ENOMEM;
792 932
793 aic32x4->regmap = devm_regmap_init_i2c(i2c, &aic32x4_regmap); 933 dev_set_drvdata(dev, aic32x4);
794 if (IS_ERR(aic32x4->regmap))
795 return PTR_ERR(aic32x4->regmap);
796
797 i2c_set_clientdata(i2c, aic32x4);
798 934
799 if (pdata) { 935 if (pdata) {
800 aic32x4->power_cfg = pdata->power_cfg; 936 aic32x4->power_cfg = pdata->power_cfg;
@@ -804,7 +940,7 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
804 } else if (np) { 940 } else if (np) {
805 ret = aic32x4_parse_dt(aic32x4, np); 941 ret = aic32x4_parse_dt(aic32x4, np);
806 if (ret) { 942 if (ret) {
807 dev_err(&i2c->dev, "Failed to parse DT node\n"); 943 dev_err(dev, "Failed to parse DT node\n");
808 return ret; 944 return ret;
809 } 945 }
810 } else { 946 } else {
@@ -814,71 +950,48 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
814 aic32x4->rstn_gpio = -1; 950 aic32x4->rstn_gpio = -1;
815 } 951 }
816 952
817 aic32x4->mclk = devm_clk_get(&i2c->dev, "mclk"); 953 aic32x4->mclk = devm_clk_get(dev, "mclk");
818 if (IS_ERR(aic32x4->mclk)) { 954 if (IS_ERR(aic32x4->mclk)) {
819 dev_err(&i2c->dev, "Failed getting the mclk. The current implementation does not support the usage of this codec without mclk\n"); 955 dev_err(dev, "Failed getting the mclk. The current implementation does not support the usage of this codec without mclk\n");
820 return PTR_ERR(aic32x4->mclk); 956 return PTR_ERR(aic32x4->mclk);
821 } 957 }
822 958
823 if (gpio_is_valid(aic32x4->rstn_gpio)) { 959 if (gpio_is_valid(aic32x4->rstn_gpio)) {
824 ret = devm_gpio_request_one(&i2c->dev, aic32x4->rstn_gpio, 960 ret = devm_gpio_request_one(dev, aic32x4->rstn_gpio,
825 GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn"); 961 GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
826 if (ret != 0) 962 if (ret != 0)
827 return ret; 963 return ret;
828 } 964 }
829 965
830 ret = aic32x4_setup_regulators(&i2c->dev, aic32x4); 966 ret = aic32x4_setup_regulators(dev, aic32x4);
831 if (ret) { 967 if (ret) {
832 dev_err(&i2c->dev, "Failed to setup regulators\n"); 968 dev_err(dev, "Failed to setup regulators\n");
833 return ret; 969 return ret;
834 } 970 }
835 971
836 ret = snd_soc_register_codec(&i2c->dev, 972 ret = snd_soc_register_codec(dev,
837 &soc_codec_dev_aic32x4, &aic32x4_dai, 1); 973 &soc_codec_dev_aic32x4, &aic32x4_dai, 1);
838 if (ret) { 974 if (ret) {
839 dev_err(&i2c->dev, "Failed to register codec\n"); 975 dev_err(dev, "Failed to register codec\n");
840 aic32x4_disable_regulators(aic32x4); 976 aic32x4_disable_regulators(aic32x4);
841 return ret; 977 return ret;
842 } 978 }
843 979
844 i2c_set_clientdata(i2c, aic32x4);
845
846 return 0; 980 return 0;
847} 981}
982EXPORT_SYMBOL(aic32x4_probe);
848 983
849static int aic32x4_i2c_remove(struct i2c_client *client) 984int aic32x4_remove(struct device *dev)
850{ 985{
851 struct aic32x4_priv *aic32x4 = i2c_get_clientdata(client); 986 struct aic32x4_priv *aic32x4 = dev_get_drvdata(dev);
852 987
853 aic32x4_disable_regulators(aic32x4); 988 aic32x4_disable_regulators(aic32x4);
854 989
855 snd_soc_unregister_codec(&client->dev); 990 snd_soc_unregister_codec(dev);
991
856 return 0; 992 return 0;
857} 993}
858 994EXPORT_SYMBOL(aic32x4_remove);
859static const struct i2c_device_id aic32x4_i2c_id[] = {
860 { "tlv320aic32x4", 0 },
861 { }
862};
863MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
864
865static const struct of_device_id aic32x4_of_id[] = {
866 { .compatible = "ti,tlv320aic32x4", },
867 { /* senitel */ }
868};
869MODULE_DEVICE_TABLE(of, aic32x4_of_id);
870
871static struct i2c_driver aic32x4_i2c_driver = {
872 .driver = {
873 .name = "tlv320aic32x4",
874 .of_match_table = aic32x4_of_id,
875 },
876 .probe = aic32x4_i2c_probe,
877 .remove = aic32x4_i2c_remove,
878 .id_table = aic32x4_i2c_id,
879};
880
881module_i2c_driver(aic32x4_i2c_driver);
882 995
883MODULE_DESCRIPTION("ASoC tlv320aic32x4 codec driver"); 996MODULE_DESCRIPTION("ASoC tlv320aic32x4 codec driver");
884MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>"); 997MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h
index 995f033a855d..a197dd51addc 100644
--- a/sound/soc/codecs/tlv320aic32x4.h
+++ b/sound/soc/codecs/tlv320aic32x4.h
@@ -10,6 +10,13 @@
10#ifndef _TLV320AIC32X4_H 10#ifndef _TLV320AIC32X4_H
11#define _TLV320AIC32X4_H 11#define _TLV320AIC32X4_H
12 12
13struct device;
14struct regmap_config;
15
16extern const struct regmap_config aic32x4_regmap_config;
17int aic32x4_probe(struct device *dev, struct regmap *regmap);
18int aic32x4_remove(struct device *dev);
19
13/* tlv320aic32x4 register space (in decimal to match datasheet) */ 20/* tlv320aic32x4 register space (in decimal to match datasheet) */
14 21
15#define AIC32X4_PAGE1 128 22#define AIC32X4_PAGE1 128
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index bc3de2e844e6..1f7081043566 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -824,7 +824,7 @@ static int twl6040_set_bias_level(struct snd_soc_codec *codec,
824{ 824{
825 struct twl6040 *twl6040 = codec->control_data; 825 struct twl6040 *twl6040 = codec->control_data;
826 struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); 826 struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
827 int ret; 827 int ret = 0;
828 828
829 switch (level) { 829 switch (level) {
830 case SND_SOC_BIAS_ON: 830 case SND_SOC_BIAS_ON:
@@ -832,12 +832,16 @@ static int twl6040_set_bias_level(struct snd_soc_codec *codec,
832 case SND_SOC_BIAS_PREPARE: 832 case SND_SOC_BIAS_PREPARE:
833 break; 833 break;
834 case SND_SOC_BIAS_STANDBY: 834 case SND_SOC_BIAS_STANDBY:
835 if (priv->codec_powered) 835 if (priv->codec_powered) {
836 /* Select low power PLL in standby */
837 ret = twl6040_set_pll(twl6040, TWL6040_SYSCLK_SEL_LPPLL,
838 32768, 19200000);
836 break; 839 break;
840 }
837 841
838 ret = twl6040_power(twl6040, 1); 842 ret = twl6040_power(twl6040, 1);
839 if (ret) 843 if (ret)
840 return ret; 844 break;
841 845
842 priv->codec_powered = 1; 846 priv->codec_powered = 1;
843 847
@@ -853,7 +857,7 @@ static int twl6040_set_bias_level(struct snd_soc_codec *codec,
853 break; 857 break;
854 } 858 }
855 859
856 return 0; 860 return ret;
857} 861}
858 862
859static int twl6040_startup(struct snd_pcm_substream *substream, 863static int twl6040_startup(struct snd_pcm_substream *substream,
@@ -983,9 +987,9 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i
983 if (mute) { 987 if (mute) {
984 /* Power down drivers and DACs */ 988 /* Power down drivers and DACs */
985 hflctl &= ~(TWL6040_HFDACENA | TWL6040_HFPGAENA | 989 hflctl &= ~(TWL6040_HFDACENA | TWL6040_HFPGAENA |
986 TWL6040_HFDRVENA); 990 TWL6040_HFDRVENA | TWL6040_HFSWENA);
987 hfrctl &= ~(TWL6040_HFDACENA | TWL6040_HFPGAENA | 991 hfrctl &= ~(TWL6040_HFDACENA | TWL6040_HFPGAENA |
988 TWL6040_HFDRVENA); 992 TWL6040_HFDRVENA | TWL6040_HFSWENA);
989 } 993 }
990 994
991 twl6040_reg_write(twl6040, TWL6040_REG_HFLCTL, hflctl); 995 twl6040_reg_write(twl6040, TWL6040_REG_HFLCTL, hflctl);
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 720a14e0687d..0100e28f40dc 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3798,9 +3798,8 @@ static int wm8962_runtime_resume(struct device *dev)
3798 ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), 3798 ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
3799 wm8962->supplies); 3799 wm8962->supplies);
3800 if (ret != 0) { 3800 if (ret != 0) {
3801 dev_err(dev, 3801 dev_err(dev, "Failed to enable supplies: %d\n", ret);
3802 "Failed to enable supplies: %d\n", ret); 3802 goto disable_clock;
3803 return ret;
3804 } 3803 }
3805 3804
3806 regcache_cache_only(wm8962->regmap, false); 3805 regcache_cache_only(wm8962->regmap, false);
@@ -3838,6 +3837,10 @@ static int wm8962_runtime_resume(struct device *dev)
3838 msleep(5); 3837 msleep(5);
3839 3838
3840 return 0; 3839 return 0;
3840
3841disable_clock:
3842 clk_disable_unprepare(wm8962->pdata.mclk);
3843 return ret;
3841} 3844}
3842 3845
3843static int wm8962_runtime_suspend(struct device *dev) 3846static int wm8962_runtime_suspend(struct device *dev)
diff --git a/sound/soc/codecs/wm8962.h b/sound/soc/codecs/wm8962.h
index 910aafd09d21..e63a318a3015 100644
--- a/sound/soc/codecs/wm8962.h
+++ b/sound/soc/codecs/wm8962.h
@@ -16,9 +16,9 @@
16#include <asm/types.h> 16#include <asm/types.h>
17#include <sound/soc.h> 17#include <sound/soc.h>
18 18
19#define WM8962_SYSCLK_MCLK 1 19#define WM8962_SYSCLK_MCLK 0
20#define WM8962_SYSCLK_FLL 2 20#define WM8962_SYSCLK_FLL 1
21#define WM8962_SYSCLK_PLL3 3 21#define WM8962_SYSCLK_PLL3 2
22 22
23#define WM8962_FLL 1 23#define WM8962_FLL 1
24 24
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 2389ab47e25f..466492b7d4f5 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -643,6 +643,7 @@ MODULE_DEVICE_TABLE(of, asoc_simple_of_match);
643static struct platform_driver asoc_simple_card = { 643static struct platform_driver asoc_simple_card = {
644 .driver = { 644 .driver = {
645 .name = "asoc-simple-card", 645 .name = "asoc-simple-card",
646 .pm = &snd_soc_pm_ops,
646 .of_match_table = asoc_simple_of_match, 647 .of_match_table = asoc_simple_of_match,
647 }, 648 },
648 .probe = asoc_simple_card_probe, 649 .probe = asoc_simple_card_probe,
diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig
index 132bb83f8e99..bc3c7b5ac752 100644
--- a/sound/soc/kirkwood/Kconfig
+++ b/sound/soc/kirkwood/Kconfig
@@ -1,6 +1,7 @@
1config SND_KIRKWOOD_SOC 1config SND_KIRKWOOD_SOC
2 tristate "SoC Audio for the Marvell Kirkwood and Dove chips" 2 tristate "SoC Audio for the Marvell Kirkwood and Dove chips"
3 depends on ARCH_DOVE || ARCH_MVEBU || COMPILE_TEST 3 depends on ARCH_DOVE || ARCH_MVEBU || COMPILE_TEST
4 depends on HAS_DMA
4 help 5 help
5 Say Y or M if you want to add support for codecs attached to 6 Say Y or M if you want to add support for codecs attached to
6 the Kirkwood I2S interface. You will also need to select the 7 the Kirkwood I2S interface. You will also need to select the
diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index f7e789e97fbc..3abf51c07851 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -43,6 +43,7 @@ config SND_SOC_MT8173_RT5650_RT5676
43 depends on SND_SOC_MEDIATEK && I2C 43 depends on SND_SOC_MEDIATEK && I2C
44 select SND_SOC_RT5645 44 select SND_SOC_RT5645
45 select SND_SOC_RT5677 45 select SND_SOC_RT5677
46 select SND_SOC_HDMI_CODEC
46 help 47 help
47 This adds ASoC driver for Mediatek MT8173 boards 48 This adds ASoC driver for Mediatek MT8173 boards
48 with the RT5650 and RT5676 codecs. 49 with the RT5650 and RT5676 codecs.
diff --git a/sound/soc/mediatek/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173-rt5650-rt5676.c
index 5c4c58c69c51..bb593926c62d 100644
--- a/sound/soc/mediatek/mt8173-rt5650-rt5676.c
+++ b/sound/soc/mediatek/mt8173-rt5650-rt5676.c
@@ -134,7 +134,9 @@ static struct snd_soc_dai_link_component mt8173_rt5650_rt5676_codecs[] = {
134enum { 134enum {
135 DAI_LINK_PLAYBACK, 135 DAI_LINK_PLAYBACK,
136 DAI_LINK_CAPTURE, 136 DAI_LINK_CAPTURE,
137 DAI_LINK_HDMI,
137 DAI_LINK_CODEC_I2S, 138 DAI_LINK_CODEC_I2S,
139 DAI_LINK_HDMI_I2S,
138 DAI_LINK_INTERCODEC 140 DAI_LINK_INTERCODEC
139}; 141};
140 142
@@ -161,6 +163,16 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = {
161 .dynamic = 1, 163 .dynamic = 1,
162 .dpcm_capture = 1, 164 .dpcm_capture = 1,
163 }, 165 },
166 [DAI_LINK_HDMI] = {
167 .name = "HDMI",
168 .stream_name = "HDMI PCM",
169 .cpu_dai_name = "HDMI",
170 .codec_name = "snd-soc-dummy",
171 .codec_dai_name = "snd-soc-dummy-dai",
172 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
173 .dynamic = 1,
174 .dpcm_playback = 1,
175 },
164 176
165 /* Back End DAI links */ 177 /* Back End DAI links */
166 [DAI_LINK_CODEC_I2S] = { 178 [DAI_LINK_CODEC_I2S] = {
@@ -177,6 +189,13 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = {
177 .dpcm_playback = 1, 189 .dpcm_playback = 1,
178 .dpcm_capture = 1, 190 .dpcm_capture = 1,
179 }, 191 },
192 [DAI_LINK_HDMI_I2S] = {
193 .name = "HDMI BE",
194 .cpu_dai_name = "HDMIO",
195 .no_pcm = 1,
196 .codec_dai_name = "i2s-hifi",
197 .dpcm_playback = 1,
198 },
180 /* rt5676 <-> rt5650 intercodec link: Sets rt5676 I2S2 as master */ 199 /* rt5676 <-> rt5650 intercodec link: Sets rt5676 I2S2 as master */
181 [DAI_LINK_INTERCODEC] = { 200 [DAI_LINK_INTERCODEC] = {
182 .name = "rt5650_rt5676 intercodec", 201 .name = "rt5650_rt5676 intercodec",
@@ -251,6 +270,14 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
251 mt8173_rt5650_rt5676_dais[DAI_LINK_INTERCODEC].codec_of_node = 270 mt8173_rt5650_rt5676_dais[DAI_LINK_INTERCODEC].codec_of_node =
252 mt8173_rt5650_rt5676_codecs[1].of_node; 271 mt8173_rt5650_rt5676_codecs[1].of_node;
253 272
273 mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S].codec_of_node =
274 of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 2);
275 if (!mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S].codec_of_node) {
276 dev_err(&pdev->dev,
277 "Property 'audio-codec' missing or invalid\n");
278 return -EINVAL;
279 }
280
254 card->dev = &pdev->dev; 281 card->dev = &pdev->dev;
255 platform_set_drvdata(pdev, card); 282 platform_set_drvdata(pdev, card);
256 283
diff --git a/sound/soc/mediatek/mt8173-rt5650.c b/sound/soc/mediatek/mt8173-rt5650.c
index bb09bb1b7f1c..a27a6673dbe3 100644
--- a/sound/soc/mediatek/mt8173-rt5650.c
+++ b/sound/soc/mediatek/mt8173-rt5650.c
@@ -85,12 +85,29 @@ static int mt8173_rt5650_init(struct snd_soc_pcm_runtime *runtime)
85{ 85{
86 struct snd_soc_card *card = runtime->card; 86 struct snd_soc_card *card = runtime->card;
87 struct snd_soc_codec *codec = runtime->codec_dais[0]->codec; 87 struct snd_soc_codec *codec = runtime->codec_dais[0]->codec;
88 const char *codec_capture_dai = runtime->codec_dais[1]->name;
88 int ret; 89 int ret;
89 90
90 rt5645_sel_asrc_clk_src(codec, 91 rt5645_sel_asrc_clk_src(codec,
91 RT5645_DA_STEREO_FILTER | 92 RT5645_DA_STEREO_FILTER,
92 RT5645_AD_STEREO_FILTER,
93 RT5645_CLK_SEL_I2S1_ASRC); 93 RT5645_CLK_SEL_I2S1_ASRC);
94
95 if (!strcmp(codec_capture_dai, "rt5645-aif1")) {
96 rt5645_sel_asrc_clk_src(codec,
97 RT5645_AD_STEREO_FILTER,
98 RT5645_CLK_SEL_I2S1_ASRC);
99 } else if (!strcmp(codec_capture_dai, "rt5645-aif2")) {
100 rt5645_sel_asrc_clk_src(codec,
101 RT5645_AD_STEREO_FILTER,
102 RT5645_CLK_SEL_I2S2_ASRC);
103 } else {
104 dev_warn(card->dev,
105 "Only one dai codec found in DTS, enabled rt5645 AD filter\n");
106 rt5645_sel_asrc_clk_src(codec,
107 RT5645_AD_STEREO_FILTER,
108 RT5645_CLK_SEL_I2S1_ASRC);
109 }
110
94 /* enable jack detection */ 111 /* enable jack detection */
95 ret = snd_soc_card_jack_new(card, "Headset Jack", 112 ret = snd_soc_card_jack_new(card, "Headset Jack",
96 SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | 113 SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
@@ -110,6 +127,11 @@ static int mt8173_rt5650_init(struct snd_soc_pcm_runtime *runtime)
110 127
111static struct snd_soc_dai_link_component mt8173_rt5650_codecs[] = { 128static struct snd_soc_dai_link_component mt8173_rt5650_codecs[] = {
112 { 129 {
130 /* Playback */
131 .dai_name = "rt5645-aif1",
132 },
133 {
134 /* Capture */
113 .dai_name = "rt5645-aif1", 135 .dai_name = "rt5645-aif1",
114 }, 136 },
115}; 137};
@@ -149,7 +171,7 @@ static struct snd_soc_dai_link mt8173_rt5650_dais[] = {
149 .cpu_dai_name = "I2S", 171 .cpu_dai_name = "I2S",
150 .no_pcm = 1, 172 .no_pcm = 1,
151 .codecs = mt8173_rt5650_codecs, 173 .codecs = mt8173_rt5650_codecs,
152 .num_codecs = 1, 174 .num_codecs = 2,
153 .init = mt8173_rt5650_init, 175 .init = mt8173_rt5650_init,
154 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 176 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
155 SND_SOC_DAIFMT_CBS_CFS, 177 SND_SOC_DAIFMT_CBS_CFS,
@@ -177,6 +199,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
177{ 199{
178 struct snd_soc_card *card = &mt8173_rt5650_card; 200 struct snd_soc_card *card = &mt8173_rt5650_card;
179 struct device_node *platform_node; 201 struct device_node *platform_node;
202 struct device_node *np;
203 const char *codec_capture_dai;
180 int i, ret; 204 int i, ret;
181 205
182 platform_node = of_parse_phandle(pdev->dev.of_node, 206 platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -199,6 +223,26 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
199 "Property 'audio-codec' missing or invalid\n"); 223 "Property 'audio-codec' missing or invalid\n");
200 return -EINVAL; 224 return -EINVAL;
201 } 225 }
226 mt8173_rt5650_codecs[1].of_node = mt8173_rt5650_codecs[0].of_node;
227
228 if (of_find_node_by_name(platform_node, "codec-capture")) {
229 np = of_get_child_by_name(pdev->dev.of_node, "codec-capture");
230 if (!np) {
231 dev_err(&pdev->dev,
232 "%s: Can't find codec-capture DT node\n",
233 __func__);
234 return -EINVAL;
235 }
236 ret = snd_soc_of_get_dai_name(np, &codec_capture_dai);
237 if (ret < 0) {
238 dev_err(&pdev->dev,
239 "%s codec_capture_dai name fail %d\n",
240 __func__, ret);
241 return ret;
242 }
243 mt8173_rt5650_codecs[1].dai_name = codec_capture_dai;
244 }
245
202 card->dev = &pdev->dev; 246 card->dev = &pdev->dev;
203 platform_set_drvdata(pdev, card); 247 platform_set_drvdata(pdev, card);
204 248
diff --git a/sound/soc/mediatek/mtk-afe-pcm.c b/sound/soc/mediatek/mtk-afe-pcm.c
index f1c58a2c12fb..2b5df2ef51a3 100644
--- a/sound/soc/mediatek/mtk-afe-pcm.c
+++ b/sound/soc/mediatek/mtk-afe-pcm.c
@@ -123,6 +123,7 @@
123#define AFE_TDM_CON1_WLEN_32BIT (0x2 << 8) 123#define AFE_TDM_CON1_WLEN_32BIT (0x2 << 8)
124#define AFE_TDM_CON1_MSB_ALIGNED (0x1 << 4) 124#define AFE_TDM_CON1_MSB_ALIGNED (0x1 << 4)
125#define AFE_TDM_CON1_1_BCK_DELAY (0x1 << 3) 125#define AFE_TDM_CON1_1_BCK_DELAY (0x1 << 3)
126#define AFE_TDM_CON1_LRCK_INV (0x1 << 2)
126#define AFE_TDM_CON1_BCK_INV (0x1 << 1) 127#define AFE_TDM_CON1_BCK_INV (0x1 << 1)
127#define AFE_TDM_CON1_EN (0x1 << 0) 128#define AFE_TDM_CON1_EN (0x1 << 0)
128 129
@@ -449,6 +450,7 @@ static int mtk_afe_hdmi_prepare(struct snd_pcm_substream *substream,
449 runtime->rate * runtime->channels * 32); 450 runtime->rate * runtime->channels * 32);
450 451
451 val = AFE_TDM_CON1_BCK_INV | 452 val = AFE_TDM_CON1_BCK_INV |
453 AFE_TDM_CON1_LRCK_INV |
452 AFE_TDM_CON1_1_BCK_DELAY | 454 AFE_TDM_CON1_1_BCK_DELAY |
453 AFE_TDM_CON1_MSB_ALIGNED | /* I2S mode */ 455 AFE_TDM_CON1_MSB_ALIGNED | /* I2S mode */
454 AFE_TDM_CON1_WLEN_32BIT | 456 AFE_TDM_CON1_WLEN_32BIT |
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index c7563e230c7d..4a16e778966b 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -260,6 +260,10 @@ static void omap_st_on(struct omap_mcbsp *mcbsp)
260 if (mcbsp->pdata->enable_st_clock) 260 if (mcbsp->pdata->enable_st_clock)
261 mcbsp->pdata->enable_st_clock(mcbsp->id, 1); 261 mcbsp->pdata->enable_st_clock(mcbsp->id, 1);
262 262
263 /* Disable Sidetone clock auto-gating for normal operation */
264 w = MCBSP_ST_READ(mcbsp, SYSCONFIG);
265 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w & ~(ST_AUTOIDLE));
266
263 /* Enable McBSP Sidetone */ 267 /* Enable McBSP Sidetone */
264 w = MCBSP_READ(mcbsp, SSELCR); 268 w = MCBSP_READ(mcbsp, SSELCR);
265 MCBSP_WRITE(mcbsp, SSELCR, w | SIDETONEEN); 269 MCBSP_WRITE(mcbsp, SSELCR, w | SIDETONEEN);
@@ -279,6 +283,10 @@ static void omap_st_off(struct omap_mcbsp *mcbsp)
279 w = MCBSP_READ(mcbsp, SSELCR); 283 w = MCBSP_READ(mcbsp, SSELCR);
280 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN)); 284 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN));
281 285
286 /* Enable Sidetone clock auto-gating to reduce power consumption */
287 w = MCBSP_ST_READ(mcbsp, SYSCONFIG);
288 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w | ST_AUTOIDLE);
289
282 if (mcbsp->pdata->enable_st_clock) 290 if (mcbsp->pdata->enable_st_clock)
283 mcbsp->pdata->enable_st_clock(mcbsp->id, 0); 291 mcbsp->pdata->enable_st_clock(mcbsp->id, 0);
284} 292}
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 99381a27295b..a84f677234f0 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -82,6 +82,8 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
82 struct dma_chan *chan; 82 struct dma_chan *chan;
83 int err = 0; 83 int err = 0;
84 84
85 memset(&config, 0x00, sizeof(config));
86
85 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 87 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
86 88
87 /* return if this is a bufferless transfer e.g. 89 /* return if this is a bufferless transfer e.g.
diff --git a/sound/soc/pxa/brownstone.c b/sound/soc/pxa/brownstone.c
index ec522e94b0e2..b6cb9950f05d 100644
--- a/sound/soc/pxa/brownstone.c
+++ b/sound/soc/pxa/brownstone.c
@@ -133,3 +133,4 @@ module_platform_driver(mmp_driver);
133MODULE_AUTHOR("Leo Yan <leoy@marvell.com>"); 133MODULE_AUTHOR("Leo Yan <leoy@marvell.com>");
134MODULE_DESCRIPTION("ALSA SoC Brownstone"); 134MODULE_DESCRIPTION("ALSA SoC Brownstone");
135MODULE_LICENSE("GPL"); 135MODULE_LICENSE("GPL");
136MODULE_ALIAS("platform:brownstone-audio");
diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c
index 5c8f9db50a47..d1661fa6ee08 100644
--- a/sound/soc/pxa/mioa701_wm9713.c
+++ b/sound/soc/pxa/mioa701_wm9713.c
@@ -207,3 +207,4 @@ module_platform_driver(mioa701_wm9713_driver);
207MODULE_AUTHOR("Robert Jarzmik (rjarzmik@free.fr)"); 207MODULE_AUTHOR("Robert Jarzmik (rjarzmik@free.fr)");
208MODULE_DESCRIPTION("ALSA SoC WM9713 MIO A701"); 208MODULE_DESCRIPTION("ALSA SoC WM9713 MIO A701");
209MODULE_LICENSE("GPL"); 209MODULE_LICENSE("GPL");
210MODULE_ALIAS("platform:mioa701-wm9713");
diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c
index 51e790d006f5..96df9b2d8fc4 100644
--- a/sound/soc/pxa/mmp-pcm.c
+++ b/sound/soc/pxa/mmp-pcm.c
@@ -248,3 +248,4 @@ module_platform_driver(mmp_pcm_driver);
248MODULE_AUTHOR("Leo Yan <leoy@marvell.com>"); 248MODULE_AUTHOR("Leo Yan <leoy@marvell.com>");
249MODULE_DESCRIPTION("MMP Soc Audio DMA module"); 249MODULE_DESCRIPTION("MMP Soc Audio DMA module");
250MODULE_LICENSE("GPL"); 250MODULE_LICENSE("GPL");
251MODULE_ALIAS("platform:mmp-pcm-audio");
diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c
index eca60c29791a..ca8b23f8c525 100644
--- a/sound/soc/pxa/mmp-sspa.c
+++ b/sound/soc/pxa/mmp-sspa.c
@@ -482,3 +482,4 @@ module_platform_driver(asoc_mmp_sspa_driver);
482MODULE_AUTHOR("Leo Yan <leoy@marvell.com>"); 482MODULE_AUTHOR("Leo Yan <leoy@marvell.com>");
483MODULE_DESCRIPTION("MMP SSPA SoC Interface"); 483MODULE_DESCRIPTION("MMP SSPA SoC Interface");
484MODULE_LICENSE("GPL"); 484MODULE_LICENSE("GPL");
485MODULE_ALIAS("platform:mmp-sspa-dai");
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
index 4e74d9573f03..bcc81e920a67 100644
--- a/sound/soc/pxa/palm27x.c
+++ b/sound/soc/pxa/palm27x.c
@@ -161,3 +161,4 @@ module_platform_driver(palm27x_wm9712_driver);
161MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); 161MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
162MODULE_DESCRIPTION("ALSA SoC Palm T|X, T5 and LifeDrive"); 162MODULE_DESCRIPTION("ALSA SoC Palm T|X, T5 and LifeDrive");
163MODULE_LICENSE("GPL"); 163MODULE_LICENSE("GPL");
164MODULE_ALIAS("platform:palm27x-asoc");
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index da03fad1b9cd..3cad990dad2c 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -833,3 +833,4 @@ module_platform_driver(asoc_ssp_driver);
833MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 833MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
834MODULE_DESCRIPTION("PXA SSP/PCM SoC Interface"); 834MODULE_DESCRIPTION("PXA SSP/PCM SoC Interface");
835MODULE_LICENSE("GPL"); 835MODULE_LICENSE("GPL");
836MODULE_ALIAS("platform:pxa-ssp-dai");
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index f3de615aacd7..9615e6de1306 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -287,3 +287,4 @@ module_platform_driver(pxa2xx_ac97_driver);
287MODULE_AUTHOR("Nicolas Pitre"); 287MODULE_AUTHOR("Nicolas Pitre");
288MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip"); 288MODULE_DESCRIPTION("AC97 driver for the Intel PXA2xx chip");
289MODULE_LICENSE("GPL"); 289MODULE_LICENSE("GPL");
290MODULE_ALIAS("platform:pxa2xx-ac97");
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index 9f390398d518..410d48b93031 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -117,3 +117,4 @@ module_platform_driver(pxa_pcm_driver);
117MODULE_AUTHOR("Nicolas Pitre"); 117MODULE_AUTHOR("Nicolas Pitre");
118MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module"); 118MODULE_DESCRIPTION("Intel PXA2xx PCM DMA module");
119MODULE_LICENSE("GPL"); 119MODULE_LICENSE("GPL");
120MODULE_ALIAS("platform:pxa-pcm-audio");
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index 6e8665430bd5..db000c6987a1 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -474,7 +474,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
474 struct lpass_data *drvdata = 474 struct lpass_data *drvdata =
475 snd_soc_platform_get_drvdata(soc_runtime->platform); 475 snd_soc_platform_get_drvdata(soc_runtime->platform);
476 struct lpass_variant *v = drvdata->variant; 476 struct lpass_variant *v = drvdata->variant;
477 int ret; 477 int ret = -EINVAL;
478 struct lpass_pcm_data *data; 478 struct lpass_pcm_data *data;
479 size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; 479 size_t size = lpass_platform_pcm_hardware.buffer_bytes_max;
480 480
@@ -491,7 +491,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
491 data->rdma_ch = v->alloc_dma_channel(drvdata, 491 data->rdma_ch = v->alloc_dma_channel(drvdata,
492 SNDRV_PCM_STREAM_PLAYBACK); 492 SNDRV_PCM_STREAM_PLAYBACK);
493 493
494 if (IS_ERR_VALUE(data->rdma_ch)) 494 if (data->rdma_ch < 0)
495 return data->rdma_ch; 495 return data->rdma_ch;
496 496
497 drvdata->substream[data->rdma_ch] = psubstream; 497 drvdata->substream[data->rdma_ch] = psubstream;
@@ -518,8 +518,10 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
518 data->wrdma_ch = v->alloc_dma_channel(drvdata, 518 data->wrdma_ch = v->alloc_dma_channel(drvdata,
519 SNDRV_PCM_STREAM_CAPTURE); 519 SNDRV_PCM_STREAM_CAPTURE);
520 520
521 if (IS_ERR_VALUE(data->wrdma_ch)) 521 if (data->wrdma_ch < 0) {
522 ret = data->wrdma_ch;
522 goto capture_alloc_err; 523 goto capture_alloc_err;
524 }
523 525
524 drvdata->substream[data->wrdma_ch] = csubstream; 526 drvdata->substream[data->wrdma_ch] = csubstream;
525 527
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index 606399de684d..49354d17ea55 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -492,9 +492,7 @@ static void rsnd_adg_get_clkout(struct rsnd_priv *priv,
492 */ 492 */
493 if (!count) { 493 if (!count) {
494 clk = clk_register_fixed_rate(dev, clkout_name[CLKOUT], 494 clk = clk_register_fixed_rate(dev, clkout_name[CLKOUT],
495 parent_clk_name, 495 parent_clk_name, 0, req_rate);
496 (parent_clk_name) ?
497 0 : CLK_IS_ROOT, req_rate);
498 if (!IS_ERR(clk)) { 496 if (!IS_ERR(clk)) {
499 adg->clkout[CLKOUT] = clk; 497 adg->clkout[CLKOUT] = clk;
500 of_clk_add_provider(np, of_clk_src_simple_get, clk); 498 of_clk_add_provider(np, of_clk_src_simple_get, clk);
@@ -506,9 +504,7 @@ static void rsnd_adg_get_clkout(struct rsnd_priv *priv,
506 else { 504 else {
507 for (i = 0; i < CLKOUTMAX; i++) { 505 for (i = 0; i < CLKOUTMAX; i++) {
508 clk = clk_register_fixed_rate(dev, clkout_name[i], 506 clk = clk_register_fixed_rate(dev, clkout_name[i],
509 parent_clk_name, 507 parent_clk_name, 0,
510 (parent_clk_name) ?
511 0 : CLK_IS_ROOT,
512 req_rate); 508 req_rate);
513 if (!IS_ERR(clk)) { 509 if (!IS_ERR(clk)) {
514 adg->onecell.clks = adg->clkout; 510 adg->onecell.clks = adg->clkout;
diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c
index 7658e8fd7bdc..6bc93cbb3049 100644
--- a/sound/soc/sh/rcar/dma.c
+++ b/sound/soc/sh/rcar/dma.c
@@ -316,11 +316,15 @@ static u32 rsnd_dmapp_get_id(struct rsnd_dai_stream *io,
316 size = ARRAY_SIZE(gen2_id_table_cmd); 316 size = ARRAY_SIZE(gen2_id_table_cmd);
317 } 317 }
318 318
319 if (!entry) 319 if ((!entry) || (size <= id)) {
320 return 0xFF; 320 struct device *dev = rsnd_priv_to_dev(rsnd_io_to_priv(io));
321 321
322 if (size <= id) 322 dev_err(dev, "unknown connection (%s[%d])\n",
323 return 0xFF; 323 rsnd_mod_name(mod), rsnd_mod_id(mod));
324
325 /* use non-prohibited SRS number as error */
326 return 0x00; /* SSI00 */
327 }
324 328
325 return entry[id]; 329 return entry[id];
326} 330}
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index fc89a67258ca..a8f61d79333b 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -276,8 +276,9 @@ struct rsnd_mod {
276/* 276/*
277 * status 277 * status
278 * 278 *
279 * 0xH0000CB0 279 * 0xH0000CBA
280 * 280 *
281 * A 0: probe 1: remove
281 * B 0: init 1: quit 282 * B 0: init 1: quit
282 * C 0: start 1: stop 283 * C 0: start 1: stop
283 * 284 *
@@ -287,19 +288,19 @@ struct rsnd_mod {
287 * H 0: fallback 288 * H 0: fallback
288 * H 0: hw_params 289 * H 0: hw_params
289 */ 290 */
291#define __rsnd_mod_shift_probe 0
292#define __rsnd_mod_shift_remove 0
290#define __rsnd_mod_shift_init 4 293#define __rsnd_mod_shift_init 4
291#define __rsnd_mod_shift_quit 4 294#define __rsnd_mod_shift_quit 4
292#define __rsnd_mod_shift_start 8 295#define __rsnd_mod_shift_start 8
293#define __rsnd_mod_shift_stop 8 296#define __rsnd_mod_shift_stop 8
294#define __rsnd_mod_shift_probe 28 /* always called */
295#define __rsnd_mod_shift_remove 28 /* always called */
296#define __rsnd_mod_shift_irq 28 /* always called */ 297#define __rsnd_mod_shift_irq 28 /* always called */
297#define __rsnd_mod_shift_pcm_new 28 /* always called */ 298#define __rsnd_mod_shift_pcm_new 28 /* always called */
298#define __rsnd_mod_shift_fallback 28 /* always called */ 299#define __rsnd_mod_shift_fallback 28 /* always called */
299#define __rsnd_mod_shift_hw_params 28 /* always called */ 300#define __rsnd_mod_shift_hw_params 28 /* always called */
300 301
301#define __rsnd_mod_add_probe 0 302#define __rsnd_mod_add_probe 1
302#define __rsnd_mod_add_remove 0 303#define __rsnd_mod_add_remove -1
303#define __rsnd_mod_add_init 1 304#define __rsnd_mod_add_init 1
304#define __rsnd_mod_add_quit -1 305#define __rsnd_mod_add_quit -1
305#define __rsnd_mod_add_start 1 306#define __rsnd_mod_add_start 1
@@ -310,7 +311,7 @@ struct rsnd_mod {
310#define __rsnd_mod_add_hw_params 0 311#define __rsnd_mod_add_hw_params 0
311 312
312#define __rsnd_mod_call_probe 0 313#define __rsnd_mod_call_probe 0
313#define __rsnd_mod_call_remove 0 314#define __rsnd_mod_call_remove 1
314#define __rsnd_mod_call_init 0 315#define __rsnd_mod_call_init 0
315#define __rsnd_mod_call_quit 1 316#define __rsnd_mod_call_quit 1
316#define __rsnd_mod_call_start 0 317#define __rsnd_mod_call_start 0
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index 15d6ffe8be74..e39f916d0f2f 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -572,6 +572,9 @@ int rsnd_src_probe(struct rsnd_priv *priv)
572 572
573 i = 0; 573 i = 0;
574 for_each_child_of_node(node, np) { 574 for_each_child_of_node(node, np) {
575 if (!of_device_is_available(np))
576 goto skip;
577
575 src = rsnd_src_get(priv, i); 578 src = rsnd_src_get(priv, i);
576 579
577 snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d", 580 snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d",
@@ -595,6 +598,7 @@ int rsnd_src_probe(struct rsnd_priv *priv)
595 if (ret) 598 if (ret)
596 goto rsnd_src_probe_done; 599 goto rsnd_src_probe_done;
597 600
601skip:
598 i++; 602 i++;
599 } 603 }
600 604
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 1cf94d7fb9f4..ee7f15aa46fc 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1023,6 +1023,11 @@ static int soc_tplg_kcontrol_elems_load(struct soc_tplg *tplg,
1023 1023
1024 control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos; 1024 control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos;
1025 1025
1026 if (control_hdr->size != sizeof(*control_hdr)) {
1027 dev_err(tplg->dev, "ASoC: invalid control size\n");
1028 return -EINVAL;
1029 }
1030
1026 switch (control_hdr->ops.info) { 1031 switch (control_hdr->ops.info) {
1027 case SND_SOC_TPLG_CTL_VOLSW: 1032 case SND_SOC_TPLG_CTL_VOLSW:
1028 case SND_SOC_TPLG_CTL_STROBE: 1033 case SND_SOC_TPLG_CTL_STROBE:
@@ -1476,6 +1481,8 @@ widget:
1476 widget->dobj.type = SND_SOC_DOBJ_WIDGET; 1481 widget->dobj.type = SND_SOC_DOBJ_WIDGET;
1477 widget->dobj.ops = tplg->ops; 1482 widget->dobj.ops = tplg->ops;
1478 widget->dobj.index = tplg->index; 1483 widget->dobj.index = tplg->index;
1484 kfree(template.sname);
1485 kfree(template.name);
1479 list_add(&widget->dobj.list, &tplg->comp->dobj_list); 1486 list_add(&widget->dobj.list, &tplg->comp->dobj_list);
1480 return 0; 1487 return 0;
1481 1488
@@ -1499,10 +1506,17 @@ static int soc_tplg_dapm_widget_elems_load(struct soc_tplg *tplg,
1499 1506
1500 for (i = 0; i < count; i++) { 1507 for (i = 0; i < count; i++) {
1501 widget = (struct snd_soc_tplg_dapm_widget *) tplg->pos; 1508 widget = (struct snd_soc_tplg_dapm_widget *) tplg->pos;
1509 if (widget->size != sizeof(*widget)) {
1510 dev_err(tplg->dev, "ASoC: invalid widget size\n");
1511 return -EINVAL;
1512 }
1513
1502 ret = soc_tplg_dapm_widget_create(tplg, widget); 1514 ret = soc_tplg_dapm_widget_create(tplg, widget);
1503 if (ret < 0) 1515 if (ret < 0) {
1504 dev_err(tplg->dev, "ASoC: failed to load widget %s\n", 1516 dev_err(tplg->dev, "ASoC: failed to load widget %s\n",
1505 widget->name); 1517 widget->name);
1518 return ret;
1519 }
1506 } 1520 }
1507 1521
1508 return 0; 1522 return 0;
@@ -1586,6 +1600,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
1586 return snd_soc_register_dai(tplg->comp, dai_drv); 1600 return snd_soc_register_dai(tplg->comp, dai_drv);
1587} 1601}
1588 1602
1603/* create the FE DAI link */
1589static int soc_tplg_link_create(struct soc_tplg *tplg, 1604static int soc_tplg_link_create(struct soc_tplg *tplg,
1590 struct snd_soc_tplg_pcm *pcm) 1605 struct snd_soc_tplg_pcm *pcm)
1591{ 1606{
@@ -1598,6 +1613,16 @@ static int soc_tplg_link_create(struct soc_tplg *tplg,
1598 1613
1599 link->name = pcm->pcm_name; 1614 link->name = pcm->pcm_name;
1600 link->stream_name = pcm->pcm_name; 1615 link->stream_name = pcm->pcm_name;
1616 link->id = pcm->pcm_id;
1617
1618 link->cpu_dai_name = pcm->dai_name;
1619 link->codec_name = "snd-soc-dummy";
1620 link->codec_dai_name = "snd-soc-dummy-dai";
1621
1622 /* enable DPCM */
1623 link->dynamic = 1;
1624 link->dpcm_playback = pcm->playback;
1625 link->dpcm_capture = pcm->capture;
1601 1626
1602 /* pass control to component driver for optional further init */ 1627 /* pass control to component driver for optional further init */
1603 ret = soc_tplg_dai_link_load(tplg, link); 1628 ret = soc_tplg_dai_link_load(tplg, link);
@@ -1639,8 +1664,6 @@ static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
1639 if (tplg->pass != SOC_TPLG_PASS_PCM_DAI) 1664 if (tplg->pass != SOC_TPLG_PASS_PCM_DAI)
1640 return 0; 1665 return 0;
1641 1666
1642 pcm = (struct snd_soc_tplg_pcm *)tplg->pos;
1643
1644 if (soc_tplg_check_elem_count(tplg, 1667 if (soc_tplg_check_elem_count(tplg,
1645 sizeof(struct snd_soc_tplg_pcm), count, 1668 sizeof(struct snd_soc_tplg_pcm), count,
1646 hdr->payload_size, "PCM DAI")) { 1669 hdr->payload_size, "PCM DAI")) {
@@ -1650,7 +1673,13 @@ static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
1650 } 1673 }
1651 1674
1652 /* create the FE DAIs and DAI links */ 1675 /* create the FE DAIs and DAI links */
1676 pcm = (struct snd_soc_tplg_pcm *)tplg->pos;
1653 for (i = 0; i < count; i++) { 1677 for (i = 0; i < count; i++) {
1678 if (pcm->size != sizeof(*pcm)) {
1679 dev_err(tplg->dev, "ASoC: invalid pcm size\n");
1680 return -EINVAL;
1681 }
1682
1654 soc_tplg_pcm_create(tplg, pcm); 1683 soc_tplg_pcm_create(tplg, pcm);
1655 pcm++; 1684 pcm++;
1656 } 1685 }
@@ -1670,6 +1699,11 @@ static int soc_tplg_manifest_load(struct soc_tplg *tplg,
1670 return 0; 1699 return 0;
1671 1700
1672 manifest = (struct snd_soc_tplg_manifest *)tplg->pos; 1701 manifest = (struct snd_soc_tplg_manifest *)tplg->pos;
1702 if (manifest->size != sizeof(*manifest)) {
1703 dev_err(tplg->dev, "ASoC: invalid manifest size\n");
1704 return -EINVAL;
1705 }
1706
1673 tplg->pos += sizeof(struct snd_soc_tplg_manifest); 1707 tplg->pos += sizeof(struct snd_soc_tplg_manifest);
1674 1708
1675 if (tplg->comp && tplg->ops && tplg->ops->manifest) 1709 if (tplg->comp && tplg->ops && tplg->ops->manifest)
@@ -1686,6 +1720,14 @@ static int soc_valid_header(struct soc_tplg *tplg,
1686 if (soc_tplg_get_hdr_offset(tplg) >= tplg->fw->size) 1720 if (soc_tplg_get_hdr_offset(tplg) >= tplg->fw->size)
1687 return 0; 1721 return 0;
1688 1722
1723 if (hdr->size != sizeof(*hdr)) {
1724 dev_err(tplg->dev,
1725 "ASoC: invalid header size for type %d at offset 0x%lx size 0x%zx.\n",
1726 hdr->type, soc_tplg_get_hdr_offset(tplg),
1727 tplg->fw->size);
1728 return -EINVAL;
1729 }
1730
1689 /* big endian firmware objects not supported atm */ 1731 /* big endian firmware objects not supported atm */
1690 if (hdr->magic == cpu_to_be32(SND_SOC_TPLG_MAGIC)) { 1732 if (hdr->magic == cpu_to_be32(SND_SOC_TPLG_MAGIC)) {
1691 dev_err(tplg->dev, 1733 dev_err(tplg->dev,
diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c
index 39bcefe5eea0..488ef4ed8fba 100644
--- a/sound/soc/sti/sti_uniperif.c
+++ b/sound/soc/sti/sti_uniperif.c
@@ -11,6 +11,142 @@
11#include "uniperif.h" 11#include "uniperif.h"
12 12
13/* 13/*
14 * User frame size shall be 2, 4, 6 or 8 32-bits words length
15 * (i.e. 8, 16, 24 or 32 bytes)
16 * This constraint comes from allowed values for
17 * UNIPERIF_I2S_FMT_NUM_CH register
18 */
19#define UNIPERIF_MAX_FRAME_SZ 0x20
20#define UNIPERIF_ALLOWED_FRAME_SZ (0x08 | 0x10 | 0x18 | UNIPERIF_MAX_FRAME_SZ)
21
22int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
23 unsigned int rx_mask, int slots,
24 int slot_width)
25{
26 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
27 struct uniperif *uni = priv->dai_data.uni;
28 int i, frame_size, avail_slots;
29
30 if (!UNIPERIF_TYPE_IS_TDM(uni)) {
31 dev_err(uni->dev, "cpu dai not in tdm mode\n");
32 return -EINVAL;
33 }
34
35 /* store info in unip context */
36 uni->tdm_slot.slots = slots;
37 uni->tdm_slot.slot_width = slot_width;
38 /* unip is unidirectionnal */
39 uni->tdm_slot.mask = (tx_mask != 0) ? tx_mask : rx_mask;
40
41 /* number of available timeslots */
42 for (i = 0, avail_slots = 0; i < uni->tdm_slot.slots; i++) {
43 if ((uni->tdm_slot.mask >> i) & 0x01)
44 avail_slots++;
45 }
46 uni->tdm_slot.avail_slots = avail_slots;
47
48 /* frame size in bytes */
49 frame_size = uni->tdm_slot.avail_slots * uni->tdm_slot.slot_width / 8;
50
51 /* check frame size is allowed */
52 if ((frame_size > UNIPERIF_MAX_FRAME_SZ) ||
53 (frame_size & ~(int)UNIPERIF_ALLOWED_FRAME_SZ)) {
54 dev_err(uni->dev, "frame size not allowed: %d bytes\n",
55 frame_size);
56 return -EINVAL;
57 }
58
59 return 0;
60}
61
62int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params,
63 struct snd_pcm_hw_rule *rule)
64{
65 struct uniperif *uni = rule->private;
66 struct snd_interval t;
67
68 t.min = uni->tdm_slot.avail_slots;
69 t.max = uni->tdm_slot.avail_slots;
70 t.openmin = 0;
71 t.openmax = 0;
72 t.integer = 0;
73
74 return snd_interval_refine(hw_param_interval(params, rule->var), &t);
75}
76
77int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params,
78 struct snd_pcm_hw_rule *rule)
79{
80 struct uniperif *uni = rule->private;
81 struct snd_mask *maskp = hw_param_mask(params, rule->var);
82 u64 format;
83
84 switch (uni->tdm_slot.slot_width) {
85 case 16:
86 format = SNDRV_PCM_FMTBIT_S16_LE;
87 break;
88 case 32:
89 format = SNDRV_PCM_FMTBIT_S32_LE;
90 break;
91 default:
92 dev_err(uni->dev, "format not supported: %d bits\n",
93 uni->tdm_slot.slot_width);
94 return -EINVAL;
95 }
96
97 maskp->bits[0] &= (u_int32_t)format;
98 maskp->bits[1] &= (u_int32_t)(format >> 32);
99 /* clear remaining indexes */
100 memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX - 64) / 8);
101
102 if (!maskp->bits[0] && !maskp->bits[1])
103 return -EINVAL;
104
105 return 0;
106}
107
108int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni,
109 unsigned int *word_pos)
110{
111 int slot_width = uni->tdm_slot.slot_width / 8;
112 int slots_num = uni->tdm_slot.slots;
113 unsigned int slots_mask = uni->tdm_slot.mask;
114 int i, j, k;
115 unsigned int word16_pos[4];
116
117 /* word16_pos:
118 * word16_pos[0] = WORDX_LSB
119 * word16_pos[1] = WORDX_MSB,
120 * word16_pos[2] = WORDX+1_LSB
121 * word16_pos[3] = WORDX+1_MSB
122 */
123
124 /* set unip word position */
125 for (i = 0, j = 0, k = 0; (i < slots_num) && (k < WORD_MAX); i++) {
126 if ((slots_mask >> i) & 0x01) {
127 word16_pos[j] = i * slot_width;
128
129 if (slot_width == 4) {
130 word16_pos[j + 1] = word16_pos[j] + 2;
131 j++;
132 }
133 j++;
134
135 if (j > 3) {
136 word_pos[k] = word16_pos[1] |
137 (word16_pos[0] << 8) |
138 (word16_pos[3] << 16) |
139 (word16_pos[2] << 24);
140 j = 0;
141 k++;
142 }
143 }
144 }
145
146 return 0;
147}
148
149/*
14 * sti_uniperiph_dai_create_ctrl 150 * sti_uniperiph_dai_create_ctrl
15 * This function is used to create Ctrl associated to DAI but also pcm device. 151 * This function is used to create Ctrl associated to DAI but also pcm device.
16 * Request is done by front end to associate ctrl with pcm device id 152 * Request is done by front end to associate ctrl with pcm device id
@@ -45,10 +181,16 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,
45 struct snd_pcm_hw_params *params, 181 struct snd_pcm_hw_params *params,
46 struct snd_soc_dai *dai) 182 struct snd_soc_dai *dai)
47{ 183{
184 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
185 struct uniperif *uni = priv->dai_data.uni;
48 struct snd_dmaengine_dai_dma_data *dma_data; 186 struct snd_dmaengine_dai_dma_data *dma_data;
49 int transfer_size; 187 int transfer_size;
50 188
51 transfer_size = params_channels(params) * UNIPERIF_FIFO_FRAMES; 189 if (uni->info->type == SND_ST_UNIPERIF_TYPE_TDM)
190 /* transfer size = user frame size (in 32-bits FIFO cell) */
191 transfer_size = snd_soc_params_to_frame_size(params) / 32;
192 else
193 transfer_size = params_channels(params) * UNIPERIF_FIFO_FRAMES;
52 194
53 dma_data = snd_soc_dai_get_dma_data(dai, substream); 195 dma_data = snd_soc_dai_get_dma_data(dai, substream);
54 dma_data->maxburst = transfer_size; 196 dma_data->maxburst = transfer_size;
diff --git a/sound/soc/sti/uniperif.h b/sound/soc/sti/uniperif.h
index f0fd5a9944e9..eb9933c62ad6 100644
--- a/sound/soc/sti/uniperif.h
+++ b/sound/soc/sti/uniperif.h
@@ -25,7 +25,7 @@
25 writel_relaxed((((value) & mask) << shift), ip->base + offset) 25 writel_relaxed((((value) & mask) << shift), ip->base + offset)
26 26
27/* 27/*
28 * AUD_UNIPERIF_SOFT_RST reg 28 * UNIPERIF_SOFT_RST reg
29 */ 29 */
30 30
31#define UNIPERIF_SOFT_RST_OFFSET(ip) 0x0000 31#define UNIPERIF_SOFT_RST_OFFSET(ip) 0x0000
@@ -50,7 +50,7 @@
50 UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip)) 50 UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip))
51 51
52/* 52/*
53 * AUD_UNIPERIF_FIFO_DATA reg 53 * UNIPERIF_FIFO_DATA reg
54 */ 54 */
55 55
56#define UNIPERIF_FIFO_DATA_OFFSET(ip) 0x0004 56#define UNIPERIF_FIFO_DATA_OFFSET(ip) 0x0004
@@ -58,7 +58,7 @@
58 writel_relaxed(value, ip->base + UNIPERIF_FIFO_DATA_OFFSET(ip)) 58 writel_relaxed(value, ip->base + UNIPERIF_FIFO_DATA_OFFSET(ip))
59 59
60/* 60/*
61 * AUD_UNIPERIF_CHANNEL_STA_REGN reg 61 * UNIPERIF_CHANNEL_STA_REGN reg
62 */ 62 */
63 63
64#define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n)) 64#define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n))
@@ -105,7 +105,7 @@
105 writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip)) 105 writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip))
106 106
107/* 107/*
108 * AUD_UNIPERIF_ITS reg 108 * UNIPERIF_ITS reg
109 */ 109 */
110 110
111#define UNIPERIF_ITS_OFFSET(ip) 0x000C 111#define UNIPERIF_ITS_OFFSET(ip) 0x000C
@@ -143,7 +143,7 @@
143 0 : (BIT(UNIPERIF_ITS_UNDERFLOW_REC_FAILED_SHIFT(ip)))) 143 0 : (BIT(UNIPERIF_ITS_UNDERFLOW_REC_FAILED_SHIFT(ip))))
144 144
145/* 145/*
146 * AUD_UNIPERIF_ITS_BCLR reg 146 * UNIPERIF_ITS_BCLR reg
147 */ 147 */
148 148
149/* FIFO_ERROR */ 149/* FIFO_ERROR */
@@ -160,7 +160,7 @@
160 writel_relaxed(value, ip->base + UNIPERIF_ITS_BCLR_OFFSET(ip)) 160 writel_relaxed(value, ip->base + UNIPERIF_ITS_BCLR_OFFSET(ip))
161 161
162/* 162/*
163 * AUD_UNIPERIF_ITM reg 163 * UNIPERIF_ITM reg
164 */ 164 */
165 165
166#define UNIPERIF_ITM_OFFSET(ip) 0x0018 166#define UNIPERIF_ITM_OFFSET(ip) 0x0018
@@ -188,7 +188,7 @@
188 0 : (BIT(UNIPERIF_ITM_UNDERFLOW_REC_FAILED_SHIFT(ip)))) 188 0 : (BIT(UNIPERIF_ITM_UNDERFLOW_REC_FAILED_SHIFT(ip))))
189 189
190/* 190/*
191 * AUD_UNIPERIF_ITM_BCLR reg 191 * UNIPERIF_ITM_BCLR reg
192 */ 192 */
193 193
194#define UNIPERIF_ITM_BCLR_OFFSET(ip) 0x001c 194#define UNIPERIF_ITM_BCLR_OFFSET(ip) 0x001c
@@ -213,7 +213,7 @@
213 UNIPERIF_ITM_BCLR_DMA_ERROR_MASK(ip)) 213 UNIPERIF_ITM_BCLR_DMA_ERROR_MASK(ip))
214 214
215/* 215/*
216 * AUD_UNIPERIF_ITM_BSET reg 216 * UNIPERIF_ITM_BSET reg
217 */ 217 */
218 218
219#define UNIPERIF_ITM_BSET_OFFSET(ip) 0x0020 219#define UNIPERIF_ITM_BSET_OFFSET(ip) 0x0020
@@ -767,7 +767,7 @@
767 SET_UNIPERIF_REG(ip, \ 767 SET_UNIPERIF_REG(ip, \
768 UNIPERIF_CTRL_OFFSET(ip), \ 768 UNIPERIF_CTRL_OFFSET(ip), \
769 UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \ 769 UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
770 CORAUD_UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip), 1) 770 UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip), 1)
771 771
772/* UNDERFLOW_REC_WINDOW */ 772/* UNDERFLOW_REC_WINDOW */
773#define UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip) 20 773#define UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip) 20
@@ -1046,7 +1046,7 @@
1046 UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip), value) 1046 UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip), value)
1047 1047
1048/* 1048/*
1049 * AUD_UNIPERIF_CHANNEL_STA_REGN reg 1049 * UNIPERIF_CHANNEL_STA_REGN reg
1050 */ 1050 */
1051 1051
1052#define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n)) 1052#define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n))
@@ -1057,7 +1057,7 @@
1057 UNIPERIF_CHANNEL_STA_REGN(ip, n)) 1057 UNIPERIF_CHANNEL_STA_REGN(ip, n))
1058 1058
1059/* 1059/*
1060 * AUD_UNIPERIF_USER_VALIDITY reg 1060 * UNIPERIF_USER_VALIDITY reg
1061 */ 1061 */
1062 1062
1063#define UNIPERIF_USER_VALIDITY_OFFSET(ip) 0x0090 1063#define UNIPERIF_USER_VALIDITY_OFFSET(ip) 0x0090
@@ -1101,12 +1101,136 @@
1101 UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip), value) 1101 UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip), value)
1102 1102
1103/* 1103/*
1104 * UNIPERIF_TDM_ENABLE
1105 */
1106#define UNIPERIF_TDM_ENABLE_OFFSET(ip) 0x0118
1107#define GET_UNIPERIF_TDM_ENABLE(ip) \
1108 readl_relaxed(ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip))
1109#define SET_UNIPERIF_TDM_ENABLE(ip, value) \
1110 writel_relaxed(value, ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip))
1111
1112/* TDM_ENABLE */
1113#define UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip) 0x0
1114#define UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip) 0x1
1115#define GET_UNIPERIF_TDM_ENABLE_EN_TDM(ip) \
1116 GET_UNIPERIF_REG(ip, \
1117 UNIPERIF_TDM_ENABLE_OFFSET(ip), \
1118 UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \
1119 UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip))
1120#define SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE(ip) \
1121 SET_UNIPERIF_REG(ip, \
1122 UNIPERIF_TDM_ENABLE_OFFSET(ip), \
1123 UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \
1124 UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 1)
1125#define SET_UNIPERIF_TDM_ENABLE_TDM_DISABLE(ip) \
1126 SET_UNIPERIF_REG(ip, \
1127 UNIPERIF_TDM_ENABLE_OFFSET(ip), \
1128 UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \
1129 UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 0)
1130
1131/*
1132 * UNIPERIF_TDM_FS_REF_FREQ
1133 */
1134#define UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip) 0x011c
1135#define GET_UNIPERIF_TDM_FS_REF_FREQ(ip) \
1136 readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip))
1137#define SET_UNIPERIF_TDM_FS_REF_FREQ(ip, value) \
1138 writel_relaxed(value, ip->base + \
1139 UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip))
1140
1141/* REF_FREQ */
1142#define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip) 0x0
1143#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip) 0
1144#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip) 1
1145#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip) 2
1146#define VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip) 3
1147#define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip) 0x3
1148#define GET_UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ(ip) \
1149 GET_UNIPERIF_REG(ip, \
1150 UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
1151 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
1152 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip))
1153#define SET_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip) \
1154 SET_UNIPERIF_REG(ip, \
1155 UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
1156 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
1157 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
1158 VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip))
1159#define SET_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip) \
1160 SET_UNIPERIF_REG(ip, \
1161 UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
1162 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
1163 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
1164 VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip))
1165#define SET_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip) \
1166 SET_UNIPERIF_REG(ip, \
1167 UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
1168 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
1169 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
1170 VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip))
1171#define SET_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip) \
1172 SET_UNIPERIF_REG(ip, \
1173 UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
1174 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
1175 UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
1176 VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip))
1177
1178/*
1179 * UNIPERIF_TDM_FS_REF_DIV
1180 */
1181#define UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip) 0x0120
1182#define GET_UNIPERIF_TDM_FS_REF_DIV(ip) \
1183 readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip))
1184#define SET_UNIPERIF_TDM_FS_REF_DIV(ip, value) \
1185 writel_relaxed(value, ip->base + \
1186 UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip))
1187
1188/* NUM_TIMESLOT */
1189#define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip) 0x0
1190#define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip) 0xff
1191#define GET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT(ip) \
1192 GET_UNIPERIF_REG(ip, \
1193 UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \
1194 UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \
1195 UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip))
1196#define SET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT(ip, value) \
1197 SET_UNIPERIF_REG(ip, \
1198 UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \
1199 UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \
1200 UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip), value)
1201
1202/*
1203 * UNIPERIF_TDM_WORD_POS_X_Y
1204 * 32 bits of UNIPERIF_TDM_WORD_POS_X_Y register shall be set in 1 shot
1205 */
1206#define UNIPERIF_TDM_WORD_POS_1_2_OFFSET(ip) 0x013c
1207#define UNIPERIF_TDM_WORD_POS_3_4_OFFSET(ip) 0x0140
1208#define UNIPERIF_TDM_WORD_POS_5_6_OFFSET(ip) 0x0144
1209#define UNIPERIF_TDM_WORD_POS_7_8_OFFSET(ip) 0x0148
1210#define GET_UNIPERIF_TDM_WORD_POS(ip, words) \
1211 readl_relaxed(ip->base + UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip))
1212#define SET_UNIPERIF_TDM_WORD_POS(ip, words, value) \
1213 writel_relaxed(value, ip->base + \
1214 UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip))
1215/*
1104 * uniperipheral IP capabilities 1216 * uniperipheral IP capabilities
1105 */ 1217 */
1106 1218
1107#define UNIPERIF_FIFO_SIZE 70 /* FIFO is 70 cells deep */ 1219#define UNIPERIF_FIFO_SIZE 70 /* FIFO is 70 cells deep */
1108#define UNIPERIF_FIFO_FRAMES 4 /* FDMA trigger limit in frames */ 1220#define UNIPERIF_FIFO_FRAMES 4 /* FDMA trigger limit in frames */
1109 1221
1222#define UNIPERIF_TYPE_IS_HDMI(p) \
1223 ((p)->info->type == SND_ST_UNIPERIF_TYPE_HDMI)
1224#define UNIPERIF_TYPE_IS_PCM(p) \
1225 ((p)->info->type == SND_ST_UNIPERIF_TYPE_PCM)
1226#define UNIPERIF_TYPE_IS_SPDIF(p) \
1227 ((p)->info->type == SND_ST_UNIPERIF_TYPE_SPDIF)
1228#define UNIPERIF_TYPE_IS_IEC958(p) \
1229 (UNIPERIF_TYPE_IS_HDMI(p) || \
1230 UNIPERIF_TYPE_IS_SPDIF(p))
1231#define UNIPERIF_TYPE_IS_TDM(p) \
1232 ((p)->info->type == SND_ST_UNIPERIF_TYPE_TDM)
1233
1110/* 1234/*
1111 * Uniperipheral IP revisions 1235 * Uniperipheral IP revisions
1112 */ 1236 */
@@ -1125,10 +1249,11 @@ enum uniperif_version {
1125}; 1249};
1126 1250
1127enum uniperif_type { 1251enum uniperif_type {
1128 SND_ST_UNIPERIF_PLAYER_TYPE_NONE, 1252 SND_ST_UNIPERIF_TYPE_NONE,
1129 SND_ST_UNIPERIF_PLAYER_TYPE_HDMI, 1253 SND_ST_UNIPERIF_TYPE_HDMI,
1130 SND_ST_UNIPERIF_PLAYER_TYPE_PCM, 1254 SND_ST_UNIPERIF_TYPE_PCM,
1131 SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF 1255 SND_ST_UNIPERIF_TYPE_SPDIF,
1256 SND_ST_UNIPERIF_TYPE_TDM
1132}; 1257};
1133 1258
1134enum uniperif_state { 1259enum uniperif_state {
@@ -1145,9 +1270,17 @@ enum uniperif_iec958_encoding_mode {
1145 UNIPERIF_IEC958_ENCODING_MODE_ENCODED 1270 UNIPERIF_IEC958_ENCODING_MODE_ENCODED
1146}; 1271};
1147 1272
1273enum uniperif_word_pos {
1274 WORD_1_2,
1275 WORD_3_4,
1276 WORD_5_6,
1277 WORD_7_8,
1278 WORD_MAX
1279};
1280
1148struct uniperif_info { 1281struct uniperif_info {
1149 int id; /* instance value of the uniperipheral IP */ 1282 int id; /* instance value of the uniperipheral IP */
1150 enum uniperif_type player_type; 1283 enum uniperif_type type;
1151 int underflow_enabled; /* Underflow recovery mode */ 1284 int underflow_enabled; /* Underflow recovery mode */
1152}; 1285};
1153 1286
@@ -1156,12 +1289,20 @@ struct uniperif_iec958_settings {
1156 struct snd_aes_iec958 iec958; 1289 struct snd_aes_iec958 iec958;
1157}; 1290};
1158 1291
1292struct dai_tdm_slot {
1293 unsigned int mask;
1294 int slots;
1295 int slot_width;
1296 unsigned int avail_slots;
1297};
1298
1159struct uniperif { 1299struct uniperif {
1160 /* System information */ 1300 /* System information */
1161 struct uniperif_info *info; 1301 struct uniperif_info *info;
1162 struct device *dev; 1302 struct device *dev;
1163 int ver; /* IP version, used by register access macros */ 1303 int ver; /* IP version, used by register access macros */
1164 struct regmap_field *clk_sel; 1304 struct regmap_field *clk_sel;
1305 struct regmap_field *valid_sel;
1165 1306
1166 /* capabilities */ 1307 /* capabilities */
1167 const struct snd_pcm_hardware *hw; 1308 const struct snd_pcm_hardware *hw;
@@ -1192,6 +1333,7 @@ struct uniperif {
1192 1333
1193 /* dai properties */ 1334 /* dai properties */
1194 unsigned int daifmt; 1335 unsigned int daifmt;
1336 struct dai_tdm_slot tdm_slot;
1195 1337
1196 /* DAI callbacks */ 1338 /* DAI callbacks */
1197 const struct snd_soc_dai_ops *dai_ops; 1339 const struct snd_soc_dai_ops *dai_ops;
@@ -1209,6 +1351,28 @@ struct sti_uniperiph_data {
1209 struct sti_uniperiph_dai dai_data; 1351 struct sti_uniperiph_dai dai_data;
1210}; 1352};
1211 1353
1354static const struct snd_pcm_hardware uni_tdm_hw = {
1355 .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
1356 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP |
1357 SNDRV_PCM_INFO_MMAP_VALID,
1358
1359 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE,
1360
1361 .rates = SNDRV_PCM_RATE_CONTINUOUS,
1362 .rate_min = 8000,
1363 .rate_max = 48000,
1364
1365 .channels_min = 1,
1366 .channels_max = 32,
1367
1368 .periods_min = 2,
1369 .periods_max = 10,
1370
1371 .period_bytes_min = 128,
1372 .period_bytes_max = 64 * PAGE_SIZE,
1373 .buffer_bytes_max = 256 * PAGE_SIZE
1374};
1375
1212/* uniperiph player*/ 1376/* uniperiph player*/
1213int uni_player_init(struct platform_device *pdev, 1377int uni_player_init(struct platform_device *pdev,
1214 struct uniperif *uni_player); 1378 struct uniperif *uni_player);
@@ -1226,4 +1390,28 @@ int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,
1226 struct snd_pcm_hw_params *params, 1390 struct snd_pcm_hw_params *params,
1227 struct snd_soc_dai *dai); 1391 struct snd_soc_dai *dai);
1228 1392
1393static inline int sti_uniperiph_get_user_frame_size(
1394 struct snd_pcm_runtime *runtime)
1395{
1396 return (runtime->channels * snd_pcm_format_width(runtime->format) / 8);
1397}
1398
1399static inline int sti_uniperiph_get_unip_tdm_frame_size(struct uniperif *uni)
1400{
1401 return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8);
1402}
1403
1404int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
1405 unsigned int rx_mask, int slots,
1406 int slot_width);
1407
1408int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni,
1409 unsigned int *word_pos);
1410
1411int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params,
1412 struct snd_pcm_hw_rule *rule);
1413
1414int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params,
1415 struct snd_pcm_hw_rule *rule);
1416
1229#endif 1417#endif
diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c
index 7aca6b92f718..ee1c7c245bc7 100644
--- a/sound/soc/sti/uniperif_player.c
+++ b/sound/soc/sti/uniperif_player.c
@@ -21,23 +21,14 @@
21 21
22/* sys config registers definitions */ 22/* sys config registers definitions */
23#define SYS_CFG_AUDIO_GLUE 0xA4 23#define SYS_CFG_AUDIO_GLUE 0xA4
24#define SYS_CFG_AUDI0_GLUE_PCM_CLKX 8
25 24
26/* 25/*
27 * Driver specific types. 26 * Driver specific types.
28 */ 27 */
29#define UNIPERIF_PLAYER_TYPE_IS_HDMI(p) \
30 ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_HDMI)
31#define UNIPERIF_PLAYER_TYPE_IS_PCM(p) \
32 ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_PCM)
33#define UNIPERIF_PLAYER_TYPE_IS_SPDIF(p) \
34 ((p)->info->player_type == SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF)
35#define UNIPERIF_PLAYER_TYPE_IS_IEC958(p) \
36 (UNIPERIF_PLAYER_TYPE_IS_HDMI(p) || \
37 UNIPERIF_PLAYER_TYPE_IS_SPDIF(p))
38 28
39#define UNIPERIF_PLAYER_CLK_ADJ_MIN -999999 29#define UNIPERIF_PLAYER_CLK_ADJ_MIN -999999
40#define UNIPERIF_PLAYER_CLK_ADJ_MAX 1000000 30#define UNIPERIF_PLAYER_CLK_ADJ_MAX 1000000
31#define UNIPERIF_PLAYER_I2S_OUT 1 /* player id connected to I2S/TDM TX bus */
41 32
42/* 33/*
43 * Note: snd_pcm_hardware is linked to DMA controller but is declared here to 34 * Note: snd_pcm_hardware is linked to DMA controller but is declared here to
@@ -444,18 +435,11 @@ static int uni_player_prepare_pcm(struct uniperif *player,
444 435
445 /* Force slot width to 32 in I2S mode (HW constraint) */ 436 /* Force slot width to 32 in I2S mode (HW constraint) */
446 if ((player->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) == 437 if ((player->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) ==
447 SND_SOC_DAIFMT_I2S) { 438 SND_SOC_DAIFMT_I2S)
448 slot_width = 32; 439 slot_width = 32;
449 } else { 440 else
450 switch (runtime->format) { 441 slot_width = snd_pcm_format_width(runtime->format);
451 case SNDRV_PCM_FORMAT_S16_LE: 442
452 slot_width = 16;
453 break;
454 default:
455 slot_width = 32;
456 break;
457 }
458 }
459 output_frame_size = slot_width * runtime->channels; 443 output_frame_size = slot_width * runtime->channels;
460 444
461 clk_div = player->mclk / runtime->rate; 445 clk_div = player->mclk / runtime->rate;
@@ -530,7 +514,6 @@ static int uni_player_prepare_pcm(struct uniperif *player,
530 SET_UNIPERIF_CONFIG_ONE_BIT_AUD_DISABLE(player); 514 SET_UNIPERIF_CONFIG_ONE_BIT_AUD_DISABLE(player);
531 515
532 SET_UNIPERIF_I2S_FMT_ORDER_MSB(player); 516 SET_UNIPERIF_I2S_FMT_ORDER_MSB(player);
533 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(player);
534 517
535 /* No iec958 formatting as outputting to DAC */ 518 /* No iec958 formatting as outputting to DAC */
536 SET_UNIPERIF_CTRL_SPDIF_FMT_OFF(player); 519 SET_UNIPERIF_CTRL_SPDIF_FMT_OFF(player);
@@ -538,6 +521,55 @@ static int uni_player_prepare_pcm(struct uniperif *player,
538 return 0; 521 return 0;
539} 522}
540 523
524static int uni_player_prepare_tdm(struct uniperif *player,
525 struct snd_pcm_runtime *runtime)
526{
527 int tdm_frame_size; /* unip tdm frame size in bytes */
528 int user_frame_size; /* user tdm frame size in bytes */
529 /* default unip TDM_WORD_POS_X_Y */
530 unsigned int word_pos[4] = {
531 0x04060002, 0x0C0E080A, 0x14161012, 0x1C1E181A};
532 int freq, ret;
533
534 tdm_frame_size =
535 sti_uniperiph_get_unip_tdm_frame_size(player);
536 user_frame_size =
537 sti_uniperiph_get_user_frame_size(runtime);
538
539 /* fix 16/0 format */
540 SET_UNIPERIF_CONFIG_MEM_FMT_16_0(player);
541 SET_UNIPERIF_I2S_FMT_DATA_SIZE_32(player);
542
543 /* number of words inserted on the TDM line */
544 SET_UNIPERIF_I2S_FMT_NUM_CH(player, user_frame_size / 4 / 2);
545
546 SET_UNIPERIF_I2S_FMT_ORDER_MSB(player);
547 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(player);
548
549 /* Enable the tdm functionality */
550 SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE(player);
551
552 /* number of 8 bits timeslots avail in unip tdm frame */
553 SET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT(player, tdm_frame_size);
554
555 /* set the timeslot allocation for words in FIFO */
556 sti_uniperiph_get_tdm_word_pos(player, word_pos);
557 SET_UNIPERIF_TDM_WORD_POS(player, 1_2, word_pos[WORD_1_2]);
558 SET_UNIPERIF_TDM_WORD_POS(player, 3_4, word_pos[WORD_3_4]);
559 SET_UNIPERIF_TDM_WORD_POS(player, 5_6, word_pos[WORD_5_6]);
560 SET_UNIPERIF_TDM_WORD_POS(player, 7_8, word_pos[WORD_7_8]);
561
562 /* set unip clk rate (not done vai set_sysclk ops) */
563 freq = runtime->rate * tdm_frame_size * 8;
564 mutex_lock(&player->ctrl_lock);
565 ret = uni_player_clk_set_rate(player, freq);
566 if (!ret)
567 player->mclk = freq;
568 mutex_unlock(&player->ctrl_lock);
569
570 return 0;
571}
572
541/* 573/*
542 * ALSA uniperipheral iec958 controls 574 * ALSA uniperipheral iec958 controls
543 */ 575 */
@@ -668,11 +700,29 @@ static int uni_player_startup(struct snd_pcm_substream *substream,
668{ 700{
669 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai); 701 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
670 struct uniperif *player = priv->dai_data.uni; 702 struct uniperif *player = priv->dai_data.uni;
703 int ret;
704
671 player->substream = substream; 705 player->substream = substream;
672 706
673 player->clk_adj = 0; 707 player->clk_adj = 0;
674 708
675 return 0; 709 if (!UNIPERIF_TYPE_IS_TDM(player))
710 return 0;
711
712 /* refine hw constraint in tdm mode */
713 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
714 SNDRV_PCM_HW_PARAM_CHANNELS,
715 sti_uniperiph_fix_tdm_chan,
716 player, SNDRV_PCM_HW_PARAM_CHANNELS,
717 -1);
718 if (ret < 0)
719 return ret;
720
721 return snd_pcm_hw_rule_add(substream->runtime, 0,
722 SNDRV_PCM_HW_PARAM_FORMAT,
723 sti_uniperiph_fix_tdm_format,
724 player, SNDRV_PCM_HW_PARAM_FORMAT,
725 -1);
676} 726}
677 727
678static int uni_player_set_sysclk(struct snd_soc_dai *dai, int clk_id, 728static int uni_player_set_sysclk(struct snd_soc_dai *dai, int clk_id,
@@ -682,7 +732,7 @@ static int uni_player_set_sysclk(struct snd_soc_dai *dai, int clk_id,
682 struct uniperif *player = priv->dai_data.uni; 732 struct uniperif *player = priv->dai_data.uni;
683 int ret; 733 int ret;
684 734
685 if (dir == SND_SOC_CLOCK_IN) 735 if (UNIPERIF_TYPE_IS_TDM(player) || (dir == SND_SOC_CLOCK_IN))
686 return 0; 736 return 0;
687 737
688 if (clk_id != 0) 738 if (clk_id != 0)
@@ -714,7 +764,13 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
714 } 764 }
715 765
716 /* Calculate transfer size (in fifo cells and bytes) for frame count */ 766 /* Calculate transfer size (in fifo cells and bytes) for frame count */
717 transfer_size = runtime->channels * UNIPERIF_FIFO_FRAMES; 767 if (player->info->type == SND_ST_UNIPERIF_TYPE_TDM) {
768 /* transfer size = user frame size (in 32 bits FIFO cell) */
769 transfer_size =
770 sti_uniperiph_get_user_frame_size(runtime) / 4;
771 } else {
772 transfer_size = runtime->channels * UNIPERIF_FIFO_FRAMES;
773 }
718 774
719 /* Calculate number of empty cells available before asserting DREQ */ 775 /* Calculate number of empty cells available before asserting DREQ */
720 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) { 776 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
@@ -738,16 +794,19 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
738 SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(player, trigger_limit); 794 SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(player, trigger_limit);
739 795
740 /* Uniperipheral setup depends on player type */ 796 /* Uniperipheral setup depends on player type */
741 switch (player->info->player_type) { 797 switch (player->info->type) {
742 case SND_ST_UNIPERIF_PLAYER_TYPE_HDMI: 798 case SND_ST_UNIPERIF_TYPE_HDMI:
743 ret = uni_player_prepare_iec958(player, runtime); 799 ret = uni_player_prepare_iec958(player, runtime);
744 break; 800 break;
745 case SND_ST_UNIPERIF_PLAYER_TYPE_PCM: 801 case SND_ST_UNIPERIF_TYPE_PCM:
746 ret = uni_player_prepare_pcm(player, runtime); 802 ret = uni_player_prepare_pcm(player, runtime);
747 break; 803 break;
748 case SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF: 804 case SND_ST_UNIPERIF_TYPE_SPDIF:
749 ret = uni_player_prepare_iec958(player, runtime); 805 ret = uni_player_prepare_iec958(player, runtime);
750 break; 806 break;
807 case SND_ST_UNIPERIF_TYPE_TDM:
808 ret = uni_player_prepare_tdm(player, runtime);
809 break;
751 default: 810 default:
752 dev_err(player->dev, "invalid player type"); 811 dev_err(player->dev, "invalid player type");
753 return -EINVAL; 812 return -EINVAL;
@@ -852,8 +911,8 @@ static int uni_player_start(struct uniperif *player)
852 * will not take affect and hang the player. 911 * will not take affect and hang the player.
853 */ 912 */
854 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) 913 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0)
855 if (UNIPERIF_PLAYER_TYPE_IS_IEC958(player)) 914 if (UNIPERIF_TYPE_IS_IEC958(player))
856 SET_UNIPERIF_CTRL_SPDIF_FMT_ON(player); 915 SET_UNIPERIF_CTRL_SPDIF_FMT_ON(player);
857 916
858 /* Force channel status update (no update if clk disable) */ 917 /* Force channel status update (no update if clk disable) */
859 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) 918 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0)
@@ -954,27 +1013,30 @@ static void uni_player_shutdown(struct snd_pcm_substream *substream,
954 player->substream = NULL; 1013 player->substream = NULL;
955} 1014}
956 1015
957static int uni_player_parse_dt_clk_glue(struct platform_device *pdev, 1016static int uni_player_parse_dt_audio_glue(struct platform_device *pdev,
958 struct uniperif *player) 1017 struct uniperif *player)
959{ 1018{
960 int bit_offset;
961 struct device_node *node = pdev->dev.of_node; 1019 struct device_node *node = pdev->dev.of_node;
962 struct regmap *regmap; 1020 struct regmap *regmap;
963 1021 struct reg_field regfield[2] = {
964 bit_offset = SYS_CFG_AUDI0_GLUE_PCM_CLKX + player->info->id; 1022 /* PCM_CLK_SEL */
1023 REG_FIELD(SYS_CFG_AUDIO_GLUE,
1024 8 + player->info->id,
1025 8 + player->info->id),
1026 /* PCMP_VALID_SEL */
1027 REG_FIELD(SYS_CFG_AUDIO_GLUE, 0, 1)
1028 };
965 1029
966 regmap = syscon_regmap_lookup_by_phandle(node, "st,syscfg"); 1030 regmap = syscon_regmap_lookup_by_phandle(node, "st,syscfg");
967 1031
968 if (regmap) { 1032 if (!regmap) {
969 struct reg_field regfield =
970 REG_FIELD(SYS_CFG_AUDIO_GLUE, bit_offset, bit_offset);
971
972 player->clk_sel = regmap_field_alloc(regmap, regfield);
973 } else {
974 dev_err(&pdev->dev, "sti-audio-clk-glue syscf not found\n"); 1033 dev_err(&pdev->dev, "sti-audio-clk-glue syscf not found\n");
975 return -EINVAL; 1034 return -EINVAL;
976 } 1035 }
977 1036
1037 player->clk_sel = regmap_field_alloc(regmap, regfield[0]);
1038 player->valid_sel = regmap_field_alloc(regmap, regfield[1]);
1039
978 return 0; 1040 return 0;
979} 1041}
980 1042
@@ -1012,19 +1074,21 @@ static int uni_player_parse_dt(struct platform_device *pdev,
1012 } 1074 }
1013 1075
1014 if (strcasecmp(mode, "hdmi") == 0) 1076 if (strcasecmp(mode, "hdmi") == 0)
1015 info->player_type = SND_ST_UNIPERIF_PLAYER_TYPE_HDMI; 1077 info->type = SND_ST_UNIPERIF_TYPE_HDMI;
1016 else if (strcasecmp(mode, "pcm") == 0) 1078 else if (strcasecmp(mode, "pcm") == 0)
1017 info->player_type = SND_ST_UNIPERIF_PLAYER_TYPE_PCM; 1079 info->type = SND_ST_UNIPERIF_TYPE_PCM;
1018 else if (strcasecmp(mode, "spdif") == 0) 1080 else if (strcasecmp(mode, "spdif") == 0)
1019 info->player_type = SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF; 1081 info->type = SND_ST_UNIPERIF_TYPE_SPDIF;
1082 else if (strcasecmp(mode, "tdm") == 0)
1083 info->type = SND_ST_UNIPERIF_TYPE_TDM;
1020 else 1084 else
1021 info->player_type = SND_ST_UNIPERIF_PLAYER_TYPE_NONE; 1085 info->type = SND_ST_UNIPERIF_TYPE_NONE;
1022 1086
1023 /* Save the info structure */ 1087 /* Save the info structure */
1024 player->info = info; 1088 player->info = info;
1025 1089
1026 /* Get the PCM_CLK_SEL bit from audio-glue-ctrl SoC register */ 1090 /* Get PCM_CLK_SEL & PCMP_VALID_SEL from audio-glue-ctrl SoC reg */
1027 if (uni_player_parse_dt_clk_glue(pdev, player)) 1091 if (uni_player_parse_dt_audio_glue(pdev, player))
1028 return -EINVAL; 1092 return -EINVAL;
1029 1093
1030 return 0; 1094 return 0;
@@ -1037,7 +1101,8 @@ static const struct snd_soc_dai_ops uni_player_dai_ops = {
1037 .trigger = uni_player_trigger, 1101 .trigger = uni_player_trigger,
1038 .hw_params = sti_uniperiph_dai_hw_params, 1102 .hw_params = sti_uniperiph_dai_hw_params,
1039 .set_fmt = sti_uniperiph_dai_set_fmt, 1103 .set_fmt = sti_uniperiph_dai_set_fmt,
1040 .set_sysclk = uni_player_set_sysclk 1104 .set_sysclk = uni_player_set_sysclk,
1105 .set_tdm_slot = sti_uniperiph_set_tdm_slot
1041}; 1106};
1042 1107
1043int uni_player_init(struct platform_device *pdev, 1108int uni_player_init(struct platform_device *pdev,
@@ -1047,7 +1112,6 @@ int uni_player_init(struct platform_device *pdev,
1047 1112
1048 player->dev = &pdev->dev; 1113 player->dev = &pdev->dev;
1049 player->state = UNIPERIF_STATE_STOPPED; 1114 player->state = UNIPERIF_STATE_STOPPED;
1050 player->hw = &uni_player_pcm_hw;
1051 player->dai_ops = &uni_player_dai_ops; 1115 player->dai_ops = &uni_player_dai_ops;
1052 1116
1053 ret = uni_player_parse_dt(pdev, player); 1117 ret = uni_player_parse_dt(pdev, player);
@@ -1057,6 +1121,11 @@ int uni_player_init(struct platform_device *pdev,
1057 return ret; 1121 return ret;
1058 } 1122 }
1059 1123
1124 if (UNIPERIF_TYPE_IS_TDM(player))
1125 player->hw = &uni_tdm_hw;
1126 else
1127 player->hw = &uni_player_pcm_hw;
1128
1060 /* Get uniperif resource */ 1129 /* Get uniperif resource */
1061 player->clk = of_clk_get(pdev->dev.of_node, 0); 1130 player->clk = of_clk_get(pdev->dev.of_node, 0);
1062 if (IS_ERR(player->clk)) 1131 if (IS_ERR(player->clk))
@@ -1073,6 +1142,17 @@ int uni_player_init(struct platform_device *pdev,
1073 } 1142 }
1074 } 1143 }
1075 1144
1145 /* connect to I2S/TDM TX bus */
1146 if (player->valid_sel &&
1147 (player->info->id == UNIPERIF_PLAYER_I2S_OUT)) {
1148 ret = regmap_field_write(player->valid_sel, player->info->id);
1149 if (ret) {
1150 dev_err(player->dev,
1151 "%s: unable to connect to tdm bus", __func__);
1152 return ret;
1153 }
1154 }
1155
1076 ret = devm_request_irq(&pdev->dev, player->irq, 1156 ret = devm_request_irq(&pdev->dev, player->irq,
1077 uni_player_irq_handler, IRQF_SHARED, 1157 uni_player_irq_handler, IRQF_SHARED,
1078 dev_name(&pdev->dev), player); 1158 dev_name(&pdev->dev), player);
@@ -1087,7 +1167,7 @@ int uni_player_init(struct platform_device *pdev,
1087 SET_UNIPERIF_CTRL_SPDIF_LAT_OFF(player); 1167 SET_UNIPERIF_CTRL_SPDIF_LAT_OFF(player);
1088 SET_UNIPERIF_CONFIG_IDLE_MOD_DISABLE(player); 1168 SET_UNIPERIF_CONFIG_IDLE_MOD_DISABLE(player);
1089 1169
1090 if (UNIPERIF_PLAYER_TYPE_IS_IEC958(player)) { 1170 if (UNIPERIF_TYPE_IS_IEC958(player)) {
1091 /* Set default iec958 status bits */ 1171 /* Set default iec958 status bits */
1092 1172
1093 /* Consumer, PCM, copyright, 2ch, mode 0 */ 1173 /* Consumer, PCM, copyright, 2ch, mode 0 */
diff --git a/sound/soc/sti/uniperif_reader.c b/sound/soc/sti/uniperif_reader.c
index 8a0eb2050169..eb74a328c928 100644
--- a/sound/soc/sti/uniperif_reader.c
+++ b/sound/soc/sti/uniperif_reader.c
@@ -73,55 +73,10 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
73 return ret; 73 return ret;
74} 74}
75 75
76static int uni_reader_prepare(struct snd_pcm_substream *substream, 76static int uni_reader_prepare_pcm(struct snd_pcm_runtime *runtime,
77 struct snd_soc_dai *dai) 77 struct uniperif *reader)
78{ 78{
79 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
80 struct uniperif *reader = priv->dai_data.uni;
81 struct snd_pcm_runtime *runtime = substream->runtime;
82 int transfer_size, trigger_limit;
83 int slot_width; 79 int slot_width;
84 int count = 10;
85
86 /* The reader should be stopped */
87 if (reader->state != UNIPERIF_STATE_STOPPED) {
88 dev_err(reader->dev, "%s: invalid reader state %d", __func__,
89 reader->state);
90 return -EINVAL;
91 }
92
93 /* Calculate transfer size (in fifo cells and bytes) for frame count */
94 transfer_size = runtime->channels * UNIPERIF_FIFO_FRAMES;
95
96 /* Calculate number of empty cells available before asserting DREQ */
97 if (reader->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0)
98 trigger_limit = UNIPERIF_FIFO_SIZE - transfer_size;
99 else
100 /*
101 * Since SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0
102 * FDMA_TRIGGER_LIMIT also controls when the state switches
103 * from OFF or STANDBY to AUDIO DATA.
104 */
105 trigger_limit = transfer_size;
106
107 /* Trigger limit must be an even number */
108 if ((!trigger_limit % 2) ||
109 (trigger_limit != 1 && transfer_size % 2) ||
110 (trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(reader))) {
111 dev_err(reader->dev, "invalid trigger limit %d", trigger_limit);
112 return -EINVAL;
113 }
114
115 SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(reader, trigger_limit);
116
117 switch (reader->daifmt & SND_SOC_DAIFMT_INV_MASK) {
118 case SND_SOC_DAIFMT_IB_IF:
119 case SND_SOC_DAIFMT_NB_IF:
120 SET_UNIPERIF_I2S_FMT_LR_POL_HIG(reader);
121 break;
122 default:
123 SET_UNIPERIF_I2S_FMT_LR_POL_LOW(reader);
124 }
125 80
126 /* Force slot width to 32 in I2S mode */ 81 /* Force slot width to 32 in I2S mode */
127 if ((reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) 82 if ((reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK)
@@ -173,6 +128,109 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
173 return -EINVAL; 128 return -EINVAL;
174 } 129 }
175 130
131 /* Number of channels must be even */
132 if ((runtime->channels % 2) || (runtime->channels < 2) ||
133 (runtime->channels > 10)) {
134 dev_err(reader->dev, "%s: invalid nb of channels", __func__);
135 return -EINVAL;
136 }
137
138 SET_UNIPERIF_I2S_FMT_NUM_CH(reader, runtime->channels / 2);
139 SET_UNIPERIF_I2S_FMT_ORDER_MSB(reader);
140
141 return 0;
142}
143
144static int uni_reader_prepare_tdm(struct snd_pcm_runtime *runtime,
145 struct uniperif *reader)
146{
147 int frame_size; /* user tdm frame size in bytes */
148 /* default unip TDM_WORD_POS_X_Y */
149 unsigned int word_pos[4] = {
150 0x04060002, 0x0C0E080A, 0x14161012, 0x1C1E181A};
151
152 frame_size = sti_uniperiph_get_user_frame_size(runtime);
153
154 /* fix 16/0 format */
155 SET_UNIPERIF_CONFIG_MEM_FMT_16_0(reader);
156 SET_UNIPERIF_I2S_FMT_DATA_SIZE_32(reader);
157
158 /* number of words inserted on the TDM line */
159 SET_UNIPERIF_I2S_FMT_NUM_CH(reader, frame_size / 4 / 2);
160
161 SET_UNIPERIF_I2S_FMT_ORDER_MSB(reader);
162 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(reader);
163 SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE(reader);
164
165 /*
166 * set the timeslots allocation for words in FIFO
167 *
168 * HW bug: (LSB word < MSB word) => this config is not possible
169 * So if we want (LSB word < MSB) word, then it shall be
170 * handled by user
171 */
172 sti_uniperiph_get_tdm_word_pos(reader, word_pos);
173 SET_UNIPERIF_TDM_WORD_POS(reader, 1_2, word_pos[WORD_1_2]);
174 SET_UNIPERIF_TDM_WORD_POS(reader, 3_4, word_pos[WORD_3_4]);
175 SET_UNIPERIF_TDM_WORD_POS(reader, 5_6, word_pos[WORD_5_6]);
176 SET_UNIPERIF_TDM_WORD_POS(reader, 7_8, word_pos[WORD_7_8]);
177
178 return 0;
179}
180
181static int uni_reader_prepare(struct snd_pcm_substream *substream,
182 struct snd_soc_dai *dai)
183{
184 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
185 struct uniperif *reader = priv->dai_data.uni;
186 struct snd_pcm_runtime *runtime = substream->runtime;
187 int transfer_size, trigger_limit, ret;
188 int count = 10;
189
190 /* The reader should be stopped */
191 if (reader->state != UNIPERIF_STATE_STOPPED) {
192 dev_err(reader->dev, "%s: invalid reader state %d", __func__,
193 reader->state);
194 return -EINVAL;
195 }
196
197 /* Calculate transfer size (in fifo cells and bytes) for frame count */
198 if (reader->info->type == SND_ST_UNIPERIF_TYPE_TDM) {
199 /* transfer size = unip frame size (in 32 bits FIFO cell) */
200 transfer_size =
201 sti_uniperiph_get_user_frame_size(runtime) / 4;
202 } else {
203 transfer_size = runtime->channels * UNIPERIF_FIFO_FRAMES;
204 }
205
206 /* Calculate number of empty cells available before asserting DREQ */
207 if (reader->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0)
208 trigger_limit = UNIPERIF_FIFO_SIZE - transfer_size;
209 else
210 /*
211 * Since SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0
212 * FDMA_TRIGGER_LIMIT also controls when the state switches
213 * from OFF or STANDBY to AUDIO DATA.
214 */
215 trigger_limit = transfer_size;
216
217 /* Trigger limit must be an even number */
218 if ((!trigger_limit % 2) ||
219 (trigger_limit != 1 && transfer_size % 2) ||
220 (trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(reader))) {
221 dev_err(reader->dev, "invalid trigger limit %d", trigger_limit);
222 return -EINVAL;
223 }
224
225 SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(reader, trigger_limit);
226
227 if (UNIPERIF_TYPE_IS_TDM(reader))
228 ret = uni_reader_prepare_tdm(runtime, reader);
229 else
230 ret = uni_reader_prepare_pcm(runtime, reader);
231 if (ret)
232 return ret;
233
176 switch (reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) { 234 switch (reader->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) {
177 case SND_SOC_DAIFMT_I2S: 235 case SND_SOC_DAIFMT_I2S:
178 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(reader); 236 SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(reader);
@@ -191,21 +249,26 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
191 return -EINVAL; 249 return -EINVAL;
192 } 250 }
193 251
194 SET_UNIPERIF_I2S_FMT_ORDER_MSB(reader); 252 /* Data clocking (changing) on the rising/falling edge */
195 253 switch (reader->daifmt & SND_SOC_DAIFMT_INV_MASK) {
196 /* Data clocking (changing) on the rising edge */ 254 case SND_SOC_DAIFMT_NB_NF:
197 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(reader); 255 SET_UNIPERIF_I2S_FMT_LR_POL_LOW(reader);
198 256 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(reader);
199 /* Number of channels must be even */ 257 break;
200 258 case SND_SOC_DAIFMT_NB_IF:
201 if ((runtime->channels % 2) || (runtime->channels < 2) || 259 SET_UNIPERIF_I2S_FMT_LR_POL_HIG(reader);
202 (runtime->channels > 10)) { 260 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(reader);
203 dev_err(reader->dev, "%s: invalid nb of channels", __func__); 261 break;
204 return -EINVAL; 262 case SND_SOC_DAIFMT_IB_NF:
263 SET_UNIPERIF_I2S_FMT_LR_POL_LOW(reader);
264 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(reader);
265 break;
266 case SND_SOC_DAIFMT_IB_IF:
267 SET_UNIPERIF_I2S_FMT_LR_POL_HIG(reader);
268 SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(reader);
269 break;
205 } 270 }
206 271
207 SET_UNIPERIF_I2S_FMT_NUM_CH(reader, runtime->channels / 2);
208
209 /* Clear any pending interrupts */ 272 /* Clear any pending interrupts */
210 SET_UNIPERIF_ITS_BCLR(reader, GET_UNIPERIF_ITS(reader)); 273 SET_UNIPERIF_ITS_BCLR(reader, GET_UNIPERIF_ITS(reader));
211 274
@@ -293,6 +356,32 @@ static int uni_reader_trigger(struct snd_pcm_substream *substream,
293 } 356 }
294} 357}
295 358
359static int uni_reader_startup(struct snd_pcm_substream *substream,
360 struct snd_soc_dai *dai)
361{
362 struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
363 struct uniperif *reader = priv->dai_data.uni;
364 int ret;
365
366 if (!UNIPERIF_TYPE_IS_TDM(reader))
367 return 0;
368
369 /* refine hw constraint in tdm mode */
370 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
371 SNDRV_PCM_HW_PARAM_CHANNELS,
372 sti_uniperiph_fix_tdm_chan,
373 reader, SNDRV_PCM_HW_PARAM_CHANNELS,
374 -1);
375 if (ret < 0)
376 return ret;
377
378 return snd_pcm_hw_rule_add(substream->runtime, 0,
379 SNDRV_PCM_HW_PARAM_FORMAT,
380 sti_uniperiph_fix_tdm_format,
381 reader, SNDRV_PCM_HW_PARAM_FORMAT,
382 -1);
383}
384
296static void uni_reader_shutdown(struct snd_pcm_substream *substream, 385static void uni_reader_shutdown(struct snd_pcm_substream *substream,
297 struct snd_soc_dai *dai) 386 struct snd_soc_dai *dai)
298{ 387{
@@ -310,6 +399,7 @@ static int uni_reader_parse_dt(struct platform_device *pdev,
310{ 399{
311 struct uniperif_info *info; 400 struct uniperif_info *info;
312 struct device_node *node = pdev->dev.of_node; 401 struct device_node *node = pdev->dev.of_node;
402 const char *mode;
313 403
314 /* Allocate memory for the info structure */ 404 /* Allocate memory for the info structure */
315 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 405 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
@@ -322,6 +412,17 @@ static int uni_reader_parse_dt(struct platform_device *pdev,
322 return -EINVAL; 412 return -EINVAL;
323 } 413 }
324 414
415 /* Read the device mode property */
416 if (of_property_read_string(node, "st,mode", &mode)) {
417 dev_err(&pdev->dev, "uniperipheral mode not defined");
418 return -EINVAL;
419 }
420
421 if (strcasecmp(mode, "tdm") == 0)
422 info->type = SND_ST_UNIPERIF_TYPE_TDM;
423 else
424 info->type = SND_ST_UNIPERIF_TYPE_PCM;
425
325 /* Save the info structure */ 426 /* Save the info structure */
326 reader->info = info; 427 reader->info = info;
327 428
@@ -329,11 +430,13 @@ static int uni_reader_parse_dt(struct platform_device *pdev,
329} 430}
330 431
331static const struct snd_soc_dai_ops uni_reader_dai_ops = { 432static const struct snd_soc_dai_ops uni_reader_dai_ops = {
433 .startup = uni_reader_startup,
332 .shutdown = uni_reader_shutdown, 434 .shutdown = uni_reader_shutdown,
333 .prepare = uni_reader_prepare, 435 .prepare = uni_reader_prepare,
334 .trigger = uni_reader_trigger, 436 .trigger = uni_reader_trigger,
335 .hw_params = sti_uniperiph_dai_hw_params, 437 .hw_params = sti_uniperiph_dai_hw_params,
336 .set_fmt = sti_uniperiph_dai_set_fmt, 438 .set_fmt = sti_uniperiph_dai_set_fmt,
439 .set_tdm_slot = sti_uniperiph_set_tdm_slot
337}; 440};
338 441
339int uni_reader_init(struct platform_device *pdev, 442int uni_reader_init(struct platform_device *pdev,
@@ -343,7 +446,6 @@ int uni_reader_init(struct platform_device *pdev,
343 446
344 reader->dev = &pdev->dev; 447 reader->dev = &pdev->dev;
345 reader->state = UNIPERIF_STATE_STOPPED; 448 reader->state = UNIPERIF_STATE_STOPPED;
346 reader->hw = &uni_reader_pcm_hw;
347 reader->dai_ops = &uni_reader_dai_ops; 449 reader->dai_ops = &uni_reader_dai_ops;
348 450
349 ret = uni_reader_parse_dt(pdev, reader); 451 ret = uni_reader_parse_dt(pdev, reader);
@@ -352,6 +454,11 @@ int uni_reader_init(struct platform_device *pdev,
352 return ret; 454 return ret;
353 } 455 }
354 456
457 if (UNIPERIF_TYPE_IS_TDM(reader))
458 reader->hw = &uni_tdm_hw;
459 else
460 reader->hw = &uni_reader_pcm_hw;
461
355 ret = devm_request_irq(&pdev->dev, reader->irq, 462 ret = devm_request_irq(&pdev->dev, reader->irq,
356 uni_reader_irq_handler, IRQF_SHARED, 463 uni_reader_irq_handler, IRQF_SHARED,
357 dev_name(&pdev->dev), reader); 464 dev_name(&pdev->dev), reader);
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 6b7707270aa3..9f878619077a 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -30,6 +30,7 @@ endef
30FEATURE_TESTS_BASIC := \ 30FEATURE_TESTS_BASIC := \
31 backtrace \ 31 backtrace \
32 dwarf \ 32 dwarf \
33 dwarf_getlocations \
33 fortify-source \ 34 fortify-source \
34 sync-compare-and-swap \ 35 sync-compare-and-swap \
35 glibc \ 36 glibc \
@@ -78,6 +79,7 @@ endif
78 79
79FEATURE_DISPLAY ?= \ 80FEATURE_DISPLAY ?= \
80 dwarf \ 81 dwarf \
82 dwarf_getlocations \
81 glibc \ 83 glibc \
82 gtk2 \ 84 gtk2 \
83 libaudit \ 85 libaudit \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index c5f4c417428d..4ae94dbfdab9 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -3,6 +3,7 @@ FILES= \
3 test-backtrace.bin \ 3 test-backtrace.bin \
4 test-bionic.bin \ 4 test-bionic.bin \
5 test-dwarf.bin \ 5 test-dwarf.bin \
6 test-dwarf_getlocations.bin \
6 test-fortify-source.bin \ 7 test-fortify-source.bin \
7 test-sync-compare-and-swap.bin \ 8 test-sync-compare-and-swap.bin \
8 test-glibc.bin \ 9 test-glibc.bin \
@@ -82,6 +83,9 @@ endif
82$(OUTPUT)test-dwarf.bin: 83$(OUTPUT)test-dwarf.bin:
83 $(BUILD) $(DWARFLIBS) 84 $(BUILD) $(DWARFLIBS)
84 85
86$(OUTPUT)test-dwarf_getlocations.bin:
87 $(BUILD) $(DWARFLIBS)
88
85$(OUTPUT)test-libelf-mmap.bin: 89$(OUTPUT)test-libelf-mmap.bin:
86 $(BUILD) -lelf 90 $(BUILD) -lelf
87 91
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index e499a36c1e4a..a282e8cb84f3 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -41,6 +41,10 @@
41# include "test-dwarf.c" 41# include "test-dwarf.c"
42#undef main 42#undef main
43 43
44#define main main_test_dwarf_getlocations
45# include "test-dwarf_getlocations.c"
46#undef main
47
44#define main main_test_libelf_getphdrnum 48#define main main_test_libelf_getphdrnum
45# include "test-libelf-getphdrnum.c" 49# include "test-libelf-getphdrnum.c"
46#undef main 50#undef main
@@ -143,6 +147,7 @@ int main(int argc, char *argv[])
143 main_test_libelf_mmap(); 147 main_test_libelf_mmap();
144 main_test_glibc(); 148 main_test_glibc();
145 main_test_dwarf(); 149 main_test_dwarf();
150 main_test_dwarf_getlocations();
146 main_test_libelf_getphdrnum(); 151 main_test_libelf_getphdrnum();
147 main_test_libunwind(); 152 main_test_libunwind();
148 main_test_libaudit(); 153 main_test_libaudit();
diff --git a/tools/build/feature/test-dwarf_getlocations.c b/tools/build/feature/test-dwarf_getlocations.c
new file mode 100644
index 000000000000..70162699dd43
--- /dev/null
+++ b/tools/build/feature/test-dwarf_getlocations.c
@@ -0,0 +1,12 @@
1#include <stdlib.h>
2#include <elfutils/libdw.h>
3
4int main(void)
5{
6 Dwarf_Addr base, start, end;
7 Dwarf_Attribute attr;
8 Dwarf_Op *op;
9 size_t nops;
10 ptrdiff_t offset = 0;
11 return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
12}
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 0144b3d1bb77..88cccea3ca99 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1164,11 +1164,11 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1164 current_op = current_exp; 1164 current_op = current_exp;
1165 1165
1166 ret = collapse_tree(current_op, parg, error_str); 1166 ret = collapse_tree(current_op, parg, error_str);
1167 /* collapse_tree() may free current_op, and updates parg accordingly */
1168 current_op = NULL;
1167 if (ret < 0) 1169 if (ret < 0)
1168 goto fail; 1170 goto fail;
1169 1171
1170 *parg = current_op;
1171
1172 free(token); 1172 free(token);
1173 return 0; 1173 return 0;
1174 1174
diff --git a/tools/net/bpf_jit_disasm.c b/tools/net/bpf_jit_disasm.c
index 5b3241340945..544b05a53b70 100644
--- a/tools/net/bpf_jit_disasm.c
+++ b/tools/net/bpf_jit_disasm.c
@@ -98,6 +98,9 @@ static char *get_klog_buff(unsigned int *klen)
98 char *buff; 98 char *buff;
99 99
100 len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0); 100 len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
101 if (len < 0)
102 return NULL;
103
101 buff = malloc(len); 104 buff = malloc(len);
102 if (!buff) 105 if (!buff)
103 return NULL; 106 return NULL;
diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c
index 9223c164e545..1f86ee8fb831 100644
--- a/tools/perf/arch/x86/util/dwarf-regs.c
+++ b/tools/perf/arch/x86/util/dwarf-regs.c
@@ -63,6 +63,8 @@ struct pt_regs_offset {
63# define REG_OFFSET_NAME_32(n, r) {.name = n, .offset = offsetof(struct pt_regs, r)} 63# define REG_OFFSET_NAME_32(n, r) {.name = n, .offset = offsetof(struct pt_regs, r)}
64#endif 64#endif
65 65
66/* TODO: switching by dwarf address size */
67#ifndef __x86_64__
66static const struct pt_regs_offset x86_32_regoffset_table[] = { 68static const struct pt_regs_offset x86_32_regoffset_table[] = {
67 REG_OFFSET_NAME_32("%ax", eax), 69 REG_OFFSET_NAME_32("%ax", eax),
68 REG_OFFSET_NAME_32("%cx", ecx), 70 REG_OFFSET_NAME_32("%cx", ecx),
@@ -75,6 +77,8 @@ static const struct pt_regs_offset x86_32_regoffset_table[] = {
75 REG_OFFSET_END, 77 REG_OFFSET_END,
76}; 78};
77 79
80#define regoffset_table x86_32_regoffset_table
81#else
78static const struct pt_regs_offset x86_64_regoffset_table[] = { 82static const struct pt_regs_offset x86_64_regoffset_table[] = {
79 REG_OFFSET_NAME_64("%ax", rax), 83 REG_OFFSET_NAME_64("%ax", rax),
80 REG_OFFSET_NAME_64("%dx", rdx), 84 REG_OFFSET_NAME_64("%dx", rdx),
@@ -95,11 +99,7 @@ static const struct pt_regs_offset x86_64_regoffset_table[] = {
95 REG_OFFSET_END, 99 REG_OFFSET_END,
96}; 100};
97 101
98/* TODO: switching by dwarf address size */
99#ifdef __x86_64__
100#define regoffset_table x86_64_regoffset_table 102#define regoffset_table x86_64_regoffset_table
101#else
102#define regoffset_table x86_32_regoffset_table
103#endif 103#endif
104 104
105/* Minus 1 for the ending REG_OFFSET_END */ 105/* Minus 1 for the ending REG_OFFSET_END */
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3770c3dffe5e..52826696c852 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1415,21 +1415,19 @@ static int is_directory(const char *base_path, const struct dirent *dent)
1415 return S_ISDIR(st.st_mode); 1415 return S_ISDIR(st.st_mode);
1416} 1416}
1417 1417
1418#define for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next)\ 1418#define for_each_lang(scripts_path, scripts_dir, lang_dirent) \
1419 while (!readdir_r(scripts_dir, &lang_dirent, &lang_next) && \ 1419 while ((lang_dirent = readdir(scripts_dir)) != NULL) \
1420 lang_next) \ 1420 if ((lang_dirent->d_type == DT_DIR || \
1421 if ((lang_dirent.d_type == DT_DIR || \ 1421 (lang_dirent->d_type == DT_UNKNOWN && \
1422 (lang_dirent.d_type == DT_UNKNOWN && \ 1422 is_directory(scripts_path, lang_dirent))) && \
1423 is_directory(scripts_path, &lang_dirent))) && \ 1423 (strcmp(lang_dirent->d_name, ".")) && \
1424 (strcmp(lang_dirent.d_name, ".")) && \ 1424 (strcmp(lang_dirent->d_name, "..")))
1425 (strcmp(lang_dirent.d_name, ".."))) 1425
1426 1426#define for_each_script(lang_path, lang_dir, script_dirent) \
1427#define for_each_script(lang_path, lang_dir, script_dirent, script_next)\ 1427 while ((script_dirent = readdir(lang_dir)) != NULL) \
1428 while (!readdir_r(lang_dir, &script_dirent, &script_next) && \ 1428 if (script_dirent->d_type != DT_DIR && \
1429 script_next) \ 1429 (script_dirent->d_type != DT_UNKNOWN || \
1430 if (script_dirent.d_type != DT_DIR && \ 1430 !is_directory(lang_path, script_dirent)))
1431 (script_dirent.d_type != DT_UNKNOWN || \
1432 !is_directory(lang_path, &script_dirent)))
1433 1431
1434 1432
1435#define RECORD_SUFFIX "-record" 1433#define RECORD_SUFFIX "-record"
@@ -1575,7 +1573,7 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1575 const char *s __maybe_unused, 1573 const char *s __maybe_unused,
1576 int unset __maybe_unused) 1574 int unset __maybe_unused)
1577{ 1575{
1578 struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1576 struct dirent *script_dirent, *lang_dirent;
1579 char scripts_path[MAXPATHLEN]; 1577 char scripts_path[MAXPATHLEN];
1580 DIR *scripts_dir, *lang_dir; 1578 DIR *scripts_dir, *lang_dir;
1581 char script_path[MAXPATHLEN]; 1579 char script_path[MAXPATHLEN];
@@ -1590,19 +1588,19 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1590 if (!scripts_dir) 1588 if (!scripts_dir)
1591 return -1; 1589 return -1;
1592 1590
1593 for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1591 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1594 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1592 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1595 lang_dirent.d_name); 1593 lang_dirent->d_name);
1596 lang_dir = opendir(lang_path); 1594 lang_dir = opendir(lang_path);
1597 if (!lang_dir) 1595 if (!lang_dir)
1598 continue; 1596 continue;
1599 1597
1600 for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1598 for_each_script(lang_path, lang_dir, script_dirent) {
1601 script_root = get_script_root(&script_dirent, REPORT_SUFFIX); 1599 script_root = get_script_root(script_dirent, REPORT_SUFFIX);
1602 if (script_root) { 1600 if (script_root) {
1603 desc = script_desc__findnew(script_root); 1601 desc = script_desc__findnew(script_root);
1604 snprintf(script_path, MAXPATHLEN, "%s/%s", 1602 snprintf(script_path, MAXPATHLEN, "%s/%s",
1605 lang_path, script_dirent.d_name); 1603 lang_path, script_dirent->d_name);
1606 read_script_info(desc, script_path); 1604 read_script_info(desc, script_path);
1607 free(script_root); 1605 free(script_root);
1608 } 1606 }
@@ -1690,7 +1688,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
1690 */ 1688 */
1691int find_scripts(char **scripts_array, char **scripts_path_array) 1689int find_scripts(char **scripts_array, char **scripts_path_array)
1692{ 1690{
1693 struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1691 struct dirent *script_dirent, *lang_dirent;
1694 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN]; 1692 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN];
1695 DIR *scripts_dir, *lang_dir; 1693 DIR *scripts_dir, *lang_dir;
1696 struct perf_session *session; 1694 struct perf_session *session;
@@ -1713,9 +1711,9 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1713 return -1; 1711 return -1;
1714 } 1712 }
1715 1713
1716 for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1714 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1717 snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, 1715 snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
1718 lang_dirent.d_name); 1716 lang_dirent->d_name);
1719#ifdef NO_LIBPERL 1717#ifdef NO_LIBPERL
1720 if (strstr(lang_path, "perl")) 1718 if (strstr(lang_path, "perl"))
1721 continue; 1719 continue;
@@ -1729,16 +1727,16 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1729 if (!lang_dir) 1727 if (!lang_dir)
1730 continue; 1728 continue;
1731 1729
1732 for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1730 for_each_script(lang_path, lang_dir, script_dirent) {
1733 /* Skip those real time scripts: xxxtop.p[yl] */ 1731 /* Skip those real time scripts: xxxtop.p[yl] */
1734 if (strstr(script_dirent.d_name, "top.")) 1732 if (strstr(script_dirent->d_name, "top."))
1735 continue; 1733 continue;
1736 sprintf(scripts_path_array[i], "%s/%s", lang_path, 1734 sprintf(scripts_path_array[i], "%s/%s", lang_path,
1737 script_dirent.d_name); 1735 script_dirent->d_name);
1738 temp = strchr(script_dirent.d_name, '.'); 1736 temp = strchr(script_dirent->d_name, '.');
1739 snprintf(scripts_array[i], 1737 snprintf(scripts_array[i],
1740 (temp - script_dirent.d_name) + 1, 1738 (temp - script_dirent->d_name) + 1,
1741 "%s", script_dirent.d_name); 1739 "%s", script_dirent->d_name);
1742 1740
1743 if (check_ev_match(lang_path, 1741 if (check_ev_match(lang_path,
1744 scripts_array[i], session)) 1742 scripts_array[i], session))
@@ -1756,7 +1754,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1756 1754
1757static char *get_script_path(const char *script_root, const char *suffix) 1755static char *get_script_path(const char *script_root, const char *suffix)
1758{ 1756{
1759 struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1757 struct dirent *script_dirent, *lang_dirent;
1760 char scripts_path[MAXPATHLEN]; 1758 char scripts_path[MAXPATHLEN];
1761 char script_path[MAXPATHLEN]; 1759 char script_path[MAXPATHLEN];
1762 DIR *scripts_dir, *lang_dir; 1760 DIR *scripts_dir, *lang_dir;
@@ -1769,21 +1767,21 @@ static char *get_script_path(const char *script_root, const char *suffix)
1769 if (!scripts_dir) 1767 if (!scripts_dir)
1770 return NULL; 1768 return NULL;
1771 1769
1772 for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1770 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1773 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1771 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1774 lang_dirent.d_name); 1772 lang_dirent->d_name);
1775 lang_dir = opendir(lang_path); 1773 lang_dir = opendir(lang_path);
1776 if (!lang_dir) 1774 if (!lang_dir)
1777 continue; 1775 continue;
1778 1776
1779 for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1777 for_each_script(lang_path, lang_dir, script_dirent) {
1780 __script_root = get_script_root(&script_dirent, suffix); 1778 __script_root = get_script_root(script_dirent, suffix);
1781 if (__script_root && !strcmp(script_root, __script_root)) { 1779 if (__script_root && !strcmp(script_root, __script_root)) {
1782 free(__script_root); 1780 free(__script_root);
1783 closedir(lang_dir); 1781 closedir(lang_dir);
1784 closedir(scripts_dir); 1782 closedir(scripts_dir);
1785 snprintf(script_path, MAXPATHLEN, "%s/%s", 1783 snprintf(script_path, MAXPATHLEN, "%s/%s",
1786 lang_path, script_dirent.d_name); 1784 lang_path, script_dirent->d_name);
1787 return strdup(script_path); 1785 return strdup(script_path);
1788 } 1786 }
1789 free(__script_root); 1787 free(__script_root);
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1f19f2f999c8..307e8a1a003c 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -528,6 +528,7 @@ static int __run_perf_stat(int argc, const char **argv)
528 perf_evlist__set_leader(evsel_list); 528 perf_evlist__set_leader(evsel_list);
529 529
530 evlist__for_each(evsel_list, counter) { 530 evlist__for_each(evsel_list, counter) {
531try_again:
531 if (create_perf_stat_counter(counter) < 0) { 532 if (create_perf_stat_counter(counter) < 0) {
532 /* 533 /*
533 * PPC returns ENXIO for HW counters until 2.6.37 534 * PPC returns ENXIO for HW counters until 2.6.37
@@ -544,7 +545,11 @@ static int __run_perf_stat(int argc, const char **argv)
544 if ((counter->leader != counter) || 545 if ((counter->leader != counter) ||
545 !(counter->leader->nr_members > 1)) 546 !(counter->leader->nr_members > 1))
546 continue; 547 continue;
547 } 548 } else if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
549 if (verbose)
550 ui__warning("%s\n", msg);
551 goto try_again;
552 }
548 553
549 perf_evsel__open_strerror(counter, &target, 554 perf_evsel__open_strerror(counter, &target,
550 errno, msg, sizeof(msg)); 555 errno, msg, sizeof(msg));
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f7d7f5a1cad5..6f8f6430f2bf 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -268,6 +268,12 @@ else
268 ifneq ($(feature-dwarf), 1) 268 ifneq ($(feature-dwarf), 1)
269 msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); 269 msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
270 NO_DWARF := 1 270 NO_DWARF := 1
271 else
272 ifneq ($(feature-dwarf_getlocations), 1)
273 msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
274 else
275 CFLAGS += -DHAVE_DWARF_GETLOCATIONS
276 endif # dwarf_getlocations
271 endif # Dwarf support 277 endif # Dwarf support
272 endif # libelf support 278 endif # libelf support
273endif # NO_LIBELF 279endif # NO_LIBELF
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 577e600c8eb1..aea189b41cc8 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -959,6 +959,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
959 return 0; 959 return 0;
960} 960}
961 961
962#ifdef HAVE_DWARF_GETLOCATIONS
962/** 963/**
963 * die_get_var_innermost_scope - Get innermost scope range of given variable DIE 964 * die_get_var_innermost_scope - Get innermost scope range of given variable DIE
964 * @sp_die: a subprogram DIE 965 * @sp_die: a subprogram DIE
@@ -1080,3 +1081,11 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
1080 1081
1081 return ret; 1082 return ret;
1082} 1083}
1084#else
1085int die_get_var_range(Dwarf_Die *sp_die __maybe_unused,
1086 Dwarf_Die *vr_die __maybe_unused,
1087 struct strbuf *buf __maybe_unused)
1088{
1089 return -ENOTSUP;
1090}
1091#endif
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index dad55d04ffdd..edcf4ed4e99c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -433,7 +433,7 @@ static int __event__synthesize_thread(union perf_event *comm_event,
433{ 433{
434 char filename[PATH_MAX]; 434 char filename[PATH_MAX];
435 DIR *tasks; 435 DIR *tasks;
436 struct dirent dirent, *next; 436 struct dirent *dirent;
437 pid_t tgid, ppid; 437 pid_t tgid, ppid;
438 int rc = 0; 438 int rc = 0;
439 439
@@ -462,11 +462,11 @@ static int __event__synthesize_thread(union perf_event *comm_event,
462 return 0; 462 return 0;
463 } 463 }
464 464
465 while (!readdir_r(tasks, &dirent, &next) && next) { 465 while ((dirent = readdir(tasks)) != NULL) {
466 char *end; 466 char *end;
467 pid_t _pid; 467 pid_t _pid;
468 468
469 _pid = strtol(dirent.d_name, &end, 10); 469 _pid = strtol(dirent->d_name, &end, 10);
470 if (*end) 470 if (*end)
471 continue; 471 continue;
472 472
@@ -575,7 +575,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
575{ 575{
576 DIR *proc; 576 DIR *proc;
577 char proc_path[PATH_MAX]; 577 char proc_path[PATH_MAX];
578 struct dirent dirent, *next; 578 struct dirent *dirent;
579 union perf_event *comm_event, *mmap_event, *fork_event; 579 union perf_event *comm_event, *mmap_event, *fork_event;
580 int err = -1; 580 int err = -1;
581 581
@@ -600,9 +600,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
600 if (proc == NULL) 600 if (proc == NULL)
601 goto out_free_fork; 601 goto out_free_fork;
602 602
603 while (!readdir_r(proc, &dirent, &next) && next) { 603 while ((dirent = readdir(proc)) != NULL) {
604 char *end; 604 char *end;
605 pid_t pid = strtol(dirent.d_name, &end, 10); 605 pid_t pid = strtol(dirent->d_name, &end, 10);
606 606
607 if (*end) /* only interested in proper numerical dirents */ 607 if (*end) /* only interested in proper numerical dirents */
608 continue; 608 continue;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 738ce226002b..645dc1828836 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2345,6 +2345,8 @@ out:
2345bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 2345bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
2346 char *msg, size_t msgsize) 2346 char *msg, size_t msgsize)
2347{ 2347{
2348 int paranoid;
2349
2348 if ((err == ENOENT || err == ENXIO || err == ENODEV) && 2350 if ((err == ENOENT || err == ENXIO || err == ENODEV) &&
2349 evsel->attr.type == PERF_TYPE_HARDWARE && 2351 evsel->attr.type == PERF_TYPE_HARDWARE &&
2350 evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) { 2352 evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) {
@@ -2364,6 +2366,22 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
2364 2366
2365 zfree(&evsel->name); 2367 zfree(&evsel->name);
2366 return true; 2368 return true;
2369 } else if (err == EACCES && !evsel->attr.exclude_kernel &&
2370 (paranoid = perf_event_paranoid()) > 1) {
2371 const char *name = perf_evsel__name(evsel);
2372 char *new_name;
2373
2374 if (asprintf(&new_name, "%s%su", name, strchr(name, ':') ? "" : ":") < 0)
2375 return false;
2376
2377 if (evsel->name)
2378 free(evsel->name);
2379 evsel->name = new_name;
2380 scnprintf(msg, msgsize,
2381"kernel.perf_event_paranoid=%d, trying to fall back to excluding kernel samples", paranoid);
2382 evsel->attr.exclude_kernel = 1;
2383
2384 return true;
2367 } 2385 }
2368 2386
2369 return false; 2387 return false;
@@ -2382,12 +2400,13 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
2382 "Consider tweaking /proc/sys/kernel/perf_event_paranoid,\n" 2400 "Consider tweaking /proc/sys/kernel/perf_event_paranoid,\n"
2383 "which controls use of the performance events system by\n" 2401 "which controls use of the performance events system by\n"
2384 "unprivileged users (without CAP_SYS_ADMIN).\n\n" 2402 "unprivileged users (without CAP_SYS_ADMIN).\n\n"
2385 "The default value is 1:\n\n" 2403 "The current value is %d:\n\n"
2386 " -1: Allow use of (almost) all events by all users\n" 2404 " -1: Allow use of (almost) all events by all users\n"
2387 ">= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK\n" 2405 ">= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK\n"
2388 ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n" 2406 ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n"
2389 ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN", 2407 ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN",
2390 target->system_wide ? "system-wide " : ""); 2408 target->system_wide ? "system-wide " : "",
2409 perf_event_paranoid());
2391 case ENOENT: 2410 case ENOENT:
2392 return scnprintf(msg, size, "The %s event is not supported.", 2411 return scnprintf(msg, size, "The %s event is not supported.",
2393 perf_evsel__name(evsel)); 2412 perf_evsel__name(evsel));
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4c19d5e79d8c..bcbc983d4b12 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -138,11 +138,11 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = {
138#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) 138#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
139#define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) 139#define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
140 140
141#define for_each_subsystem(sys_dir, sys_dirent, sys_next) \ 141#define for_each_subsystem(sys_dir, sys_dirent) \
142 while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \ 142 while ((sys_dirent = readdir(sys_dir)) != NULL) \
143 if (sys_dirent.d_type == DT_DIR && \ 143 if (sys_dirent->d_type == DT_DIR && \
144 (strcmp(sys_dirent.d_name, ".")) && \ 144 (strcmp(sys_dirent->d_name, ".")) && \
145 (strcmp(sys_dirent.d_name, ".."))) 145 (strcmp(sys_dirent->d_name, "..")))
146 146
147static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir) 147static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)
148{ 148{
@@ -159,12 +159,12 @@ static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)
159 return 0; 159 return 0;
160} 160}
161 161
162#define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \ 162#define for_each_event(sys_dirent, evt_dir, evt_dirent) \
163 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \ 163 while ((evt_dirent = readdir(evt_dir)) != NULL) \
164 if (evt_dirent.d_type == DT_DIR && \ 164 if (evt_dirent->d_type == DT_DIR && \
165 (strcmp(evt_dirent.d_name, ".")) && \ 165 (strcmp(evt_dirent->d_name, ".")) && \
166 (strcmp(evt_dirent.d_name, "..")) && \ 166 (strcmp(evt_dirent->d_name, "..")) && \
167 (!tp_event_has_id(&sys_dirent, &evt_dirent))) 167 (!tp_event_has_id(sys_dirent, evt_dirent)))
168 168
169#define MAX_EVENT_LENGTH 512 169#define MAX_EVENT_LENGTH 512
170 170
@@ -173,7 +173,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
173{ 173{
174 struct tracepoint_path *path = NULL; 174 struct tracepoint_path *path = NULL;
175 DIR *sys_dir, *evt_dir; 175 DIR *sys_dir, *evt_dir;
176 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 176 struct dirent *sys_dirent, *evt_dirent;
177 char id_buf[24]; 177 char id_buf[24];
178 int fd; 178 int fd;
179 u64 id; 179 u64 id;
@@ -184,18 +184,18 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
184 if (!sys_dir) 184 if (!sys_dir)
185 return NULL; 185 return NULL;
186 186
187 for_each_subsystem(sys_dir, sys_dirent, sys_next) { 187 for_each_subsystem(sys_dir, sys_dirent) {
188 188
189 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, 189 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
190 sys_dirent.d_name); 190 sys_dirent->d_name);
191 evt_dir = opendir(dir_path); 191 evt_dir = opendir(dir_path);
192 if (!evt_dir) 192 if (!evt_dir)
193 continue; 193 continue;
194 194
195 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { 195 for_each_event(sys_dirent, evt_dir, evt_dirent) {
196 196
197 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, 197 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
198 evt_dirent.d_name); 198 evt_dirent->d_name);
199 fd = open(evt_path, O_RDONLY); 199 fd = open(evt_path, O_RDONLY);
200 if (fd < 0) 200 if (fd < 0)
201 continue; 201 continue;
@@ -220,9 +220,9 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
220 free(path); 220 free(path);
221 return NULL; 221 return NULL;
222 } 222 }
223 strncpy(path->system, sys_dirent.d_name, 223 strncpy(path->system, sys_dirent->d_name,
224 MAX_EVENT_LENGTH); 224 MAX_EVENT_LENGTH);
225 strncpy(path->name, evt_dirent.d_name, 225 strncpy(path->name, evt_dirent->d_name,
226 MAX_EVENT_LENGTH); 226 MAX_EVENT_LENGTH);
227 return path; 227 return path;
228 } 228 }
@@ -1812,7 +1812,7 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
1812 bool name_only) 1812 bool name_only)
1813{ 1813{
1814 DIR *sys_dir, *evt_dir; 1814 DIR *sys_dir, *evt_dir;
1815 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 1815 struct dirent *sys_dirent, *evt_dirent;
1816 char evt_path[MAXPATHLEN]; 1816 char evt_path[MAXPATHLEN];
1817 char dir_path[MAXPATHLEN]; 1817 char dir_path[MAXPATHLEN];
1818 char **evt_list = NULL; 1818 char **evt_list = NULL;
@@ -1830,20 +1830,20 @@ restart:
1830 goto out_close_sys_dir; 1830 goto out_close_sys_dir;
1831 } 1831 }
1832 1832
1833 for_each_subsystem(sys_dir, sys_dirent, sys_next) { 1833 for_each_subsystem(sys_dir, sys_dirent) {
1834 if (subsys_glob != NULL && 1834 if (subsys_glob != NULL &&
1835 !strglobmatch(sys_dirent.d_name, subsys_glob)) 1835 !strglobmatch(sys_dirent->d_name, subsys_glob))
1836 continue; 1836 continue;
1837 1837
1838 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, 1838 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
1839 sys_dirent.d_name); 1839 sys_dirent->d_name);
1840 evt_dir = opendir(dir_path); 1840 evt_dir = opendir(dir_path);
1841 if (!evt_dir) 1841 if (!evt_dir)
1842 continue; 1842 continue;
1843 1843
1844 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { 1844 for_each_event(sys_dirent, evt_dir, evt_dirent) {
1845 if (event_glob != NULL && 1845 if (event_glob != NULL &&
1846 !strglobmatch(evt_dirent.d_name, event_glob)) 1846 !strglobmatch(evt_dirent->d_name, event_glob))
1847 continue; 1847 continue;
1848 1848
1849 if (!evt_num_known) { 1849 if (!evt_num_known) {
@@ -1852,7 +1852,7 @@ restart:
1852 } 1852 }
1853 1853
1854 snprintf(evt_path, MAXPATHLEN, "%s:%s", 1854 snprintf(evt_path, MAXPATHLEN, "%s:%s",
1855 sys_dirent.d_name, evt_dirent.d_name); 1855 sys_dirent->d_name, evt_dirent->d_name);
1856 1856
1857 evt_list[evt_i] = strdup(evt_path); 1857 evt_list[evt_i] = strdup(evt_path);
1858 if (evt_list[evt_i] == NULL) 1858 if (evt_list[evt_i] == NULL)
@@ -1905,7 +1905,7 @@ out_close_sys_dir:
1905int is_valid_tracepoint(const char *event_string) 1905int is_valid_tracepoint(const char *event_string)
1906{ 1906{
1907 DIR *sys_dir, *evt_dir; 1907 DIR *sys_dir, *evt_dir;
1908 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 1908 struct dirent *sys_dirent, *evt_dirent;
1909 char evt_path[MAXPATHLEN]; 1909 char evt_path[MAXPATHLEN];
1910 char dir_path[MAXPATHLEN]; 1910 char dir_path[MAXPATHLEN];
1911 1911
@@ -1913,17 +1913,17 @@ int is_valid_tracepoint(const char *event_string)
1913 if (!sys_dir) 1913 if (!sys_dir)
1914 return 0; 1914 return 0;
1915 1915
1916 for_each_subsystem(sys_dir, sys_dirent, sys_next) { 1916 for_each_subsystem(sys_dir, sys_dirent) {
1917 1917
1918 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, 1918 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path,
1919 sys_dirent.d_name); 1919 sys_dirent->d_name);
1920 evt_dir = opendir(dir_path); 1920 evt_dir = opendir(dir_path);
1921 if (!evt_dir) 1921 if (!evt_dir)
1922 continue; 1922 continue;
1923 1923
1924 for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { 1924 for_each_event(sys_dirent, evt_dir, evt_dirent) {
1925 snprintf(evt_path, MAXPATHLEN, "%s:%s", 1925 snprintf(evt_path, MAXPATHLEN, "%s:%s",
1926 sys_dirent.d_name, evt_dirent.d_name); 1926 sys_dirent->d_name, evt_dirent->d_name);
1927 if (!strcmp(evt_path, event_string)) { 1927 if (!strcmp(evt_path, event_string)) {
1928 closedir(evt_dir); 1928 closedir(evt_dir);
1929 closedir(sys_dir); 1929 closedir(sys_dir);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 47966a1618c7..f5ba111cd9fb 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2445,6 +2445,9 @@ static char *prefix_if_not_in(const char *pre, char *str)
2445 2445
2446static char *setup_overhead(char *keys) 2446static char *setup_overhead(char *keys)
2447{ 2447{
2448 if (sort__mode == SORT_MODE__DIFF)
2449 return keys;
2450
2448 keys = prefix_if_not_in("overhead", keys); 2451 keys = prefix_if_not_in("overhead", keys);
2449 2452
2450 if (symbol_conf.cumulate_callchain) 2453 if (symbol_conf.cumulate_callchain)
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index 08afc6909953..267112b4e3db 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -94,7 +94,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
94 DIR *proc; 94 DIR *proc;
95 int max_threads = 32, items, i; 95 int max_threads = 32, items, i;
96 char path[256]; 96 char path[256];
97 struct dirent dirent, *next, **namelist = NULL; 97 struct dirent *dirent, **namelist = NULL;
98 struct thread_map *threads = thread_map__alloc(max_threads); 98 struct thread_map *threads = thread_map__alloc(max_threads);
99 99
100 if (threads == NULL) 100 if (threads == NULL)
@@ -107,16 +107,16 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
107 threads->nr = 0; 107 threads->nr = 0;
108 atomic_set(&threads->refcnt, 1); 108 atomic_set(&threads->refcnt, 1);
109 109
110 while (!readdir_r(proc, &dirent, &next) && next) { 110 while ((dirent = readdir(proc)) != NULL) {
111 char *end; 111 char *end;
112 bool grow = false; 112 bool grow = false;
113 struct stat st; 113 struct stat st;
114 pid_t pid = strtol(dirent.d_name, &end, 10); 114 pid_t pid = strtol(dirent->d_name, &end, 10);
115 115
116 if (*end) /* only interested in proper numerical dirents */ 116 if (*end) /* only interested in proper numerical dirents */
117 continue; 117 continue;
118 118
119 snprintf(path, sizeof(path), "/proc/%s", dirent.d_name); 119 snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
120 120
121 if (stat(path, &st) != 0) 121 if (stat(path, &st) != 0)
122 continue; 122 continue;