From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 B015672621 for ; Sun, 3 May 2026 00:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777768253; cv=none; b=unLxLMXINxUNxRW9paQ11ryFba/i1Egq95Jrt8+juMgtv+ytr6jEX2bBz7kb7GoYd30/SdIipkGnD+yxm4U7y88vOtPBjymNQBdqQn452kUwysVX6eksoqrvE7ACNDiO+s/tnegS/ReLCd1GpvaaKmnIfZb4yEf2lJsCjwZFJls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777768253; c=relaxed/simple; bh=N4Oewy83+Tf/MQeuvG7fpzvA1Aszha9anFzqTZugG0A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TQE39V7gDOtoEq2atsA0EoHFJB9feHhmgOGOFYyDp9YABkonh4kdK1sXlrfdIf8lyPGnwUl3aaiUfz1H60G7TS4/fLk5z8AtKfNSGn5OBhoE/AO7L4rIhl+RxAJoAzOkgL0l5Sw5UtAJl5gp4RS4e2EH6VSnNGyu73YUYY0rTHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hPjCbDfq; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hPjCbDfq" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8353ca0f1f1so153113b3a.1 for ; Sat, 02 May 2026 17:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777768252; x=1778373052; 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=2cqtN6UxMZDT/bmefPZMzQI/MaSXcFcM6J1zz/t6mH8=; b=hPjCbDfqOIYxyAYnFs5HLlGwKMxVf5NDKQTQt29hcQc9/JY9AKo86YOSG3SD2eTuiS oqMgwiLlookbhcBR1UEja0SUwEkE4BYlbco2Pf02rF1zpsPMlp0vC4rEh69dRvzsZwH5 KsS1VEXKYPOBEdH++9ukyselT3Lkfav5ktXq398EIxlELnjv61JK67wA4iFQhYgT84AQ LFyQdoqpJUq9G5TGXY3u3pgpm/y6YURmLdkXPKNt89w9KLa4W5x2D0Lr5B5b3H3duv6t u3Y4trT/kta3Iiu4BDzYxXTWmqFsdoQnqiILx6AzsGBoWQBe1Kjjj2TgouBtNZh82syw GM/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777768252; x=1778373052; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2cqtN6UxMZDT/bmefPZMzQI/MaSXcFcM6J1zz/t6mH8=; b=oZsiD9rlorM803DeTsSbzhTvtG3uojqJt+U5AJe6Df/UheaTmSuGDy549f0G+DSuy9 1H4G6NxnJRld5YY8o5Uc8qQYSR7hi3WufPG6uaxik1ZLc5xQ7rzNRjTRNulQ8dk9OOTX YxeVQ/CDWffIrnMhxCoC+DKsXnYjRRkPZVStdxTxfcvgtIvdcIuvCbUpvUwbsOjj4CvZ D+XBMZSIEacXOfL4b9wERvT/xU07UxSALUI1uLEGGyXftu54IIP+ampnix1AKcKN/5Nq 7SDP7oGwWAEPHRE3ZiQkJASx3e0XODOGktdowzMQFWx8bp3pkAlnDoej+n1DDxeoGVIP XdtQ== X-Forwarded-Encrypted: i=1; AFNElJ+HNc290pQkU2UdpI9mQ96v2quWZx3V2PB+isfbxY/kyIMM+6fSmMPpcEwBX29KKRIrAQKALv7hJ05ITQQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywlj5WaVwXUxDGbLu9nRmCQMNWKmgKMNUJouN/UnGoDTQhfmHRN a/aeOtyVql0d0v3fZlnCqbOwsu1CHxdqvp7MPxxe9RXwJ/f56tJGmIvl X-Gm-Gg: AeBDievjMvsbMfVXSiqRe9JhrOFljhPhZuq9UUxt6gtR56u372S/uhbTpjmv+6OzO+I 3qtrI3i8Hw46I8vo9X3KljxDbg0OinfOfO01D+sO1fk0swVXebAQYAh7zRQolWY/3diqSOlinAT TCV1gGa2gdlqIvEhTfpNNsoU4CIDJN8lQkhV6M1CgQ7nrW6NJjgf7qsmwCpm3eBa562a/asQKS5 RTB9/DadDL2UQ1Yy+wZxCb8C4WklftW6bxuyqt2ztOdo3aeHbtxG319zv7xcpIrk/WEtuV6f2NG xTdF8kVT1/CzLYSqlGpQTl+OcrBf6MOlCWIujvFEwpsp+9rEDa4wvqmyT3slzqDi6F2Mzk3Rcnp SXp3NcVWJTkCWUdYNpDb6IeZ3fsoAx78hUYry2mlBuIpB9VeFjLJe3WQXsnR1hLF7w5YS9Q5Ree ifdR4lBkHMpNjWdkoL9qDPIgdOFECHu6NKNnLgyDPHMhKLlhJ/bSgmnPO5T1ipMRDKOx3c3ug1O Vi/GalHuVDujO9noAjPFSqmT9hoA47mFfHy8h2W3Hf2Mg== X-Received: by 2002:a05:6a00:299a:b0:822:69b2:7ed0 with SMTP id d2e1a72fcca58-8352c3b0cc7mr3848193b3a.6.1777768251973; Sat, 02 May 2026 17:30:51 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-835293f022asm4086305b3a.45.2026.05.02.17.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 17:30:51 -0700 (PDT) From: Rosen Penev To: linux-sound@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCHv2] ASoC: tegra: ADMAIF: allocate with a single kzalloc Date: Sat, 2 May 2026 17:30:37 -0700 Message-ID: <20260503003037.11942-1-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Consolidate the allocations for capture_dma_data and playback_dma_data into a single kzalloc by using a flexible array member at the end of the tegra_admaif struct. This reduces the number of allocations from three to one, simplifies error handling, and improves memory locality. Signed-off-by: Rosen Penev --- v2: place description in the proper place. sound/soc/tegra/tegra210_admaif.c | 28 ++++++++++------------------ sound/soc/tegra/tegra210_admaif.h | 2 +- sound/soc/tegra/tegra_isomgr_bw.c | 1 + 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/sound/soc/tegra/tegra210_admaif.c b/sound/soc/tegra/tegra210_admaif.c index a1c2757a3932..7299c6bfcf15 100644 --- a/sound/soc/tegra/tegra210_admaif.c +++ b/sound/soc/tegra/tegra210_admaif.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "tegra_isomgr_bw.h" @@ -912,35 +913,26 @@ MODULE_DEVICE_TABLE(of, tegra_admaif_of_match); static int tegra_admaif_probe(struct platform_device *pdev) { + const struct tegra_admaif_soc_data *soc_data; struct tegra_admaif *admaif; void __iomem *regs; struct resource *res; + size_t alloc_size; int err, i; - admaif = devm_kzalloc(&pdev->dev, sizeof(*admaif), GFP_KERNEL); + soc_data = of_device_get_match_data(&pdev->dev); + + alloc_size = struct_size(admaif, capture_dma_data, soc_data->num_ch); + alloc_size += sizeof(*admaif->playback_dma_data) * soc_data->num_ch; + admaif = devm_kzalloc(&pdev->dev, alloc_size, GFP_KERNEL); if (!admaif) return -ENOMEM; - admaif->soc_data = of_device_get_match_data(&pdev->dev); + admaif->playback_dma_data = admaif->capture_dma_data + soc_data->num_ch; + admaif->soc_data = soc_data; dev_set_drvdata(&pdev->dev, admaif); - admaif->capture_dma_data = - devm_kcalloc(&pdev->dev, - admaif->soc_data->num_ch, - sizeof(struct snd_dmaengine_dai_dma_data), - GFP_KERNEL); - if (!admaif->capture_dma_data) - return -ENOMEM; - - admaif->playback_dma_data = - devm_kcalloc(&pdev->dev, - admaif->soc_data->num_ch, - sizeof(struct snd_dmaengine_dai_dma_data), - GFP_KERNEL); - if (!admaif->playback_dma_data) - return -ENOMEM; - for (i = 0; i < ADMAIF_PATHS; i++) { admaif->mono_to_stereo[i] = devm_kcalloc(&pdev->dev, admaif->soc_data->num_ch, diff --git a/sound/soc/tegra/tegra210_admaif.h b/sound/soc/tegra/tegra210_admaif.h index 304d45c76a9a..fd9877aa95d3 100644 --- a/sound/soc/tegra/tegra210_admaif.h +++ b/sound/soc/tegra/tegra210_admaif.h @@ -229,13 +229,13 @@ struct tegra_admaif_soc_data { }; struct tegra_admaif { - struct snd_dmaengine_dai_dma_data *capture_dma_data; struct snd_dmaengine_dai_dma_data *playback_dma_data; const struct tegra_admaif_soc_data *soc_data; unsigned int *mono_to_stereo[ADMAIF_PATHS]; unsigned int *stereo_to_mono[ADMAIF_PATHS]; struct regmap *regmap; struct tegra_adma_isomgr *adma_isomgr; + struct snd_dmaengine_dai_dma_data capture_dma_data[]; }; #endif diff --git a/sound/soc/tegra/tegra_isomgr_bw.c b/sound/soc/tegra/tegra_isomgr_bw.c index fa979960bc09..c0f300fb3d38 100644 --- a/sound/soc/tegra/tegra_isomgr_bw.c +++ b/sound/soc/tegra/tegra_isomgr_bw.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include "tegra_isomgr_bw.h" -- 2.54.0