From nobody Fri Dec 19 04:53:45 2025 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0050222566 for ; Thu, 19 Dec 2024 10:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734605591; cv=none; b=IYo6tfAwu0mI16IjwtRpcq27+oIXnTTOlddtqFaoAtxJdlcJY68IHNwS7uOMbe1LWFGboQ+OaFfUfmUlfJ48n9tREzM1IuYSvEWmrjrymJdB1HZpH1l5/cfsFcQIM73sFAY7ZyEPlbYYX3etQNT6NEpA1maGgrWJj2X94vv8DOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734605591; c=relaxed/simple; bh=k28pLNNZjozLAKrGqFNCyucEiaZ4YUhCVjh8E4110oo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DUEFio778RZK//usr7GB/EYEslqtMjIyKeiPy7I64Zj3xrKErlOb/VG6xuUjMthicYOHe74mTCaHgzXUq+y2bhq+lB4KCLeKbw6azZpJLtW01/xBDcb9oGxfkNSyjCKl7VK3JssL73CHqnRkW6tCSsDZk2lJtcPscUL0Lmtp5T8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=KJ0RXbX1; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KJ0RXbX1" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7fd4c0220bbso490748a12.0 for ; Thu, 19 Dec 2024 02:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1734605588; x=1735210388; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=h9EH0VzNdlwEE7HT+ejlIQXInr2HWzq5t9FyUGd1FM0=; b=KJ0RXbX1drflt9ehU3JTgVXItynFxGNuZ7iCdg7a4wkFlQZcH1b9OFMJX6nmOuQy/T fMDxPDf6Gm//1ujKiYNxxBMlFJZqs64RSNnXlr8gaSvWxP6gwVLY8VJoHPRDcGFurbpc tHuJg9YTFhn2VgS21RuQkeADszZtmvcZ56qLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734605588; x=1735210388; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h9EH0VzNdlwEE7HT+ejlIQXInr2HWzq5t9FyUGd1FM0=; b=tApX8ZLLRyPo3Bf01wUsGY8TcfrrFKJ5yPeb3A8IdgqArewUClSSsXMKplUF1Kx8OP WBMkyarAxjUUsZBY7CPiA4UvpjV+YsEqQTOsWB6/upApZwDsMp9qP5gLonf+92yN7Jv/ N/vF2Eqo0cRBXZ86UKHSw3J/LsbYmsrNHPapgiz3uJhRcntMDgLC7CS+WP6QzSkMltRj ePsvaScri6FFe9mOBKFpfhhoQAEriDh5N0Eqh4eH+wObLP18lgcfeym9pQIHzdYlMp6J +qYiSAqfHhWiwvB0uNM1KD4KA63LfV0uzxxq2VF1dH/CDQnEtXbetZyrwvaN0f+0am52 k9bw== X-Forwarded-Encrypted: i=1; AJvYcCVyw16W9g2UKuUackZ5GHaEi6jtEzc7FomaENGJUkJs2E3Dh79/qSzpTfUMSKUkVay5ImuJk+h18j2EO2g=@vger.kernel.org X-Gm-Message-State: AOJu0YwEt7fzOXNx79m4MFZEOeeJhWLqvqfaADhaaWNMi743YAs4o9P5 BGRc9XSlVl3kEiofh85ZrZJkXgUQ+Hb9vtvRGs5S0XUkQGb9qTc4/OvqSOE6ag== X-Gm-Gg: ASbGncsX8zE7NP0lm2bZEi3gfGcpDYGzeouxs0MuNzQFkx8sVY9bVQydfeIL4dO1gJw xI1k4bWAVfJ9tSizgVV2ImOFHA1hvVtJ9sP74Kezf5w3rewbtcwsPDbGISJRM2ISwQ2g0Fn8Lkn g/dw9ontOGUonlwg2TpKmNRzuMdI1Wtp8uk9pGuIznuM3Z9j7tEopqnEAtsTDL6FSS3oO4Vvd3m PH2bVXXTlURi918kpiMq7QPOxtwsQCd92lZM4Bph5Rb7XBlD0olsz0C94JLKPMbRj8Whk5dZQ== X-Google-Smtp-Source: AGHT+IENxlsOZm9def6oti4V70uj/jGgxMRZENhVtBejHswBs3FlI1YExvOn9EK0Mjoqmtw4PCN2Zg== X-Received: by 2002:a17:90a:c105:b0:2ee:f80c:6892 with SMTP id 98e67ed59e1d1-2f2e91a4d5emr9173937a91.3.1734605588162; Thu, 19 Dec 2024 02:53:08 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6603:6add:77e:d71c]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ee06dd61sm2975014a91.42.2024.12.19.02.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 02:53:07 -0800 (PST) From: Chen-Yu Tsai To: Mark Brown , Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , linux-sound@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, treapking@chromium.org, yuanhsinte@chromium.org Subject: [PATCH] ASoC: mediatek: disable buffer pre-allocation Date: Thu, 19 Dec 2024 18:53:02 +0800 Message-ID: <20241219105303.548437-1-wenst@chromium.org> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Chromebooks based on Mediatek MT8195 or MT8188, the audio frontend (AFE) is limited to accessing a very small window (1 MiB) of memory, which is described as a reserved memory region in the device tree. On these two platforms, the maximum buffer size is given as 512 KiB. The MediaTek common code uses the same value for preallocations. This means that only the first two PCM substreams get preallocations, and then the whole space is exhausted, barring any other substreams from working. Since the substreams used are not always the first two, this means audio won't work correctly. This is observed on the MT8188 Geralt Chromebooks, on which the "mediatek,dai-link" property was dropped when it was upstreamed. That property causes the driver to only register the PCM substreams listed in the property, and in the order given. Instead of trying to compute an optimal value and figuring out which streams are used, simply disable preallocation. The PCM buffers are managed by the core and are allocated and released on the fly. There should be no impact to any of the other MediaTek platforms. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/common/mtk-afe-platform-driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/so= c/mediatek/common/mtk-afe-platform-driver.c index 9b72b2a7ae91..6b6330583941 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -120,8 +120,8 @@ int mtk_afe_pcm_new(struct snd_soc_component *component, struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); =20 size =3D afe->mtk_afe_hardware->buffer_bytes_max; - snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, - afe->dev, size, size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, afe->dev, 0, size= ); + return 0; } EXPORT_SYMBOL_GPL(mtk_afe_pcm_new); --=20 2.47.1.613.gc27f4b7a9f-goog