Merge tag 'LA.UM.9.14.r1-25800-LAHAINA.QSSI15.0' of https://git.codelinaro.org/clo/la/platform/vendor/opensource/audio-kernel into android13-5.4-lahaina

"LA.UM.9.14.r1-25800-LAHAINA.QSSI15.0"

* tag 'LA.UM.9.14.r1-25800-LAHAINA.QSSI15.0' of https://git.codelinaro.org/clo/la/platform/vendor/opensource/audio-kernel:
  asoc: codec: avoid out of bound write to map array
  asoc: codec: avoid out of bound write to map array
  asoc: Fixed OOB issue in qcs405
  asoc: codec: wcd934x: enable auto recovery when port overflows

Change-Id: I51a30fe905251b6f66e733bae43fdcd3b0a7e787
This commit is contained in:
Michael Bestas
2025-02-14 03:28:21 +02:00
6 changed files with 41 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@@ -257,6 +258,10 @@ static int rouleur_parse_port_mapping(struct device *dev,
for (i = 0; i < map_length; i++) {
port_num = dt_array[NUM_SWRS_DT_PARAMS * i];
if (port_num >= MAX_PORT || ch_iter >= MAX_CH_PER_PORT) {
dev_err(dev, "%s: Invalid port or channel number\n", __func__);
goto err_pdata_fail;
}
slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
#include <linux/init.h>
@@ -153,6 +153,8 @@ static const struct snd_kcontrol_new name##_mux = \
#define WCD934X_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
#define ENABLE_FIFO_OVERRUN_AUTO_RECOVERY_BIT 0x1
enum {
POWER_COLLAPSE,
POWER_RESUME,
@@ -1561,6 +1563,14 @@ static void tavil_codec_enable_slim_port_intr(
val = wcd9xxx_interface_reg_read(
tavil_p->wcd9xxx, reg);
}
/* Enable auto recovery from slim port overflow on port_num */
reg = WCD934X_SLIM_PGD_PORT_TX_OR_UR_CFG_0 + port_num;
val = wcd9xxx_interface_reg_read(tavil_p->wcd9xxx, reg);
if(!(val & (1 << ENABLE_FIFO_OVERRUN_AUTO_RECOVERY_BIT))) {
val = val | (1 << ENABLE_FIFO_OVERRUN_AUTO_RECOVERY_BIT);
wcd9xxx_interface_reg_write(tavil_p->wcd9xxx, reg, val);
val = wcd9xxx_interface_reg_read(tavil_p->wcd9xxx, reg);
}
}
}
}
@@ -10018,6 +10028,15 @@ static irqreturn_t tavil_slimbus_irq(int irq, void *data)
WARN(!cleared,
"Couldn't find slimbus %s port %d for closing\n",
(tx ? "TX" : "RX"), port_id);
/* Enable auto recovery from slim port overflow on port_num */
reg = WCD934X_SLIM_PGD_PORT_TX_OR_UR_CFG_0 + port_id;
val = wcd9xxx_interface_reg_read(tavil->wcd9xxx, reg);
if((val & (1 << ENABLE_FIFO_OVERRUN_AUTO_RECOVERY_BIT))) {
val = val ^ (1 << ENABLE_FIFO_OVERRUN_AUTO_RECOVERY_BIT);
wcd9xxx_interface_reg_write(tavil->wcd9xxx, reg, val);
val = wcd9xxx_interface_reg_read(tavil->wcd9xxx, reg);
}
}
wcd9xxx_interface_reg_write(tavil->wcd9xxx,
WCD934X_SLIM_PGD_PORT_INT_CLR_RX_0 +

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@@ -315,6 +315,10 @@ static int wcd937x_parse_port_mapping(struct device *dev,
for (i = 0; i < map_length; i++) {
port_num = dt_array[NUM_SWRS_DT_PARAMS * i];
if (port_num >= MAX_PORT || ch_iter >= MAX_CH_PER_PORT) {
dev_err(dev, "%s: Invalid port or channel number\n", __func__);
goto err_pdata_fail;
}
slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022,2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@@ -395,6 +395,12 @@ static int wcd938x_parse_port_mapping(struct device *dev,
for (i = 0; i < map_length; i++) {
port_num = dt_array[NUM_SWRS_DT_PARAMS * i];
if (port_num >= MAX_PORT || ch_iter >= MAX_CH_PER_PORT) {
dev_err(dev, "%s: Invalid port or channel number\n", __func__);
goto err_pdata_fail;
}
slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022,2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/clk.h>
#include <linux/delay.h>
@@ -7376,7 +7376,7 @@ static void msm_meta_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
pr_debug("%s(): substream = %s stream = %d\n", __func__,
substream->name, substream->stream);
if (index < PRIM_MI2S || index >= MI2S_MAX) {
if (index < PRIM_MI2S || index >= META_MI2S_MAX) {
pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
return;
}

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _WCD934X_REGISTERS_H
@@ -1836,5 +1837,6 @@ enum {
#define WCD934X_SLIM_PGD_PORT_INT_CLR_TX_1 (0x3B)
#define WCD934X_SLIM_PGD_PORT_INT_RX_SOURCE0 (0x60)
#define WCD934X_SLIM_PGD_PORT_INT_TX_SOURCE0 (0x70)
#define WCD934X_SLIM_PGD_PORT_TX_OR_UR_CFG_0 (0x1F0)
#endif