platform/kernel/linux-starfive.git
3 years agoASoC: sun4i-i2s: Set sign extend sample
Marcus Cooper [Fri, 30 Oct 2020 14:46:38 +0000 (15:46 +0100)]
ASoC: sun4i-i2s: Set sign extend sample

On the newer SoCs such as the H3 and A64 this is set by default
to transfer a 0 after each sample in each slot. However the A10
and A20 SoCs that this driver was developed on had a default
setting where it padded the audio gain with zeros.

This isn't a problem while we have only support for 16bit audio
but with larger sample resolution rates in the pipeline then SEXT
bits should be cleared so that they also pad at the LSB. Without
this the audio gets distorted.

Set sign extend sample for all the sunxi generations even if they
are not affected. This will keep consistency and avoid relying on
default.

Signed-off-by: Marcus Cooper <codekipper@gmail.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Link: https://lore.kernel.org/r/20201030144648.397824-6-peron.clem@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun4i-i2s: Change get_sr() and get_wss() to be more explicit
Clément Péron [Fri, 30 Oct 2020 14:46:37 +0000 (15:46 +0100)]
ASoC: sun4i-i2s: Change get_sr() and get_wss() to be more explicit

We are actually using a complex formula to just return a bunch of
simple values. Also this formula is wrong for sun4i when calling
get_wss() the function return 4 instead of 3.

Replace this with a simpler switch case.

Also drop the i2s params which is unused and return a simple int as
returning an error code could be out of range for an s8 and there is
no optim to return a s8 here.

Fixes: 619c15f7fac9 ("ASoC: sun4i-i2s: Change SR and WSS computation")
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Link: https://lore.kernel.org/r/20201030144648.397824-5-peron.clem@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun4i-i2s: Add support for H6 I2S
Jernej Skrabec [Fri, 30 Oct 2020 14:46:36 +0000 (15:46 +0100)]
ASoC: sun4i-i2s: Add support for H6 I2S

H6 I2S is very similar to that in H3, except it supports up to 16
channels.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Marcus Cooper <codekipper@gmail.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Link: https://lore.kernel.org/r/20201030144648.397824-4-peron.clem@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun4i-i2s: Change set_chan_cfg() params
Clément Péron [Fri, 30 Oct 2020 14:46:35 +0000 (15:46 +0100)]
ASoC: sun4i-i2s: Change set_chan_cfg() params

As slots and slot_width can be set manually using set_tdm().
These values are then kept in sun4i_i2s struct.
So we need to check if these values are set or not.

This is not done actually and will trigger a bug.
For example, if we set to the simple soundcard in the device-tree
dai-tdm-slot-width = <32> and then start a stream using S16_LE,
currently we would calculate BCLK for 32-bit slots, but program
lrck_period for 16-bit slots, making the sample rate double what we
expected.

To fix this, we need to check if these values are set or not but as
this logic is already done by the caller. Avoid duplicating this
logic and just pass the required values as params to set_chan_cfg().

Suggested-by: Samuel Holland <samuel@sholland.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Link: https://lore.kernel.org/r/20201030144648.397824-3-peron.clem@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun4i-i2s: Fix lrck_period computation for I2S justified mode
Clément Péron [Fri, 30 Oct 2020 14:46:34 +0000 (15:46 +0100)]
ASoC: sun4i-i2s: Fix lrck_period computation for I2S justified mode

Left and Right justified mode are computed using the same formula
as DSP_A and DSP_B mode.
Which is wrong and the user manual explicitly says:

LRCK_PERDIOD:
PCM Mode: Number of BCLKs within (Left + Right) channel width.
I2S/Left-Justified/Right-Justified Mode: Number of BCLKs within each
individual channel width(Left or Right)

Fix this by using the same formula as the I2S mode.

Fixes: 7ae7834ec446 ("ASoC: sun4i-i2s: Add support for DSP formats")
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20201030144648.397824-2-peron.clem@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: tegra20-spdif: remove "default m"
Michał Mirosław [Wed, 28 Oct 2020 22:48:05 +0000 (23:48 +0100)]
ASoC: tegra20-spdif: remove "default m"

Make tegra20-spdif default to N as all other drivers do.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Fixes: 774fec338bfc ("ASoC: Tegra: Implement SPDIF CPU DAI")
Link: https://lore.kernel.org/r/8756eb5aac561173aa222c9cb64dd314ab1b1f9b.1603925200.git.mirq-linux@rere.qmqm.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: sm8250: update compatible with new bindings
Srinivas Kandagatla [Thu, 29 Oct 2020 10:15:50 +0000 (10:15 +0000)]
ASoC: qcom: sm8250: update compatible with new bindings

Update compatible string as board compatible and device compatible
should not be same!. Make the driver inline with the new bindings.

Fixes: aa2e2785545a ("ASoC: qcom: sm8250: add sound card qrb5165-rb5 support")
Reported-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201029101550.31695-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: dt-bindings: sm8250: update compatibles
Srinivas Kandagatla [Thu, 29 Oct 2020 10:15:49 +0000 (10:15 +0000)]
ASoC: qcom: dt-bindings: sm8250: update compatibles

Update compatible string as board compatible and device compatible
should not be same!. New compatible is now suffixed with -sndcard
to be inline with other Qualcomm Sound cards.

This also fixes the warnings/error reported by dt_binding_check.

Fixes: 765c37598494 ("ASoC: qcom: dt-bindings: Add SM8250 sound card bindings")
Reported-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201029101550.31695-1-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: fix unsigned int bitwidth compared to less than zero
Colin Ian King [Wed, 28 Oct 2020 11:51:12 +0000 (11:51 +0000)]
ASoC: qcom: fix unsigned int bitwidth compared to less than zero

The check for an error return from the call to snd_pcm_format_width
is never true as the unsigned int bitwidth can never be less than
zero. Fix this by making bitwidth an int.

Fixes: 7cb37b7bd0d3 ("ASoC: qcom: Add support for lpass hdmi driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201028115112.109017-1-colin.king@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: sm8250: Fix array out of bounds access
Srinivas Kandagatla [Wed, 28 Oct 2020 14:20:01 +0000 (14:20 +0000)]
ASoC: qcom: sm8250: Fix array out of bounds access

Static analysis Coverity had detected a potential array out-of-bounds
write issue due to the fact that MAX AFE port Id was set to 16 instead
of using AFE_PORT_MAX macro.

Fix this by properly using AFE_PORT_MAX macro.

Fixes: aa2e2785545a ("ASoC: qcom: sm8250: add sound card qrb5165-rb5 support")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201028142001.22431-1-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoMerge series "Add documentation and machine driver for SC7180 sound card" from Cheng...
Mark Brown [Tue, 27 Oct 2020 20:36:10 +0000 (20:36 +0000)]
Merge series "Add documentation and machine driver for SC7180 sound card" from Cheng-Yi Chiang <cychiang@chromium.org>:

Note:
- The machine driver patch is made by the collaboration of
  Cheng-Yi Chiang <cychiang@chromium.org>
  Rohit kumar <rohitkr@codeaurora.org>
  Ajit Pandey <ajitp@codeaurora.org>
  But Ajit has left codeaurora.

Changes from v1 to v2:
- Ducumentation: Addressed all suggestions from Doug.
- Machine driver:
  - Fix comment style for license.
  - Sort includes.
  - Remove sc7180_snd_hw_params.
  - Remove sc7180_dai_init and use aux device instead for headset jack registration.
  - Statically define format for Primary MI2S.
  - Atomic is not a concern because there is mutex in card to make sure
    startup and shutdown happen sequentially.
  - Fix missing return -EINVAL in startup.
  - Use static sound card.
  - Use devm_kzalloc to avoid kfree.

Changes from v2 to v3:
- Ducumentation: Addressed suggestions from Srini.
- Machine driver:
  - Reuse qcom_snd_parse_of to parse properties.
  - Remove playback-only and capture-only.
  - Misc fixes to address comments.

Changes from v3 to v4:
- Ducumentation: Addressed suggestions from Rob.
 - Remove definition of dai.
 - Use 'sound-dai: true' for sound-dai schema.
 - Add reg property to pass 'make dt_binding_check' check although reg is not used in the driver.
- Machine driver:
 - Add Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>

Changes from v4 to v5:
- Documentation: Addressed suggestions from Rob.
 - Add definition for "#address-cells" and "#size-cells".
 - Add additionalProperties: false
 - Add required properties.

Changes from v5 to v6:
- Documentation: Addressed suggestions from Rob.
 - Drop contains in compatible strings.
 - Only allow dai-link@[0-9]
 - Remove reg ref since it has a type definition already.

Changes from v6 to v7
- Documentation:
  - Add headset-jack and hdmi-jack to specify the codec
    responsible for jack detection.
- HDMI codec driver:
  - Use component set_jack ops instead of exporting hdmi_codec_set_jack_detect.
- Machine driver:
  - Removed aux device following Stephan's suggestion.
  - Use headset-jack and hdmi-jack to specify the codec
    responsible for jack detection.
  - Add support for HDMI(actually DP) playback.

Changes from v7 to v8
- Documentation:
  - Remove headset-jack and hdmi-jack.
- Machine driver:
  - Let machine driver decide whether there is a jack on the DAI.

Changes from v8 to v9
- hdmi-codec driver:
  - Fixed the naming.
- Machine driver:
  - Fixed unused fields.
  - Moved snd_soc_card_set_drvdata
  - Keep the naming of HDMI as dai name until v5 of lpass-hdmi patches.

Changes from v9 to v10
- Documentation:
  - Let compatible string be more specific for board configuration to allow
    for future changes.
- Machine driver:
  - Fixed unused include and macro.
  - Add temporary macro SC7180_LPASS_DP for future change in sc7180-lpass.h.
  - Let sound card be dynamically allocated.
  - Change compatible string accordingly.

Changes from v10 to v11
- Machine driver:
  - Use temporary macro LPASS_DP_RX for future change in sc7180-lpass.h.

Changes from v11 to v12
- Documentation:
 - Change the file and title name for new compatible string google,sc7180-trogdor.
 - Change the example of model name.
- Machine driver:
 - Use the definitaion of index LPASS_DP_RX in sc7180-lpass.h.
 - Fix for compatible string.
 - Replace a comma with semicolon.

Ajit Pandey (1):
  ASoC: qcom: sc7180: Add machine driver for sound card registration

Cheng-Yi Chiang (1):
  ASoC: google: dt-bindings: Add sc7180-trogdor machine bindings

 .../bindings/sound/google,sc7180-trogdor.yaml | 130 +++++++++
 sound/soc/qcom/Kconfig                        |  12 +
 sound/soc/qcom/Makefile                       |   2 +
 sound/soc/qcom/sc7180.c                       | 266 ++++++++++++++++++
 4 files changed, 410 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/google,sc7180-trogdor.yaml
 create mode 100644 sound/soc/qcom/sc7180.c

--
2.29.0.rc2.309.g374f81d7ae-goog

3 years agoASoC: qcom: qdsp6: make use of devm_of_platform_populate
Srinivas Kandagatla [Tue, 27 Oct 2020 11:15:26 +0000 (11:15 +0000)]
ASoC: qcom: qdsp6: make use of devm_of_platform_populate

make use of devm_of_platform_populate to remove some redundant code!

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201027111526.12326-1-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: sc7180: Add machine driver for sound card registration
Ajit Pandey [Tue, 27 Oct 2020 03:22:34 +0000 (11:22 +0800)]
ASoC: qcom: sc7180: Add machine driver for sound card registration

Add new driver to register sound card on sc7180 trogdor board and
do the required configuration for lpass cpu dai and external codecs
connected over MI2S interfaces.

Signed-off-by: Ajit Pandey <ajitp@codeaurora.org>
Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201027032234.1705835-3-cychiang@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: google: dt-bindings: Add sc7180-trogdor machine bindings
Cheng-Yi Chiang [Tue, 27 Oct 2020 03:22:33 +0000 (11:22 +0800)]
ASoC: google: dt-bindings: Add sc7180-trogdor machine bindings

Add devicetree bindings documentation file for sc7180 sound card.

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201027032234.1705835-2-cychiang@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoMerge series "ASoC: SOF: cleanups for 5.10" from Kai Vehmanen <kai.vehmanen@linux...
Mark Brown [Mon, 26 Oct 2020 18:37:17 +0000 (18:37 +0000)]
Merge series "ASoC: SOF: cleanups for 5.10" from Kai Vehmanen <kai.vehmanen@linux.intel.com>:

Series with multiple code cleanups, plus one fix to remove
unnecessary kernel warnings related to firmware loading.

Bard Liao (1):
  ASoC: SOF: loader: handle all SOF_IPC_EXT types

Pierre-Louis Bossart (3):
  ASoC: SOF: control: remove const in sizeof()
  ASoC: SOF: topology: remove const in sizeof()
  ASoC: SOF: sof-audio: remove goto used for force-nocodec support

 sound/soc/sof/control.c   | 20 ++++++++++----------
 sound/soc/sof/loader.c    |  5 +++++
 sound/soc/sof/sof-audio.c | 10 +++-------
 sound/soc/sof/topology.c  |  2 +-
 4 files changed, 19 insertions(+), 18 deletions(-)

--
2.27.0

3 years agoMerge series "DAI driver for new XCVR IP" from "Viorel Suman (OSS)" <viorel.suman...
Mark Brown [Mon, 26 Oct 2020 18:37:16 +0000 (18:37 +0000)]
Merge series "DAI driver for new XCVR IP" from "Viorel Suman (OSS)" <viorel.suman@oss.nxp.com>
Viorel Suman <viorel.suman@nxp.com>:

From: Viorel Suman <viorel.suman@nxp.com>

DAI driver for new XCVR IP found in i.MX8MP.

Viorel Suman (2):
  ASoC: fsl_xcvr: Add XCVR ASoC CPU DAI driver
  ASoC: dt-bindings: fsl_xcvr: Add document for XCVR

Changes since v1:
 - improved 6- and 12-ch layout comment
 - used regmap polling function, improved
   clocks handling in runtime_resume
 - added FW size check in FW load function,
   improved IRQ handler, removed dummy IRQ handlers
 - fixed yaml file

Changes since v2:
 - used devm_reset_control_get_exclusive instead of of_reset_control_get
 - moved reset_control_assert into runtime_suspend

Changes since v3:
 - removed "firmware-name" DTS property from both documentation and
   source code by porting it into SoC specific 'compatible' data structure.

 .../devicetree/bindings/sound/fsl,xcvr.yaml   |  104 ++
 sound/soc/fsl/Kconfig                         |   10 +
 sound/soc/fsl/Makefile                        |    2 +
 sound/soc/fsl/fsl_xcvr.c                      | 1359 +++++++++++++++++
 sound/soc/fsl/fsl_xcvr.h                      |  266 ++++
 5 files changed, 1741 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/fsl,xcvr.yaml
 create mode 100644 sound/soc/fsl/fsl_xcvr.c
 create mode 100644 sound/soc/fsl/fsl_xcvr.h

--
2.26.2

3 years agoMerge series "ASoC: merge soc_pcm_hw_param() rollback and soc_pcm_hw_free()" from...
Mark Brown [Mon, 26 Oct 2020 18:37:15 +0000 (18:37 +0000)]
Merge series "ASoC: merge soc_pcm_hw_param() rollback and soc_pcm_hw_free()" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark

soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().

static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;

 ^ component_err:
 | ...
 | interface_err:
(A) ...
 | codec_err:
 | ...
 v return ret;
}

This kind of duplicated code can be a hotbed of bugs,
thus, this patch-set share soc_pcm_hw_free() and rollback.

Kuninori Morimoto (6):
  ASoC: soc.h: remove for_each_rtd_dais_rollback()
  ASoC: soc-pcm: move soc_pcm_hw_free() next to soc_pcm_hw_params()
  ASoC: soc-link: add mark for snd_soc_link_hw_params/free()
  ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
  ASoC: soc-dai: add mark for snd_soc_dai_hw_params/free()
  ASoC: soc-pcm: add soc_pcm_hw_clean() and call it from soc_pcm_hw_params/free()

 include/sound/soc-component.h |   6 +-
 include/sound/soc-dai.h       |   4 +-
 include/sound/soc-link.h      |   3 +-
 include/sound/soc.h           |   7 +-
 sound/soc/soc-component.c     |  19 ++---
 sound/soc/soc-dai.c           |  13 +++-
 sound/soc/soc-dapm.c          |   4 +-
 sound/soc/soc-link.c          |  12 +++-
 sound/soc/soc-pcm.c           | 131 ++++++++++++++--------------------
 9 files changed, 97 insertions(+), 102 deletions(-)

--
2.25.1

3 years agoMerge series "ASoC: qcom: add support for QRB5165 RB5 machine" from Srinivas Kandagat...
Mark Brown [Mon, 26 Oct 2020 18:37:13 +0000 (18:37 +0000)]
Merge series "ASoC: qcom: add support for QRB5165 RB5 machine" from Srinivas Kandagatla <srinivas.kandagatla@linaro.org>:

This patchset adds support to Qualcomm Robotics RB5 Development Kit based on
QRB5165 Robotics SoC. This board has 2 WSA881X smart speakers with onboard
DMIC connected to internal LPASS codec via WSA and VA macros respectively.

Srinivas Kandagatla (2):
  ASoC: qcom: dt-bindings: Add SM8250 sound card bindings
  ASoC: qcom: sm8250: add sound card qrb5165-rb5 support

 .../bindings/sound/qcom,sm8250.yaml           | 161 +++++++++++++
 sound/soc/qcom/Kconfig                        |  11 +
 sound/soc/qcom/Makefile                       |   2 +
 sound/soc/qcom/sm8250.c                       | 228 ++++++++++++++++++
 4 files changed, 402 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,sm8250.yaml
 create mode 100644 sound/soc/qcom/sm8250.c

--
2.21.0

3 years agoMerge series "use semicolons rather than commas to separate statements" from Julia...
Mark Brown [Mon, 26 Oct 2020 18:37:12 +0000 (18:37 +0000)]
Merge series "use semicolons rather than commas to separate statements" from Julia Lawall <Julia.Lawall@inria.fr>:

These patches replace commas by semicolons.  This was done using the
Coccinelle semantic patch (http://coccinelle.lip6.fr/) shown below.

This semantic patch ensures that commas inside for loop headers will not be
transformed.  It also doesn't touch macro definitions.

Coccinelle ensures that braces are added as needed when a single-statement
branch turns into a multi-statement one.

This semantic patch has a few false positives, for variable delcarations
such as:

LIST_HEAD(x), *y;

The semantic patch could be improved to avoid these, but for the moment
they have been removed manually (2 occurrences).

// <smpl>
@initialize:ocaml@
@@

let infunction p =
  (* avoid macros *)
  (List.hd p).current_element <> "something_else"

let combined p1 p2 =
  (List.hd p1).line_end = (List.hd p2).line ||
  (((List.hd p1).line_end < (List.hd p2).line) &&
   ((List.hd p1).col < (List.hd p2).col))

@bad@
statement S;
declaration d;
position p;
@@

S@p
d

// special cases where newlines are needed (hope for no more than 5)
@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@r@
expression e1,e2;
statement S;
position p != bad.p;
@@

e1 ,@S@p e2;

@@
expression e1,e2;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && not(combined p1 p2) };
statement S;
position r.p;
@@

e1@p1
-,@S@p
+;
e2@p2
... when any
// </smpl>

---

 sound/firewire/fireworks/fireworks_pcm.c |    2 +-
 sound/pci/hda/patch_ca0132.c             |    2 +-
 sound/pci/hda/patch_hdmi.c               |    2 +-
 sound/soc/codecs/madera.c                |    4 ++--
 sound/soc/codecs/wm8350.c                |    3 ++-
 sound/soc/intel/boards/bytcr_rt5651.c    |    2 +-
 sound/soc/samsung/snow.c                 |    2 +-
 sound/soc/soc-dapm.c                     |    2 +-
 sound/soc/sof/intel/hda-dsp.c            |    2 +-
 9 files changed, 11 insertions(+), 10 deletions(-)

3 years agoMerge series "ASoC: sun8i-codec: support for AIF2 and AIF3" from Samuel Holland ...
Mark Brown [Mon, 26 Oct 2020 18:37:11 +0000 (18:37 +0000)]
Merge series "ASoC: sun8i-codec: support for AIF2 and AIF3" from Samuel Holland <samuel@sholland.org>:

This series adds support the other two AIFs present in the sun8i codec,
which can be used for codec2codec DAI links.

This series first fills out the DAI driver, removing assumptions that
were made for AIF1 (16 bits, 2 channels, certain clock inversions). Some
new logic is required to handle 3 DAIs and the ADC/DAC sharing the same
clock. Finally, it adds the new DAIs, and hooks them up with DAPM
widgets and routes per the hardware topology.

To minimize the number of patches in this series, related device tree
patches (increasing #sound-dai-cells, adding new DAI links) will be sent
separately.

Changes from v1:
  - Patches 1-8 from v1 (DAPM changes) were merged
  - Prefixed AIF constants with "SUN8I_CODEC_" [1, 7, 10, 16, 17]
  - Renamed variables in sun8i_codec_set_fmt for clarity [3]
  - Update sysclk->sysclk_rate if later calls to hw_params change the
    sample rate (thanks Chen-Yu for reminding me of this) [11]
  - Select COMMON_CLK for clk_set_rate_exclusive [12]
  - Add comments and hopefully clarify the clock protection logic [12]
  - Make the error message more concise and put it on one line [12]
  - Drop the "reg" variable holding SUN8I_AIF_CLK_CTRL(dai->id) [15]
  - Rename "div_reg" to "clk_reg" and adjust comments for clarity [17]
  - Improve the AIF2/AIF3 rate mismatch error message [17]
  - Minor grammar/wording fixes in commit messages [2, 4, 7, 8, 16, 17]
  - Added Maxime's Acked-by: [1-2, 4-9, 11, 13-14, 16]

Samuel Holland (17):
  ASoC: sun8i-codec: Prepare to extend the DAI driver
  ASoC: sun8i-codec: Program DAI format before clock inversion
  ASoC: sun8i-codec: Enable all supported clock inversions
  ASoC: sun8i-codec: Use the provided word size
  ASoC: sun8i-codec: Round up the LRCK divisor
  ASoC: sun8i-codec: Correct the BCLK divisor calculation
  ASoC: sun8i-codec: Support the TDM slot binding
  ASoC: sun8i-codec: Enforce symmetric DAI parameters
  ASoC: sun8i-codec: Enable all supported sample rates
  ASoC: sun8i-codec: Automatically set the system sample rate
  ASoC: sun8i-codec: Constrain to compatible sample rates
  ASoC: sun8i-codec: Protect the clock rate while streams are open
  ASoC: sun8i-codec: Require an exact BCLK divisor match
  ASoC: sun8i-codec: Enable all supported PCM formats
  ASoC: sun8i-codec: Generalize AIF clock control
  ASoC: sun8i-codec: Add the AIF2 DAI, widgets, and routes
  ASoC: sun8i-codec: Add the AIF3 DAI, widgets, and routes

 sound/soc/sunxi/Kconfig       |   1 +
 sound/soc/sunxi/sun8i-codec.c | 834 ++++++++++++++++++++++++++++------
 2 files changed, 699 insertions(+), 136 deletions(-)

--
2.26.2

3 years agoMerge series "dt-bindings: stm32: convert audio dfsdm to json-schema" from Olivier...
Mark Brown [Mon, 26 Oct 2020 18:37:10 +0000 (18:37 +0000)]
Merge series "dt-bindings: stm32: convert audio dfsdm to json-schema" from Olivier Moysan <olivier.moysan@st.com>:

Some audio properties documented in st,stm32-adfsdm.txt are already documented
in Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml bindings.
Move remaining properties from st,stm32-adfsdm.txt to st,stm32-dfsdm-adc.yaml,
and remove st,stm32-adfsdm.txt.

Changes in v2:
- Complete st,stm32-dfsdm-adc.yaml rather than converting st,stm32-adfsdm.txt

Olivier Moysan (2):
  dt-bindings: stm32: dfsdm: update audio properties
  dt-bindings: stm32: dfsdm: remove stm32-adfsdm.txt binding

 .../bindings/iio/adc/st,stm32-dfsdm-adc.yaml  |  7 ++-
 .../bindings/sound/st,stm32-adfsdm.txt        | 63 -------------------
 2 files changed, 5 insertions(+), 65 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/st,stm32-adfsdm.txt

--
2.17.1

3 years agoASoC: fsl_spdif: Add support for higher sample rates
Shengjiu Wang [Tue, 13 Oct 2020 02:49:20 +0000 (10:49 +0800)]
ASoC: fsl_spdif: Add support for higher sample rates

Add 88200Hz and 176400Hz sample rates support for TX.
Add 88200Hz, 176400Hz, 192000Hz sample rates support for RX.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Link: https://lore.kernel.org/r/1602557360-18795-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: fsl_spdif: Add support for i.MX8QM platform
Shengjiu Wang [Thu, 15 Oct 2020 05:28:48 +0000 (13:28 +0800)]
ASoC: fsl_spdif: Add support for i.MX8QM platform

On i.MX8QM, there are separate interrupts for TX and RX.

As the EDMA can't be configured to swing back to first FIFO
after writing the second FIFO, so we need to force the burst
size to be 2 on i.MX8QM. And EDMA don't support to shift
the data from S24_LE to S16_LE, so the supported TX format
is also different on i.MX8QM.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/1602739728-4433-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: dt-bindings: fsl_spdif: Add new compatible string for i.MX8QM
Shengjiu Wang [Thu, 15 Oct 2020 05:28:47 +0000 (13:28 +0800)]
ASoC: dt-bindings: fsl_spdif: Add new compatible string for i.MX8QM

Add new compatible string "fsl,imx8qm-spdif" for supporting spdif
module on i.MX8QM.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/1602739728-4433-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: amd: support other audio modes for raven
Vijendar Mukunda [Fri, 23 Oct 2020 18:07:17 +0000 (23:37 +0530)]
ASoC: amd: support other audio modes for raven

ACP supports different audio configurations other than I2S.
This patch will fix acp driver probe failure for other audio
configurations.

Tested-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Prike Liang <Prike.Liang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/1603476441-3506-1-git-send-email-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: wm5102: Use get_unaligned_be16() for dac_comp_coeff
Richard Fitzgerald [Thu, 15 Oct 2020 10:27:03 +0000 (11:27 +0100)]
ASoC: wm5102: Use get_unaligned_be16() for dac_comp_coeff

Replace the two-step copy-and-convert in
wm5102_out_comp_coeff_put() with get_unaligned_be16(). Apart from
looking nicer, it avoids this sparse warning:

wm5102.c:687:35: sparse: sparse: cast to restricted __be16

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20201015102703.24622-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: dt-bindings: stm32: convert sai to json-schema
Olivier Moysan [Fri, 9 Oct 2020 14:10:51 +0000 (16:10 +0200)]
ASoC: dt-bindings: stm32: convert sai to json-schema

Convert the STM32 SAI bindings to DT schema format using json-schema.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201009141051.27365-1-olivier.moysan@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: adau1977: remove platform data and move micbias bindings include
Alexandru Ardelean [Mon, 19 Oct 2020 10:53:13 +0000 (13:53 +0300)]
ASoC: adau1977: remove platform data and move micbias bindings include

The change removes the platform_data include/definition. It only contains
some values for the MICBIAS.
These are moved into 'dt-bindings/sound/adi,adau1977.h' so that they can be
used inside device-trees. When moving then, they need to be converted to
pre-compiler defines, so that the DT compiler can understand them.

The driver then, also needs to include the new
'dt-bindings/sound/adi,adau1977.h' file.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20201019105313.24862-1-alexandru.ardelean@analog.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: pcm5102a: Make codec selectable
Codrin Ciubotariu [Mon, 12 Oct 2020 14:19:11 +0000 (17:19 +0300)]
ASoC: pcm5102a: Make codec selectable

The TI PCM5102A codec driver can be used with the generic sound card
drivers, so it should be selectable. For example, with the addition
of #sound-dai-cells = <0> property in DT, it can be used with simple/graph
card drivers.

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Link: https://lore.kernel.org/r/20201012141911.3150996-1-codrin.ciubotariu@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: jz4740-i2s: Remove manual DMA peripheral ID assignment
Lars-Peter Clausen [Fri, 23 Oct 2020 09:23:46 +0000 (11:23 +0200)]
ASoC: jz4740-i2s: Remove manual DMA peripheral ID assignment

All platforms that use the jz4740-i2s driver have been switched to
devicetree for a while now and the assignment of the DMA peripheral ID
is done in the devicetree.

It is no longer necessary to manually assign the peripheral ID in the
driver, so remove that. The DMA driver does not even look at the value
assigned in the driver anymore and always uses the value provided by the
devicetree.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20201023092346.5777-1-lars@metafoo.de
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: sm8250: add sound card qrb5165-rb5 support
Srinivas Kandagatla [Mon, 26 Oct 2020 17:09:47 +0000 (17:09 +0000)]
ASoC: qcom: sm8250: add sound card qrb5165-rb5 support

Add support to Qualcomm Robotics RB5 Development Kit based on
QRB5165 Robotics SoC. This board has 2 WSA881X smart speakers
with onboard DMIC connected to internal LPASS codec via WSA
and VA macros respectively.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201026170947.10567-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: dt-bindings: Add SM8250 sound card bindings
Srinivas Kandagatla [Mon, 26 Oct 2020 17:09:46 +0000 (17:09 +0000)]
ASoC: qcom: dt-bindings: Add SM8250 sound card bindings

This patch adds bindings required for SM8250 based soundcards
for example Qualcomm Robotics RB5 Development Kit which makes
use of ADSP and Internal LPASS codec.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20201026170947.10567-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: dt-bindings: stm32: dfsdm: remove stm32-adfsdm.txt binding
Olivier Moysan [Tue, 20 Oct 2020 15:57:09 +0000 (17:57 +0200)]
ASoC: dt-bindings: stm32: dfsdm: remove stm32-adfsdm.txt binding

Device tree audio configuration for STM32 DFSDM is already
covered in the following binding:
Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml
Remove stm32-adfsdm.txt obsolete binding.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201020155709.2621-3-olivier.moysan@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agodt-bindings: stm32: dfsdm: update audio properties
Olivier Moysan [Tue, 20 Oct 2020 15:57:08 +0000 (17:57 +0200)]
dt-bindings: stm32: dfsdm: update audio properties

- Add missing compatible property in audio node.
- Remove obsolete "st,stm32-dfsdm-pdm" compatible.
- Remove useless comment in adc io-channels description.

Signed-off-by: Olivier Moysan <olivier.moysan@st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201020155709.2621-2-olivier.moysan@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: soc-pcm: add soc_pcm_hw_clean() and call it from soc_pcm_hw_params/free()
Kuninori Morimoto [Tue, 29 Sep 2020 04:32:01 +0000 (13:32 +0900)]
ASoC: soc-pcm: add soc_pcm_hw_clean() and call it from soc_pcm_hw_params/free()

soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().

static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;

 ^ component_err:
 | ...
 | interface_err:
(A) ...
 | codec_err:
 | ...
 v return ret;
}

The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback          is for succeeded part only.

This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.

Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()

Now, 1) to 3) are handled.
This patch adds new soc_pcm_hw_clean() and call it from
soc_pcm_hw_params() as rollback, and from soc_pcm_hw_free() as
normal close handler.

Other difference is that soc_pcm_hw_free() handles digital mute
if it was last user. Rollback also handles it by this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7rhgqab.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: soc-dai: add mark for snd_soc_dai_hw_params/free()
Kuninori Morimoto [Tue, 29 Sep 2020 04:31:53 +0000 (13:31 +0900)]
ASoC: soc-dai: add mark for snd_soc_dai_hw_params/free()

soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().

static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;

 ^ component_err:
 | ...
 | interface_err:
(A) ...
 | codec_err:
 | ...
 v return ret;
}

The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback          is for succeeded part only.

This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.

Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
2) snd_soc_pcm_component_hw_params/free()
=> 3) snd_soc_dai_hw_params/free()

This patch is for 3) snd_soc_dai_hw_params/free().

The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.

To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.

One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbxgqai.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
Kuninori Morimoto [Tue, 29 Sep 2020 04:31:41 +0000 (13:31 +0900)]
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()

soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().

static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;

 ^ component_err:
 | ...
 | interface_err:
(A) ...
 | codec_err:
 | ...
 v return ret;
}

The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback          is for succeeded part only.

This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.

Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()

This patch is for 2) snd_soc_pcm_component_hw_params/free().

The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.

To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.

One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: soc-link: add mark for snd_soc_link_hw_params/free()
Kuninori Morimoto [Tue, 29 Sep 2020 04:31:25 +0000 (13:31 +0900)]
ASoC: soc-link: add mark for snd_soc_link_hw_params/free()

soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().

static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;

 ^ component_err:
 | ...
 | interface_err:
(A) ...
 | codec_err:
 | ...
 v return ret;
}

The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback          is for succeeded part only.

This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.

Now, soc_pcm_hw_params/free() are handling
=> 1) snd_soc_link_hw_params/free()
2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()

This patch is for 1) snd_soc_link_hw_params/free().

The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.

To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.

One note here ist that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfgtgqba.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: soc-pcm: move soc_pcm_hw_free() next to soc_pcm_hw_params()
Kuninori Morimoto [Tue, 29 Sep 2020 04:31:19 +0000 (13:31 +0900)]
ASoC: soc-pcm: move soc_pcm_hw_free() next to soc_pcm_hw_params()

This patch moves soc_pcm_hw_free() next to soc_pcm_hw_params().
This is prepare for soc_pcm_hw_params() cleanup

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mu19gqbh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: soc.h: remove for_each_rtd_dais_rollback()
Kuninori Morimoto [Tue, 29 Sep 2020 04:31:11 +0000 (13:31 +0900)]
ASoC: soc.h: remove for_each_rtd_dais_rollback()

commit 140a4532cdb8 ("ASoC: soc-pcm: add soc_pcm_clean() and call it
from soc_pcm_open/close()") uses soc_pcm_clean() and then
for_each_rtd_dais_rollback() is no longer used.
This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o8lpgqbp.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: SOF: sof-audio: remove goto used for force-nocodec support
Pierre-Louis Bossart [Wed, 30 Sep 2020 15:20:25 +0000 (18:20 +0300)]
ASoC: SOF: sof-audio: remove goto used for force-nocodec support

Address smatch warnings:
sound/soc/sof/sof-audio.c:375 sof_machine_check() warn: inconsistent indenting
sound/soc/sof/sof-audio.c:380 sof_machine_check() warn: ignoring unreachable code.

No functionality change.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Tested-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20200930152026.3902186-4-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: SOF: topology: remove const in sizeof()
Pierre-Louis Bossart [Wed, 30 Sep 2020 15:20:24 +0000 (18:20 +0300)]
ASoC: SOF: topology: remove const in sizeof()

We should only use the type, the const attribute makes no sense in
sizeof().

Reported-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Tested-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20200930152026.3902186-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: SOF: control: remove const in sizeof()
Pierre-Louis Bossart [Wed, 30 Sep 2020 15:20:23 +0000 (18:20 +0300)]
ASoC: SOF: control: remove const in sizeof()

We should only use the type, the const attribute makes no sense in
sizeof().

Reported-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Tested-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20200930152026.3902186-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: dt-bindings: fsl_xcvr: Add document for XCVR
Viorel Suman [Tue, 13 Oct 2020 12:17:33 +0000 (15:17 +0300)]
ASoC: dt-bindings: fsl_xcvr: Add document for XCVR

XCVR (Audio Transceiver) is a new IP module found on i.MX8MP.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20201013121733.83684-3-viorel.suman@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: fsl_xcvr: Add XCVR ASoC CPU DAI driver
Viorel Suman [Tue, 13 Oct 2020 12:17:32 +0000 (15:17 +0300)]
ASoC: fsl_xcvr: Add XCVR ASoC CPU DAI driver

XCVR (Audio Transceiver) is a on-chip functional module found
on i.MX8MP. It support HDMI2.1 eARC, HDMI1.4 ARC and SPDIF.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/20201013121733.83684-2-viorel.suman@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: dapm: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 11 Oct 2020 09:19:39 +0000 (11:19 +0200)]
ASoC: dapm: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Link: https://lore.kernel.org/r/1602407979-29038-9-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: madera: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 11 Oct 2020 09:19:38 +0000 (11:19 +0200)]
ASoC: madera: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/1602407979-29038-8-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: samsung: snow: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 11 Oct 2020 09:19:37 +0000 (11:19 +0200)]
ASoC: samsung: snow: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/1602407979-29038-7-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: SOF: Intel: hda: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 11 Oct 2020 09:19:36 +0000 (11:19 +0200)]
ASoC: SOF: Intel: hda: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Link: https://lore.kernel.org/r/1602407979-29038-6-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: Intel: bytcr_rt5651: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 11 Oct 2020 09:19:34 +0000 (11:19 +0200)]
ASoC: Intel: bytcr_rt5651: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Acked-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/1602407979-29038-4-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: wm8350: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 11 Oct 2020 09:19:32 +0000 (11:19 +0200)]
ASoC: wm8350: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/1602407979-29038-2-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Add the AIF3 DAI, widgets, and routes
Samuel Holland [Wed, 14 Oct 2020 06:19:41 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Add the AIF3 DAI, widgets, and routes

AIF3 has some differences from AIF1 and AIF2:
 - It supports one channel only
 - It supports master mode only
 - It is not directly connected to any of the mixers; instead all audio
   goes through a mux with AIF2.
 - It does not have its own clock dividers; instead it reuses AIF2 BCLK
   and LRCK. This means that when both AIF2 and AIF3 are active, they
   must use the same sample rate and total frame width. Since AIF2 and
   AIF3 are only used for codec2codec DAI links, constraints are not
   applicable here; the only thing we can do when the rates don't match
   is report an error.

Make the necessary adjustments to support this AIF.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-18-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Add the AIF2 DAI, widgets, and routes
Samuel Holland [Wed, 14 Oct 2020 06:19:40 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Add the AIF2 DAI, widgets, and routes

This adds support for AIF2, which is stereo and has fullly independent
clocking capability, making it very similar to AIF1.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-17-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Generalize AIF clock control
Samuel Holland [Wed, 14 Oct 2020 06:19:39 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Generalize AIF clock control

The AIF clock control register has the same layout for all three AIFs.
The only difference between them is that AIF3 is missing some fields. We
can reuse the same register field definitions for all three registers,
and use the DAI ID to select the correct register address.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20201014061941.4306-16-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Enable all supported PCM formats
Samuel Holland [Wed, 14 Oct 2020 06:19:38 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Enable all supported PCM formats

Now that the DAI clock setup is correct for all hardware-supported PCM
formats, we can enable them in the driver. With the appropriate support
in the CPU DAI driver, this allows userspace to access the additional
formats.

Since this codec is connected to the CPU via a DAI, not directly, we do
not care if the CPU DAI is using 3-byte or 4-byte formats, so we can
support them both.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-15-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Require an exact BCLK divisor match
Samuel Holland [Wed, 14 Oct 2020 06:19:37 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Require an exact BCLK divisor match

Now that we guarantee that SYSCLK is running at the optimal rate when
hw_params succeeds, and that it will continue running at that rate,
SYSCLK will always be an integer multiple of BCLK. So we can always
pick the exact divider, not just the closest divider.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-14-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Protect the clock rate while streams are open
Samuel Holland [Wed, 14 Oct 2020 06:19:36 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Protect the clock rate while streams are open

The codec's clock input is shared among all AIFs, and shared with other
audio-related hardware in the SoC, including I2S and SPDIF controllers.
To ensure sample rates selected by userspace or by codec2codec DAI links
are maintained, the clock rate must be protected while it is in use.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20201014061941.4306-13-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Constrain to compatible sample rates
Samuel Holland [Wed, 14 Oct 2020 06:19:35 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Constrain to compatible sample rates

While another stream is active, only allow userspace to use sample rates
that are compatible with the current SYSCLK frequency. This ensures the
actual sample rate will always match what is given in hw_params.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-12-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Automatically set the system sample rate
Samuel Holland [Wed, 14 Oct 2020 06:19:34 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Automatically set the system sample rate

The sun8i codec has three clock/sample rate domains:
 - The AIF1 domain, with a sample rate equal to AIF1 LRCK
 - The AIF2 domain, with a sample rate equal to AIF2 LRCK
 - The SYSCLK domain, containing the ADC, DAC, and effects (AGC/DRC),
   with a sample rate given by a divisor from SYSCLK. The divisor is
   controlled by the AIF1_FS or AIF2_FS field in SYS_SR_CTRL, depending
   on if SYSCLK's source is AIF1CLK or AIF2CLK, respectively. The exact
   sample rate depends on if SYSCLK is running at 22.6 MHz or 24.6 MHz.

When an AIF (currently only AIF1) is active, the ADC and DAC should run
at that sample rate to avoid artifacting. Sample rate conversion is only
available when multiple AIFs are active and are routed to each other;
this means the sample rate conversion hardware usually cannot be used.

Only attach the event hook to the channel 0 AIF widgets, since we only
need one event when a DAI stream starts or stops. Channel 0 is always
brought up with a DAI stream, regardless of the number of channels in
the stream.

The ADC and DAC (along with their effects blocks) can be used even if
no AIFs are in use. In that case, we should select an appropriate sample
rate divisor, instead of keeping the last-used AIF sample rate.
44.1/48 kHz was chosen to balance audio quality and power consumption.

Since the sample rate is tied to active AIF paths, disabling pmdown_time
allows switching to the optimal sample rate immediately, instead of
after a 5 second delay.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20201014061941.4306-11-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Enable all supported sample rates
Samuel Holland [Wed, 14 Oct 2020 06:19:33 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Enable all supported sample rates

The system sample rate programmed into the hardware is really a clock
divider from SYSCLK to the ADC and DAC. Since we support two SYSCLK
frequencies, we can use all sample rates corresponding to one of those
frequencies divided by any available divisor.

This commit enables support for those sample rates. It also stops
advertising support for a 64 kHz sample rate, which is not supported.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-10-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Enforce symmetric DAI parameters
Samuel Holland [Wed, 14 Oct 2020 06:19:32 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Enforce symmetric DAI parameters

The AIFs have a single register controlling DAI parameters in both
directions, including BCLK/LRCK divisor and word size. The DAIs produce
only noise or silence if any of these parameters is wrong. Therefore, we
need to enforce symmetry for these parameters, so starting a new
substream will not break an existing substream.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-9-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Support the TDM slot binding
Samuel Holland [Wed, 14 Oct 2020 06:19:31 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Support the TDM slot binding

Now that BCLK and LRCK rate calculations in the driver can handle any
hardware-supported slot width and number of slots, allow overriding
those parameters from the device tree.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-8-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Correct the BCLK divisor calculation
Samuel Holland [Wed, 14 Oct 2020 06:19:30 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Correct the BCLK divisor calculation

Previously, the BCLK divisor calculation assumed zero padding and
exactly two slots. In order to support the TDM slot binding and
20/24-bit word sizes, those assumptions must be removed.

Due to hardware limitations, the BCLK/LRCK ratio is not as simple as
"slot_width * slots". However, the correct value is already calculated
elsewhere in this function, since it must also be programmed into the
hardware. Reuse that value to calculate the correct SYSCLK/BCLK divisor.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-7-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Round up the LRCK divisor
Samuel Holland [Wed, 14 Oct 2020 06:19:29 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Round up the LRCK divisor

The codec supports only power-of-two BCLK/LRCK divisors. If either the
slot width or the number of slots is not a power of two, the LRCK
divisor must be rounded up to provide enough space. To do that, use
order_base_2 (instead of ilog2, which rounds down).

Since the rounded divisor is also needed for setting the SYSCLK/BCLK
divisor, return the order base 2 instead of fully calculating the
hardware register encoding.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-6-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Use the provided word size
Samuel Holland [Wed, 14 Oct 2020 06:19:28 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Use the provided word size

The hardware supports 8 to 24-bit word sizes on all three of its DAIs,
only one of which is connected to the CPU DAI. Program the word size
based on the actual selected format, instead of assuming limitations
from another driver (which, incedentally, has patches pending to remove
that limitation).

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-5-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Enable all supported clock inversions
Samuel Holland [Wed, 14 Oct 2020 06:19:27 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Enable all supported clock inversions

When using the I2S, LEFT_J, or RIGHT_J format, the hardware supports
independent BCLK and LRCK inversion control. When using DSP_A or DSP_B,
LRCK inversion is not supported. The register bit is repurposed to
select between DSP_A and DSP_B. Extend the driver to support this.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20201014061941.4306-4-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Program DAI format before clock inversion
Samuel Holland [Wed, 14 Oct 2020 06:19:26 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Program DAI format before clock inversion

The LRCK inversion bit has a different meaning in DSP mode: it selects
between the DSP A and DSP B formats. To support this, we need to know if
the selected format is a DSP format. One easy way to do this is to set
the format field before the clock inversion fields.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-3-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: sun8i-codec: Prepare to extend the DAI driver
Samuel Holland [Wed, 14 Oct 2020 06:19:25 +0000 (01:19 -0500)]
ASoC: sun8i-codec: Prepare to extend the DAI driver

In preparation for adding additional DAIs to this component, convert the
DAI driver definition to an array. Since this changes all of the lines
in the definition anyway, let's move it closer to the ops function
definitions, instead of on the far side of the DAPM arrays. And while
moving the DAI driver ops, rename the set_fmt hook to match the usual
naming scheme.

Give the existing DAI an explicit ID and more meaningful stream names,
so it will remain unique as more DAIs are added. The AIF widget streams
must be updated to match.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20201014061941.4306-2-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoMerge existing fixes from asoc/for-5.10
Mark Brown [Mon, 26 Oct 2020 13:11:37 +0000 (13:11 +0000)]
Merge existing fixes from asoc/for-5.10

3 years agoLinux 5.10-rc1
Linus Torvalds [Sun, 25 Oct 2020 22:14:11 +0000 (15:14 -0700)]
Linux 5.10-rc1

3 years agotreewide: Convert macro and uses of __section(foo) to __section("foo")
Joe Perches [Thu, 22 Oct 2020 02:36:07 +0000 (19:36 -0700)]
treewide: Convert macro and uses of __section(foo) to __section("foo")

Use a more generic form for __section that requires quotes to avoid
complications with clang and gcc differences.

Remove the quote operator # from compiler_attributes.h __section macro.

Convert all unquoted __section(foo) uses to quoted __section("foo").
Also convert __attribute__((section("foo"))) uses to __section("foo")
even if the __attribute__ has multiple list entry forms.

Conversion done using the script at:

    https://lore.kernel.org/lkml/75393e5ddc272dc7403de74d645e6c6e0f4e70eb.camel@perches.com/2-convert_section.pl

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@gooogle.com>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agokernel/sys.c: fix prototype of prctl_get_tid_address()
Rasmus Villemoes [Sat, 24 Oct 2020 01:04:26 +0000 (03:04 +0200)]
kernel/sys.c: fix prototype of prctl_get_tid_address()

tid_addr is not a "pointer to (pointer to int in userspace)"; it is in
fact a "pointer to (pointer to int in userspace) in userspace".  So
sparse rightfully complains about passing a kernel pointer to
put_user().

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agomm: remove kzfree() compatibility definition
Eric Biggers [Fri, 23 Oct 2020 23:27:16 +0000 (16:27 -0700)]
mm: remove kzfree() compatibility definition

Commit 453431a54934 ("mm, treewide: rename kzfree() to
kfree_sensitive()") renamed kzfree() to kfree_sensitive(),
but it left a compatibility definition of kzfree() to avoid
being too disruptive.

Since then a few more instances of kzfree() have slipped in.

Just get rid of them and remove the compatibility definition
once and for all.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agocheckpatch: enable GIT_DIR environment use to set git repository location
Joe Perches [Sat, 24 Oct 2020 23:59:04 +0000 (16:59 -0700)]
checkpatch: enable GIT_DIR environment use to set git repository location

If set, use the environment variable GIT_DIR to change the default .git
location of the kernel git tree.

If GIT_DIR is unset, keep using the current ".git" default.

Link: https://lkml.kernel.org/r/c5e23b45562373d632fccb8bc04e563abba4dd1d.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agoMerge tag 'timers-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Oct 2020 18:28:49 +0000 (11:28 -0700)]
Merge tag 'timers-urgent-2020-10-25' of git://git./linux/kernel/git/tip/tip

Pull timer fixes from Thomas Gleixner:
 "A time namespace fix and a matching selftest. The futex absolute
  timeouts which are based on CLOCK_MONOTONIC require time namespace
  corrected. This was missed in the original time namesapce support"

* tag 'timers-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  selftests/timens: Add a test for futex()
  futex: Adjust absolute futex timeouts with per time namespace offset

3 years agoMerge tag 'sched-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Oct 2020 18:25:16 +0000 (11:25 -0700)]
Merge tag 'sched-urgent-2020-10-25' of git://git./linux/kernel/git/tip/tip

Pull scheduler fixes from Thomas Gleixner:
 "Two scheduler fixes:

   - A trivial build fix for sched_feat() to compile correctly with
     CONFIG_JUMP_LABEL=n

   - Replace a zero lenght array with a flexible array"

* tag 'sched-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/features: Fix !CONFIG_JUMP_LABEL case
  sched: Replace zero-length array with flexible-array

3 years agoMerge tag 'perf-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 25 Oct 2020 18:22:59 +0000 (11:22 -0700)]
Merge tag 'perf-urgent-2020-10-25' of git://git./linux/kernel/git/tip/tip

Pull perf fix from Thomas Gleixner:
 "A single fix to compute the field offset of the SNOOPX bit in the data
  source bitmask of perf events correctly"

* tag 'perf-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf: correct SNOOPX field offset

3 years agoMerge tag 'locking-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Oct 2020 18:14:54 +0000 (11:14 -0700)]
Merge tag 'locking-urgent-2020-10-25' of git://git./linux/kernel/git/tip/tip

Pull locking fix from Thomas Gleixner:
 "Just a trivial fix for kernel-doc warnings"

* tag 'locking-urgent-2020-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  locking/seqlocks: Fix kernel-doc warnings

3 years agoMerge tag 'ntb-5.10' of git://github.com/jonmason/ntb
Linus Torvalds [Sun, 25 Oct 2020 18:12:31 +0000 (11:12 -0700)]
Merge tag 'ntb-5.10' of git://github.com/jonmason/ntb

Pull NTB fixes from Jon Mason.

* tag 'ntb-5.10' of git://github.com/jonmason/ntb:
  NTB: Use struct_size() helper in devm_kzalloc()
  ntb: intel: Fix memleak in intel_ntb_pci_probe
  NTB: hw: amd: fix an issue about leak system resources

3 years agoMerge branch 'i2c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
Linus Torvalds [Sun, 25 Oct 2020 18:10:23 +0000 (11:10 -0700)]
Merge branch 'i2c/for-5.10' of git://git./linux/kernel/git/wsa/linux

Pull i2c fix from Wolfram Sang:
 "Regression fix for rc1 and stable kernels as well"

* 'i2c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: core: Restore acpi_walk_dep_device_list() getting called after registering the ACPI i2c devs

3 years agoMerge tag '5.10-rc-smb3-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sun, 25 Oct 2020 18:05:04 +0000 (11:05 -0700)]
Merge tag '5.10-rc-smb3-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6

Pull more cifs updates from Steve French:
 "Add support for stat of various special file types (WSL reparse points
  for char, block, fifo)"

* tag '5.10-rc-smb3-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: update internal module version number
  smb3: add some missing definitions from MS-FSCC
  smb3: remove two unused variables
  smb3: add support for stat of WSL reparse points for special file types

3 years agoMerge branch 'parisc-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
Linus Torvalds [Sun, 25 Oct 2020 17:59:34 +0000 (10:59 -0700)]
Merge branch 'parisc-5.10-2' of git://git./linux/kernel/git/deller/parisc-linux

Pull more parisc updates from Helge Deller:

 - During this merge window O_NONBLOCK was changed to become 000200000,
   but we missed that the syscalls timerfd_create(), signalfd4(),
   eventfd2(), pipe2(), inotify_init1() and userfaultfd() do a strict
   bit-wise check of the flags parameter.

   To provide backward compatibility with existing userspace we
   introduce parisc specific wrappers for those syscalls which filter
   out the old O_NONBLOCK value and replaces it with the new one.

 - Prevent HIL bus driver to get stuck when keyboard or mouse isn't
   attached

 - Improve error return codes when setting rtc time

 - Minor documentation fix in pata_ns87415.c

* 'parisc-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
  ata: pata_ns87415.c: Document support on parisc with superio chip
  parisc: Add wrapper syscalls to fix O_NONBLOCK flag usage
  hil/parisc: Disable HIL driver when it gets stuck
  parisc: Improve error return codes when setting rtc time

3 years agoMerge tag 'for-linus-5.10b-rc1c-tag' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Oct 2020 17:55:35 +0000 (10:55 -0700)]
Merge tag 'for-linus-5.10b-rc1c-tag' of git://git./linux/kernel/git/xen/tip

Pull more xen updates from Juergen Gross:

 - a series for the Xen pv block drivers adding module parameters for
   better control of resource usge

 - a cleanup series for the Xen event driver

* tag 'for-linus-5.10b-rc1c-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  Documentation: add xen.fifo_events kernel parameter description
  xen/events: unmask a fifo event channel only if it was masked
  xen/events: only register debug interrupt for 2-level events
  xen/events: make struct irq_info private to events_base.c
  xen: remove no longer used functions
  xen-blkfront: Apply changed parameter name to the document
  xen-blkfront: add a parameter for disabling of persistent grants
  xen-blkback: add a parameter for disabling of persistent grants

3 years agoMerge tag 'safesetid-5.10' of git://github.com/micah-morton/linux
Linus Torvalds [Sun, 25 Oct 2020 17:45:26 +0000 (10:45 -0700)]
Merge tag 'safesetid-5.10' of git://github.com/micah-morton/linux

Pull SafeSetID updates from Micah Morton:
 "The changes are mostly contained to within the SafeSetID LSM, with the
  exception of a few 1-line changes to change some ns_capable() calls to
  ns_capable_setid() -- causing a flag (CAP_OPT_INSETID) to be set that
  is examined by SafeSetID code and nothing else in the kernel.

  The changes to SafeSetID internally allow for setting up GID
  transition security policies, as already existed for UIDs"

* tag 'safesetid-5.10' of git://github.com/micah-morton/linux:
  LSM: SafeSetID: Fix warnings reported by test bot
  LSM: SafeSetID: Add GID security policy handling
  LSM: Signal to SafeSetID when setting group IDs

3 years agoMerge tag '20201024-v4-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/wtarrea...
Linus Torvalds [Sun, 25 Oct 2020 17:40:08 +0000 (10:40 -0700)]
Merge tag '20201024-v4-5.10' of git://git./linux/kernel/git/wtarreau/prandom

Pull random32 updates from Willy Tarreau:
 "Make prandom_u32() less predictable.

  This is the cleanup of the latest series of prandom_u32
  experimentations consisting in using SipHash instead of Tausworthe to
  produce the randoms used by the network stack.

  The changes to the files were kept minimal, and the controversial
  commit that used to take noise from the fast_pool (f227e3ec3b5c) was
  reverted. Instead, a dedicated "net_rand_noise" per_cpu variable is
  fed from various sources of activities (networking, scheduling) to
  perturb the SipHash state using fast, non-trivially predictable data,
  instead of keeping it fully deterministic. The goal is essentially to
  make any occasional memory leakage or brute-force attempt useless.

  The resulting code was verified to be very slightly faster on x86_64
  than what is was with the controversial commit above, though this
  remains barely above measurement noise. It was also tested on i386 and
  arm, and build- tested only on arm64"

Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
* tag '20201024-v4-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/prandom:
  random32: add a selftest for the prandom32 code
  random32: add noise from network and scheduling activity
  random32: make prandom_u32() output unpredictable

3 years agoi2c: core: Restore acpi_walk_dep_device_list() getting called after registering the...
Hans de Goede [Wed, 14 Oct 2020 14:41:58 +0000 (16:41 +0200)]
i2c: core: Restore acpi_walk_dep_device_list() getting called after registering the ACPI i2c devs

Commit 21653a4181ff ("i2c: core: Call i2c_acpi_install_space_handler()
before i2c_acpi_register_devices()")'s intention was to only move the
acpi_install_address_space_handler() call to the point before where
the ACPI declared i2c-children of the adapter where instantiated by
i2c_acpi_register_devices().

But i2c_acpi_install_space_handler() had a call to
acpi_walk_dep_device_list() hidden (that is I missed it) at the end
of it, so as an unwanted side-effect now acpi_walk_dep_device_list()
was also being called before i2c_acpi_register_devices().

Move the acpi_walk_dep_device_list() call to the end of
i2c_acpi_register_devices(), so that it is once again called *after*
the i2c_client-s hanging of the adapter have been created.

This fixes the Microsoft Surface Go 2 hanging at boot.

Fixes: 21653a4181ff ("i2c: core: Call i2c_acpi_install_space_handler() before i2c_acpi_register_devices()")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=209627
Reported-by: Rainer Finke <rainer@finke.cc>
Reported-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Suggested-by: Maximilian Luz <luzmaximilian@gmail.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
3 years agoMerge tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 24 Oct 2020 19:46:42 +0000 (12:46 -0700)]
Merge tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:

 - NVMe pull request from Christoph
     - rdma error handling fixes (Chao Leng)
     - fc error handling and reconnect fixes (James Smart)
     - fix the qid displace when tracing ioctl command (Keith Busch)
     - don't use BLK_MQ_REQ_NOWAIT for passthru (Chaitanya Kulkarni)
     - fix MTDT for passthru (Logan Gunthorpe)
     - blacklist Write Same on more devices (Kai-Heng Feng)
     - fix an uninitialized work struct (zhenwei pi)"

 - lightnvm out-of-bounds fix (Colin)

 - SG allocation leak fix (Doug)

 - rnbd fixes (Gioh, Guoqing, Jack)

 - zone error translation fixes (Keith)

 - kerneldoc markup fix (Mauro)

 - zram lockdep fix (Peter)

 - Kill unused io_context members (Yufen)

 - NUMA memory allocation cleanup (Xianting)

 - NBD config wakeup fix (Xiubo)

* tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block: (27 commits)
  block: blk-mq: fix a kernel-doc markup
  nvme-fc: shorten reconnect delay if possible for FC
  nvme-fc: wait for queues to freeze before calling update_hr_hw_queues
  nvme-fc: fix error loop in create_hw_io_queues
  nvme-fc: fix io timeout to abort I/O
  null_blk: use zone status for max active/open
  nvmet: don't use BLK_MQ_REQ_NOWAIT for passthru
  nvmet: cleanup nvmet_passthru_map_sg()
  nvmet: limit passthru MTDS by BIO_MAX_PAGES
  nvmet: fix uninitialized work for zero kato
  nvme-pci: disable Write Zeroes on Sandisk Skyhawk
  nvme: use queuedata for nvme_req_qid
  nvme-rdma: fix crash due to incorrect cqe
  nvme-rdma: fix crash when connect rejected
  block: remove unused members for io_context
  blk-mq: remove the calling of local_memory_node()
  zram: Fix __zram_bvec_{read,write}() locking order
  skd_main: remove unused including <linux/version.h>
  sgl_alloc_order: fix memory leak
  lightnvm: fix out-of-bounds write to array devices->info[]
  ...

3 years agoMerge tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 24 Oct 2020 19:40:18 +0000 (12:40 -0700)]
Merge tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:

 - fsize was missed in previous unification of work flags

 - Few fixes cleaning up the flags unification creds cases (Pavel)

 - Fix NUMA affinities for completely unplugged/replugged node for io-wq

 - Two fallout fixes from the set_fs changes. One local to io_uring, one
   for the splice entry point that io_uring uses.

 - Linked timeout fixes (Pavel)

 - Removal of ->flush() ->files work-around that we don't need anymore
   with referenced files (Pavel)

 - Various cleanups (Pavel)

* tag 'io_uring-5.10-2020-10-24' of git://git.kernel.dk/linux-block:
  splice: change exported internal do_splice() helper to take kernel offset
  io_uring: make loop_rw_iter() use original user supplied pointers
  io_uring: remove req cancel in ->flush()
  io-wq: re-set NUMA node affinities if CPUs come online
  io_uring: don't reuse linked_timeout
  io_uring: unify fsize with def->work_flags
  io_uring: fix racy REQ_F_LINK_TIMEOUT clearing
  io_uring: do poll's hash_node init in common code
  io_uring: inline io_poll_task_handler()
  io_uring: remove extra ->file check in poll prep
  io_uring: make cached_cq_overflow non atomic_t
  io_uring: inline io_fail_links()
  io_uring: kill ref get/drop in personality init
  io_uring: flags-based creds init in queue

3 years agoMerge tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 24 Oct 2020 19:36:24 +0000 (12:36 -0700)]
Merge tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block

Pull libata fixes from Jens Axboe:
 "Two minor libata fixes:

   - Fix a DMA boundary mask regression for sata_rcar (Geert)

   - kerneldoc markup fix (Mauro)"

* tag 'libata-5.10-2020-10-24' of git://git.kernel.dk/linux-block:
  ata: fix some kernel-doc markups
  ata: sata_rcar: Fix DMA boundary mask

3 years agoMerge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Linus Torvalds [Sat, 24 Oct 2020 19:26:05 +0000 (12:26 -0700)]
Merge branch 'work.misc' of git://git./linux/kernel/git/viro/vfs

Pull misc vfs updates from Al Viro:
 "Assorted stuff all over the place (the largest group here is
  Christoph's stat cleanups)"

* 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs: remove KSTAT_QUERY_FLAGS
  fs: remove vfs_stat_set_lookup_flags
  fs: move vfs_fstatat out of line
  fs: implement vfs_stat and vfs_lstat in terms of vfs_fstatat
  fs: remove vfs_statx_fd
  fs: omfs: use kmemdup() rather than kmalloc+memcpy
  [PATCH] reduce boilerplate in fsid handling
  fs: Remove duplicated flag O_NDELAY occurring twice in VALID_OPEN_FLAGS
  selftests: mount: add nosymfollow tests
  Add a "nosymfollow" mount option.

3 years agoMerge tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping
Linus Torvalds [Sat, 24 Oct 2020 19:17:05 +0000 (12:17 -0700)]
Merge tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fixes from Christoph Hellwig:

 - document the new dma_{alloc,free}_pages() API

 - two fixups for the dma-mapping.h split

* tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping:
  dma-mapping: document dma_{alloc,free}_pages
  dma-mapping: move more functions to dma-map-ops.h
  ARM/sa1111: add a missing include of dma-map-ops.h

3 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Sat, 24 Oct 2020 19:09:22 +0000 (12:09 -0700)]
Merge tag 'for-linus' of git://git./virt/kvm/kvm

Pull KVM fixes from Paolo Bonzini:
 "Two fixes for this merge window, and an unrelated bugfix for a host
  hang"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: ioapic: break infinite recursion on lazy EOI
  KVM: vmx: rename pi_init to avoid conflict with paride
  KVM: x86/mmu: Avoid modulo operator on 64-bit value to fix i386 build

3 years agoMerge tag 'x86_seves_fixes_for_v5.10_rc1' of git://git.kernel.org/pub/scm/linux/kerne...
Linus Torvalds [Sat, 24 Oct 2020 18:49:32 +0000 (11:49 -0700)]
Merge tag 'x86_seves_fixes_for_v5.10_rc1' of git://git./linux/kernel/git/tip/tip

Pull x86 SEV-ES fixes from Borislav Petkov:
 "Three fixes to SEV-ES to correct setting up the new early pagetable on
  5-level paging machines, to always map boot_params and the kernel
  cmdline, and disable stack protector for ../compressed/head{32,64}.c.
  (Arvind Sankar)"

* tag 'x86_seves_fixes_for_v5.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/boot/64: Explicitly map boot_params and command line
  x86/head/64: Disable stack protection for head$(BITS).o
  x86/boot/64: Initialize 5-level paging variables earlier

3 years agorandom32: add a selftest for the prandom32 code
Willy Tarreau [Sat, 24 Oct 2020 16:36:27 +0000 (18:36 +0200)]
random32: add a selftest for the prandom32 code

Given that this code is new, let's add a selftest for it as well.
It doesn't rely on fixed sets, instead it picks 1024 numbers and
verifies that they're not more correlated than desired.

Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
Cc: George Spelvin <lkml@sdf.org>
Cc: Amit Klein <aksecurity@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: tytso@mit.edu
Cc: Florian Westphal <fw@strlen.de>
Cc: Marc Plumb <lkml.mplumb@gmail.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
3 years agorandom32: add noise from network and scheduling activity
Willy Tarreau [Mon, 10 Aug 2020 08:27:42 +0000 (10:27 +0200)]
random32: add noise from network and scheduling activity

With the removal of the interrupt perturbations in previous random32
change (random32: make prandom_u32() output unpredictable), the PRNG
has become 100% deterministic again. While SipHash is expected to be
way more robust against brute force than the previous Tausworthe LFSR,
there's still the risk that whoever has even one temporary access to
the PRNG's internal state is able to predict all subsequent draws till
the next reseed (roughly every minute). This may happen through a side
channel attack or any data leak.

This patch restores the spirit of commit f227e3ec3b5c ("random32: update
the net random state on interrupt and activity") in that it will perturb
the internal PRNG's statee using externally collected noise, except that
it will not pick that noise from the random pool's bits nor upon
interrupt, but will rather combine a few elements along the Tx path
that are collectively hard to predict, such as dev, skb and txq
pointers, packet length and jiffies values. These ones are combined
using a single round of SipHash into a single long variable that is
mixed with the net_rand_state upon each invocation.

The operation was inlined because it produces very small and efficient
code, typically 3 xor, 2 add and 2 rol. The performance was measured
to be the same (even very slightly better) than before the switch to
SipHash; on a 6-core 12-thread Core i7-8700k equipped with a 40G NIC
(i40e), the connection rate dropped from 556k/s to 555k/s while the
SYN cookie rate grew from 5.38 Mpps to 5.45 Mpps.

Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
Cc: George Spelvin <lkml@sdf.org>
Cc: Amit Klein <aksecurity@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: tytso@mit.edu
Cc: Florian Westphal <fw@strlen.de>
Cc: Marc Plumb <lkml.mplumb@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
3 years agorandom32: make prandom_u32() output unpredictable
George Spelvin [Sun, 9 Aug 2020 06:57:44 +0000 (06:57 +0000)]
random32: make prandom_u32() output unpredictable

Non-cryptographic PRNGs may have great statistical properties, but
are usually trivially predictable to someone who knows the algorithm,
given a small sample of their output.  An LFSR like prandom_u32() is
particularly simple, even if the sample is widely scattered bits.

It turns out the network stack uses prandom_u32() for some things like
random port numbers which it would prefer are *not* trivially predictable.
Predictability led to a practical DNS spoofing attack.  Oops.

This patch replaces the LFSR with a homebrew cryptographic PRNG based
on the SipHash round function, which is in turn seeded with 128 bits
of strong random key.  (The authors of SipHash have *not* been consulted
about this abuse of their algorithm.)  Speed is prioritized over security;
attacks are rare, while performance is always wanted.

Replacing all callers of prandom_u32() is the quick fix.
Whether to reinstate a weaker PRNG for uses which can tolerate it
is an open question.

Commit f227e3ec3b5c ("random32: update the net random state on interrupt
and activity") was an earlier attempt at a solution.  This patch replaces
it.

Reported-by: Amit Klein <aksecurity@gmail.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: tytso@mit.edu
Cc: Florian Westphal <fw@strlen.de>
Cc: Marc Plumb <lkml.mplumb@gmail.com>
Fixes: f227e3ec3b5c ("random32: update the net random state on interrupt and activity")
Signed-off-by: George Spelvin <lkml@sdf.org>
Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
[ willy: partial reversal of f227e3ec3b5c; moved SIPROUND definitions
  to prandom.h for later use; merged George's prandom_seed() proposal;
  inlined siprand_u32(); replaced the net_rand_state[] array with 4
  members to fix a build issue; cosmetic cleanups to make checkpatch
  happy; fixed RANDOM32_SELFTEST build ]
Signed-off-by: Willy Tarreau <w@1wt.eu>
3 years agoMerge tag 'powerpc-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
Linus Torvalds [Sat, 24 Oct 2020 18:09:13 +0000 (11:09 -0700)]
Merge tag 'powerpc-5.10-2' of git://git./linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:

 - A fix for undetected data corruption on Power9 Nimbus <= DD2.1 in the
   emulation of VSX loads. The affected CPUs were not widely available.

 - Two fixes for machine check handling in guests under PowerVM.

 - A fix for our recent changes to SMP setup, when
   CONFIG_CPUMASK_OFFSTACK=y.

 - Three fixes for races in the handling of some of our powernv sysfs
   attributes.

 - One change to remove TM from the set of Power10 CPU features.

 - A couple of other minor fixes.

Thanks to: Aneesh Kumar K.V, Christophe Leroy, Ganesh Goudar, Jordan
Niethe, Mahesh Salgaonkar, Michael Neuling, Oliver O'Halloran, Qian Cai,
Srikar Dronamraju, Vasant Hegde.

* tag 'powerpc-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/pseries: Avoid using addr_to_pfn in real mode
  powerpc/uaccess: Don't use "m<>" constraint with GCC 4.9
  powerpc/eeh: Fix eeh_dev_check_failure() for PE#0
  powerpc/64s: Remove TM from Power10 features
  selftests/powerpc: Make alignment handler test P9N DD2.1 vector CI load workaround
  powerpc: Fix undetected data corruption with P9N DD2.1 VSX CI load emulation
  powerpc/powernv/dump: Handle multiple writes to ack attribute
  powerpc/powernv/dump: Fix race while processing OPAL dump
  powerpc/smp: Use GFP_ATOMIC while allocating tmp mask
  powerpc/smp: Remove unnecessary variable
  powerpc/mce: Avoid nmi_enter/exit in real mode on pseries hash
  powerpc/opal_elog: Handle multiple writes to ack attribute

3 years agoMerge tag 'riscv-for-linus-5.10-mw1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 24 Oct 2020 17:57:57 +0000 (10:57 -0700)]
Merge tag 'riscv-for-linus-5.10-mw1' of git://git./linux/kernel/git/riscv/linux

Pull more RISC-V updates from Palmer Dabbelt:
 "Just a single patch set: the remainder of Christoph's work to remove
  set_fs, including the RISC-V portion"

* tag 'riscv-for-linus-5.10-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: remove address space overrides using set_fs()
  riscv: implement __get_kernel_nofault and __put_user_nofault
  riscv: refactor __get_user and __put_user
  riscv: use memcpy based uaccess for nommu again
  asm-generic: make the set_fs implementation optional
  asm-generic: add nommu implementations of __{get,put}_kernel_nofault
  asm-generic: improve the nommu {get,put}_user handling
  uaccess: provide a generic TASK_SIZE_MAX definition

3 years agoMerge tag 'armsoc-defconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
Linus Torvalds [Sat, 24 Oct 2020 17:53:04 +0000 (10:53 -0700)]
Merge tag 'armsoc-defconfig' of git://git./linux/kernel/git/soc/soc

Pull ARM SoC defconfig updates from Olof Johansson:
 "We keep this in a separate branch to avoid cross-branch conflicts, but
  most of the material here is fairly boring -- some new drivers turned
  on for hardware since they were merged, and some refreshed files due
  to time having moved a lot of entries around"

* tag 'armsoc-defconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (33 commits)
  ARM: multi_v7_defconfig: add FMC2 EBI controller support
  arm64: defconfig: enable Qualcomm ASoC modules
  arm64: defconfig: qcom: enable GPU clock controller for SM8[12]50
  arm64: defconfig: enable INTERCONNECT for Qualcomm chipsets
  arm64: defconfig: enable the sl28cpld board management controller
  arm64: defconfig: Enable the eLCDIF and Raydium RM67191 drivers
  arm64: defconfig: Enable Qcom SNPS Femto PHY
  ARM: configs: Update Realview defconfig
  ARM: configs: Update Versatile defconfig
  ARM: config: aspeed_g5: Enable IBM OP Panel driver
  ARM: config: aspeed-g5: Enable I2C GPIO mux driver
  ARM: config: aspeed: Fix selection of media drivers
  arm64: defconfig: Enable Samsung S3FWRN5 NFC driver
  ARM: omap2plus_defconfig: enable generic net options
  ARM: omap2plus_defconfig: enable twl4030_madc as a loadable module
  arm64: defconfig: Enable clock driver for ROHM BD718x7 PMIC
  arm64: defconfig: Build ADMA and ACONNECT driver
  arm64: defconfig: Build AHUB component drivers
  arm64: defconfig: Enable Lontium LT9611 driver
  arm64: defcondfig: Enable USB ACM and FTDI drivers
  ...

3 years agoMerge tag 'armsoc-dt' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
Linus Torvalds [Sat, 24 Oct 2020 17:44:18 +0000 (10:44 -0700)]
Merge tag 'armsoc-dt' of git://git./linux/kernel/git/soc/soc

Pull ARM Devicetree updates from Olof Johansson:
 "As usual, most of the changes are to devicetrees.

  Besides smaller fixes, some refactorings and cleanups, some of the new
  platforms and chips (or significant features) supported are below:

  Broadcom boards:
   - Cisco Meraki MR32 (BCM53016-based)
   - BCM2711 (RPi4) display pipeline support

  Actions Semi boards:
   - Caninos Loucos Labrador SBC (S500-based)
   - RoseapplePi SBC (S500-based)

  Allwinner SoCs/boards:
   - A100 SoC with Perf1 board
   - Mali, DMA, Cetrus and IR support for R40 SoC

  Amlogic boards:
   - Libretch S905x CC V2 board
   - Hardkernel ODROID-N2+ board

  Aspeed boards/platforms:
   - Wistron Mowgli (AST2500-based, Power9 OpenPower server)
   - Facebook Wedge400 (AST2500-based, ToR switch)

  Hisilicon SoC:
   - SD5203 SoC

  Nvidia boards:
   - Tegra234 VDK, for pre-silicon Orin SoC

  NXP i.MX boards:
   - Librem 5 phone
   - i.MX8MM DDR4 EVK
   - Variscite VAR-SOM-MX8MN SoM
   - Symphony board
   - Tolino Shine 2 HD
   - TQMa6 SoM
   - Y Soft IOTA Orion

  Rockchip boards:
   - NanoPi R2S board
   - A95X-Z2 board
   - more Rock-Pi4 variants

  STM32 boards:
   - Odyssey SOM board (STM32MP157CAC-based)
   - DH DRC02 board

  Toshiba SoCs/boards:
   - Visconti SoC and TPMV7708 board"

* tag 'armsoc-dt' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (638 commits)
  ARM: dts: nspire: Fix SP804 users
  arm64: dts: lg: Fix SP804 users
  arm64: dts: lg: Fix SP805 clocks
  ARM: mstar: Fix up the fallout from moving the dts/dtsi files
  ARM: mstar: Add mstar prefix to all of the dtsi/dts files
  ARM: mstar: Add interrupt to pm_uart
  ARM: mstar: Add interrupt controller to base dtsi
  ARM: dts: meson8: remove two invalid interrupt lines from the GPU node
  arm64: dts: ti: k3-j7200-common-proc-board: Add USB support
  arm64: dts: ti: k3-j7200-common-proc-board: Configure the SERDES lane function
  arm64: dts: ti: k3-j7200-main: Add USB controller
  arm64: dts: ti: k3-j7200-main.dtsi: Add USB to SERDES lane MUX
  arm64: dts: ti: k3-j7200-main: Add SERDES lane control mux
  dt-bindings: ti-serdes-mux: Add defines for J7200 SoC
  ARM: dts: hisilicon: add SD5203 dts
  ARM: dts: hisilicon: fix the system controller compatible nodes
  arm64: dts: zynqmp: Fix leds subnode name for zcu100/ultra96 v1
  arm64: dts: zynqmp: Remove undocumented u-boot properties
  arm64: dts: zynqmp: Remove additional compatible string for i2c IPs
  arm64: dts: zynqmp: Rename buses to be align with simple-bus yaml
  ...