From patchwork Fri Apr 26 15:29:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13645001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28AD8C19F4F for ; Fri, 26 Apr 2024 15:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4KJPwxD74L8inYP5ugwxoBDMiols3D1ru5eCRYJsfKI=; b=SFBwVgFR6dTOoh EHy5UGrQWYgDc3ZV5vK7xnGFoYnS1epW1/z4KcPJ+mfzpTIypLyUAUVOfRJ9IPP1cuHioaOZTgToM 3uMNRtEHYQSGIzakw4woIqw1kU2Q3pPA8WwVev9PIcDmyUGGmEIsMP1xPHix+gv8haS/ZGaZc6JZU z1fNKzTjyrPAEGwo6HaYtB2m0fHVR+V2c2uGyRFxWFitY6KyCAEozTDv8ydPU5HpduSWpJSlHVg/t fvZ6bmYpHACz4YRgiSmXz+5yoS9AIxLR9qAv2SoobKFs/FiSx8JsF6SjksJyL8yuBoZg28oAVxXtg UCrOFJk+J7OXOjRqj6GA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWU-0000000D3H8-3182; Fri, 26 Apr 2024 15:30:02 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWQ-0000000D3CY-2cdN for linux-amlogic@lists.infradead.org; Fri, 26 Apr 2024 15:30:00 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41b5dd5af48so12890385e9.0 for ; Fri, 26 Apr 2024 08:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714145396; x=1714750196; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wdxkC9xy0JdUlM4HJdidG8uU38VPySKk64XDlad2PLg=; b=idoxkQdjOKqxH8EofiH1tOI6TGW6m0s9hgVRrgpKnSZD9xm0V4E4Q0OKesC0Cbsvfn GXlVxZQtjAng6cxqCk53SR2VJ4gwpK/xLfFUUO/7sP80ovGf8KjNRLCiAimqVs7jXVxa EkmMEPjvabSLEzns75Crlc04l7Exu+Dtl8VUE9ygW0sV//6SknqHm42SuS/MNNFd8LCp Dl2YGQKyz/gQv55Qdnogex7BsPJ6Y3hTECCcJtIT2MpD9PZ3GP6YADOl58lAveIEoYNp A7xh+N3I6O0+Oi+Q+UUs6vLBDftgBy9q1BhKk/BlzQdhLU+wjk/Vf/VL+QcAeCNNVmY8 WGyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714145396; x=1714750196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wdxkC9xy0JdUlM4HJdidG8uU38VPySKk64XDlad2PLg=; b=mN+KUUKhZUiGs+4Fyn3YtqqToCZDBO+U6xqAoie7QFxPyFZYqthTHjTr8h7EdyN3iz 3B1BA1boeKBh45KEYFamj9pNs4KQC/GK3n6QuceQg3rhyFoWkc9TlPyID87UbmKU5dME 9QycQ53SKsy50hvygq01+No3o7YcO53h3fqydFpOd2OruvS44oAlEPucBoj8AtUQteWK ollTQreauKnhK5Wxm8UIg/WPHtykgq5D09uB7zZijxgDtRahQ3+J9wQ7XnwhXRCYNYxM zbLZPd3bwXLJY/IaQUYWblofC+ZQD1jhmd+thM1fVocNQOZBFHAbZffL0GZbENtvS3wS EvXw== X-Forwarded-Encrypted: i=1; AJvYcCWFgpci9J5ffgsHJEsyDWZ8Vm4vcU70LEjmT4vmqeaJUz7B9sJKYrMTBSIiUoqajuKzaI1Vj3nPOdS6h5+QRc2rwEt/6sPR6eX6RirolhG52VI= X-Gm-Message-State: AOJu0YyXtjfIfjDG/TgkJWSFIXuBP4AXmSgEW3mZujxvIEq6d+HbNG7S N7bGRlfoA5vcyT+1y17/vi/EYpMTyAtHbPvxyg6AIyzYzJkyD/2gUzxmVF5isJZOtkXwixmp5Yj 4 X-Google-Smtp-Source: AGHT+IHPpBP3QSa57mdn7C6mGnSnPPrJ1b15kSZTPSoFNzWhfVV6qwoJcqsNBhnR4twzoAilz89DKA== X-Received: by 2002:a05:600c:4ecf:b0:416:bc18:2a00 with SMTP id g15-20020a05600c4ecf00b00416bc182a00mr2136057wmq.38.1714145395834; Fri, 26 Apr 2024 08:29:55 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1926:f73e:8b99:1c0a]) by smtp.googlemail.com with ESMTPSA id i13-20020a05600c354d00b00419fba938d8sm22628687wmq.27.2024.04.26.08.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:29:55 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 1/4] ASoC: meson: axg-fifo: use threaded irq to check periods Date: Fri, 26 Apr 2024 17:29:38 +0200 Message-ID: <20240426152946.3078805-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426152946.3078805-1-jbrunet@baylibre.com> References: <20240426152946.3078805-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_082958_699711_D6A48AFD X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org With the AXG audio subsystem, there is a possible random channel shift on TDM capture, when the slot number per lane is more than 2, and there is more than one lane used. The problem has been there since the introduction of the axg audio support but such scenario is pretty uncommon. This is why there is no loud complains about the problem. Solving the problem require to make the links non-atomic and use the trigger() callback to start FEs and BEs in the appropriate order. This was tried in the past and reverted because it caused the block irq to sleep while atomic. However, instead of reverting, the solution is to call snd_pcm_period_elapsed() in a non atomic context. Use the bottom half of a threaded IRQ to do so. Fixes: 6dc4fa179fb8 ("ASoC: meson: add axg fifo base driver") Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-fifo.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c index bebee0ca8e38..ecb3eb7a9723 100644 --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c @@ -204,18 +204,26 @@ static irqreturn_t axg_fifo_pcm_irq_block(int irq, void *dev_id) unsigned int status; regmap_read(fifo->map, FIFO_STATUS1, &status); - status = FIELD_GET(STATUS1_INT_STS, status); + axg_fifo_ack_irq(fifo, status); + + /* Use the thread to call period elapsed on nonatomic links */ if (status & FIFO_INT_COUNT_REPEAT) - snd_pcm_period_elapsed(ss); - else - dev_dbg(axg_fifo_dev(ss), "unexpected irq - STS 0x%02x\n", - status); + return IRQ_WAKE_THREAD; - /* Ack irqs */ - axg_fifo_ack_irq(fifo, status); + dev_dbg(axg_fifo_dev(ss), "unexpected irq - STS 0x%02x\n", + status); + + return IRQ_NONE; +} + +static irqreturn_t axg_fifo_pcm_irq_block_thread(int irq, void *dev_id) +{ + struct snd_pcm_substream *ss = dev_id; + + snd_pcm_period_elapsed(ss); - return IRQ_RETVAL(status); + return IRQ_HANDLED; } int axg_fifo_pcm_open(struct snd_soc_component *component, @@ -243,8 +251,9 @@ int axg_fifo_pcm_open(struct snd_soc_component *component, if (ret) return ret; - ret = request_irq(fifo->irq, axg_fifo_pcm_irq_block, 0, - dev_name(dev), ss); + ret = request_threaded_irq(fifo->irq, axg_fifo_pcm_irq_block, + axg_fifo_pcm_irq_block_thread, + IRQF_ONESHOT, dev_name(dev), ss); if (ret) return ret; From patchwork Fri Apr 26 15:29:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13645004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE6D6C04FFE for ; Fri, 26 Apr 2024 15:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KcLoz/asyGJ2yUhKocn7VwrkBO9WmGYJ2c8NNvmBbZ8=; b=Xf81pmzjsy4jHT 9qS6udSDVBfJaxIo4f8t6TVLHQx2j2P3OxtO/g+Aira/geJr0AM4Y2hWGs5YPnZGcDkfSotN1EIaj tz9gANeScqUaZiJaRjWKd6e0RR8pb+FsltJNR2ccQbXR7Xpkf2b355/6ZK7ADH4LxJy7JVH/g/p2R ljKNkQd6z84/5u9DNrdKt48kxQLB3znHVaKWJ8zPgEhjfC0REeuwrRyFIl4ASC7eiDiotUt8DtWFj 3BtUQhopiBjxfltV+uNveaNwvBR/tfYT9daJ+uXADZS5MO+4InOrsx1EqfuTGWfEUsttWgeB5lc/1 cvmHNIuO1u53EwPxJVmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWV-0000000D3HI-0l7b; Fri, 26 Apr 2024 15:30:03 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWQ-0000000D3Cr-2cTx for linux-amlogic@lists.infradead.org; Fri, 26 Apr 2024 15:30:00 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41b79451145so8326485e9.3 for ; Fri, 26 Apr 2024 08:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714145396; x=1714750196; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vj88fGfTuV4/ceY0CRDNjfucEqH3NJ0Iz+8z4tgOcCE=; b=XgRgQepP+exdRu6Fzy9ZuGsdsLWS6JASKMF7pati5RkADOtfT6qe5pga7prR3nzWdn cJmQ/lrcs12v0hoFSqf6vNJ5g1w7fLP+4B49QcWjdac/KJHSHzRAIBWrywjopd1eFFQ8 9hj8f7rQz3QefZv2r+l5lc2BOs3/jQYIuhh7e2COJ2wlx6dHQ5TwyUxrpJFnzX28zuZH R4eA4IaASIElBTsYpy54nlprfui4wGKvGv9uqRogrfPdCME7LL6yiHJ7w8EvTNzHmqQi orxN0gkOJXjD9x97SWtmsw6shRzk8HOpxDzwkr2z4LKX/K3Ss0B6+dET8dlSkhYpS+9U AIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714145396; x=1714750196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vj88fGfTuV4/ceY0CRDNjfucEqH3NJ0Iz+8z4tgOcCE=; b=uC3qxICzejCs+2zuJXnLP6rIRghvGcMK+60GYoOXdSzLYCOjLzjMBqP2Wh4CT3KymO OlCJt+Y4PcExD3x8VmlDjG8R3l28DjGFJ4eQiCA+o4gZEOO5mFGyUClIsO3t61PVWafR QRe2ugUxDkHAZUbovqibplxWB23pPNtKvjssuAhl6w7wGPrMbxCptgq4jpxdazl2uloq TbgxsQADhhNEzsGLg8NjnBBWGZ9RBTcm0yuZEJxacmScuQx630hh/f1IDB3eCQwRd1UO ifwDQHNNp6euKhKtaUV7pgPb+4+FvKRpqBzB8l2X6oDjykAFlwAbwjQrkIzRavZq/Asa P86w== X-Forwarded-Encrypted: i=1; AJvYcCWUsCJvEmM88onK/yl2HN2/ounQgYFmAIL6ENzF4Djk0atggKBvcPB6GYcl9JNiA/sB4JqkS+2WSxojTrKA9WNvEr1pWv5BAl0cqu9NMpTM+sU= X-Gm-Message-State: AOJu0Yx1J3S13u2iLX4aIYG1Izgj8Tx+QB9M78NhLxFia5Yzy0yeKk4K I/fb0ofOY8RACFRQ/OHQq/I0cfpaLADF6l4s4veinS2IVEPziBiklh1no3NDye4= X-Google-Smtp-Source: AGHT+IEJkZy/zcyYjS/mRx4ZV80tXFjeoyE7of0nB7BlzZ+4FKV/1yBAljbeQBu73IdnjR2X5uGAvA== X-Received: by 2002:a05:600c:b88:b0:418:f991:8ad4 with SMTP id fl8-20020a05600c0b8800b00418f9918ad4mr113607wmb.6.1714145396564; Fri, 26 Apr 2024 08:29:56 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1926:f73e:8b99:1c0a]) by smtp.googlemail.com with ESMTPSA id i13-20020a05600c354d00b00419fba938d8sm22628687wmq.27.2024.04.26.08.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:29:56 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 2/4] ASoC: meson: axg-card: make links nonatomic Date: Fri, 26 Apr 2024 17:29:39 +0200 Message-ID: <20240426152946.3078805-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426152946.3078805-1-jbrunet@baylibre.com> References: <20240426152946.3078805-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_082958_701772_1A88DFFF X-CRM114-Status: UNSURE ( 9.00 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Non atomic operations need to be performed in the trigger callback of the TDM interfaces. Those are BEs but what matters is the nonatomic flag of the FE in the DPCM context. Just set nonatomic for everything so, at least, what is done is clear. Fixes: 7864a79f37b5 ("ASoC: meson: add axg sound card support") Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-card.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c index 3180aa4d3a15..8c5605c1e34e 100644 --- a/sound/soc/meson/axg-card.c +++ b/sound/soc/meson/axg-card.c @@ -318,6 +318,7 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np, dai_link->cpus = cpu; dai_link->num_cpus = 1; + dai_link->nonatomic = true; ret = meson_card_parse_dai(card, np, dai_link->cpus); if (ret) From patchwork Fri Apr 26 15:29:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13645002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42537C25B4F for ; Fri, 26 Apr 2024 15:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dGTqJmhxkTcHGyZbviMLkPYXBgymD2JUsa1/tCCMPxQ=; b=vcOwoDfYQuTL6t GPRvPFaloYzB2qW/dAWWBWFa5CA9WcrzjGkWKGMM1jygX6EcCydNpd2Rayk1AI+qUnRwbfXeDPK1C gAyjwODNl/S5PgvcWttHRlRJcCDt2zYrviE1QYU1npSAFOh6bVyZ/CsrjwkGEigBKVOie+rwFWhk5 nVKAf4CAsaPcTv0qDZMl0HLezAvR0zqp4rLxNGM1r2M9UmU8h7YEotPGEmLy+ZN750KTVrQV15g+q gnh3EWFaJlss9YSLBYfXwAPeaif6/HhDk5pXUepkG5ud9r6LtcZI5bbCDroH2eGXKcuz8L40oBajG GObH8Wdv9hZl7tMxBdnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWX-0000000D3Ih-3VSz; Fri, 26 Apr 2024 15:30:05 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWS-0000000D3DH-3Uz3 for linux-amlogic@lists.infradead.org; Fri, 26 Apr 2024 15:30:03 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41b4ff362a8so16820415e9.0 for ; Fri, 26 Apr 2024 08:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714145397; x=1714750197; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LQ4CJQsXVTR1thlbAzx7uixAygG90ZyA723vL1wPyc4=; b=Epp28Cs+FD2svqEE6CKpTs2sOq/GTs+ZD6YSBVu517S8T8f/1FieQWk5uyTSvLvONf x6CFFxBHQ/LsqsZvFMld8ZnSDvCbS1CaF3kOLFKy3PPXSHvhO/lxneCf32ko74D6WhXx xMmJ+9R7Di8BqeaKtV/7KPKLr+gR1Ja2eCASSszb0GhWaoK0X840riaDaXsz78sRgO53 w92SOUtSmSRk0I+Z5ZpMmRPzZlCx9MQrXipXOyD7qiiiG0+F/UN4fECapua2n73Pl4R2 z/mTs8gwA+DL9c1+Un9IKPj/Ss8YRFhb0p4xSVcV9/RhrUQYIkRthRDXzfm3cPAkFWce ukjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714145397; x=1714750197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LQ4CJQsXVTR1thlbAzx7uixAygG90ZyA723vL1wPyc4=; b=gdNlkmvrgtduPY7MKLn2AizwcBz7EFdGC+Qcl1P/fhXIyrCIfLn4nS/MOQusbcx98C YAPfHWY7tRqffwxiICjlUFW6YWFMTU20aIQrpap1dxdYjnLJZ0gtxp36CtL+KAtxG0fB IG8jyjn/HuAdJAHPIb5/cIb+VeUiocMVReeijRYWqPVxmZeLbQNuPX/UwHiyGT6j33u7 5F9NWQReiuhEuoAgEuIDdg7lsN63AeatpFn6bWnwfc2m0cn9YKj5oeSAZNExU8kteHUd /0GxGEOw+80RvsHBfrlgGncqR7AhyW9wKvqNoJSrukjTqf3xzQPK82A9MZiwmog4+o/R njXA== X-Forwarded-Encrypted: i=1; AJvYcCW7d9SmJWqMpWWHGDDDy2UcoAdmQoAAl5GcEjHS/z8Fp30fCYkh8ebIFT9OZTtOQQZCdNpgauGPqg+aL5WAcnA9uVJtLrose6OAnnHtso5WRYE= X-Gm-Message-State: AOJu0YzKYqHwkBtaYEX5y4o9B+3DmPz0gVWxSyMm985EYFE4rnMRjfxy tJPK36SFRXLtV158NqrytvboLXwiDw2cZNwzZlWsVGePZXefvS8C3eoTDdr9rhY= X-Google-Smtp-Source: AGHT+IH1/5s5CRPWdPZqkFw1JsMyITFCO5/+y/SMhOfip3B1nJoETVweJYnD+9vnKbqKCb2dr/aCkw== X-Received: by 2002:a05:600c:4508:b0:418:37e1:3f73 with SMTP id t8-20020a05600c450800b0041837e13f73mr3024524wmo.2.1714145397352; Fri, 26 Apr 2024 08:29:57 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1926:f73e:8b99:1c0a]) by smtp.googlemail.com with ESMTPSA id i13-20020a05600c354d00b00419fba938d8sm22628687wmq.27.2024.04.26.08.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:29:56 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 3/4] ASoC: meson: axg-tdm-interface: manage formatters in trigger Date: Fri, 26 Apr 2024 17:29:40 +0200 Message-ID: <20240426152946.3078805-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426152946.3078805-1-jbrunet@baylibre.com> References: <20240426152946.3078805-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_083000_976544_B65F1D14 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org So far, the formatters have been reset/enabled using the .prepare() callback. This was done in this callback because walking the formatters use a mutex. A mutex is used because formatter handling require dealing possibly slow clock operation. With the support of non-atomic, .trigger() callback may be used which also allows to properly enable and disable formatters on start but also pause/resume. This solve a random shift on TDMIN as well repeated samples on for TDMOUT. Fixes: d60e4f1e4be5 ("ASoC: meson: add tdm interface driver") Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-tdm-interface.c | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c index bf708717635b..8bf3735dedaa 100644 --- a/sound/soc/meson/axg-tdm-interface.c +++ b/sound/soc/meson/axg-tdm-interface.c @@ -349,26 +349,31 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream, return 0; } -static int axg_tdm_iface_hw_free(struct snd_pcm_substream *substream, +static int axg_tdm_iface_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) { - struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream); + struct axg_tdm_stream *ts = + snd_soc_dai_get_dma_data(dai, substream); - /* Stop all attached formatters */ - axg_tdm_stream_stop(ts); + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + axg_tdm_stream_start(ts); + break; + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_STOP: + axg_tdm_stream_stop(ts); + break; + default: + return -EINVAL; + } return 0; } -static int axg_tdm_iface_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream); - - /* Force all attached formatters to update */ - return axg_tdm_stream_reset(ts); -} - static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai) { int stream; @@ -412,8 +417,7 @@ static const struct snd_soc_dai_ops axg_tdm_iface_ops = { .set_fmt = axg_tdm_iface_set_fmt, .startup = axg_tdm_iface_startup, .hw_params = axg_tdm_iface_hw_params, - .prepare = axg_tdm_iface_prepare, - .hw_free = axg_tdm_iface_hw_free, + .trigger = axg_tdm_iface_trigger, }; /* TDM Backend DAIs */ From patchwork Fri Apr 26 15:29:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13645003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 575C2C25B5E for ; Fri, 26 Apr 2024 15:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FBxp2Ojj1CLP8vMQMd1yPtWVqEkVyp1j8RfpejtjXVI=; b=YhVvxovoedg1PT y111KdIUafJNF0G0SEVWgPJaUUX9iYa1iNueFD091mW5wkv7ie2OjNqBF/yrWOyS7cEwQVuKMI/AU z0i4fPyEDoYJDXF4k2TI6Cl+YbZIRaF+boCStsX2E1/FyRR4nOlQi2WzLLeLGSATFMhp5ceMhr3R4 OXt4vbSkdkdz8zp2gA1kfJ0HtYuz9fk0cGN6PDXYvb5clca4ikaq4XR7b4WAL8/bU/77FCCPtsW2R lgQykzZYzA75UwUZmOPd0pi6+iocpdrie+7Vp07T5w3F/UYWl5ZErtj3o8BXki/KY7OBloEPw+8O4 wCJpDyYbgg95s/naB+VQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWX-0000000D3IM-19yj; Fri, 26 Apr 2024 15:30:05 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0NWR-0000000D3Do-23WY for linux-amlogic@lists.infradead.org; Fri, 26 Apr 2024 15:30:02 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-41bab13ca80so2785215e9.0 for ; Fri, 26 Apr 2024 08:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714145398; x=1714750198; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4bQrmumSWoqJQMi/l6xj2yc8RNYXdlpvWVWdoITuaG8=; b=q4Y5Khf1pKoaXG8M+O0hUP3XUTJd4MhbC77hqOxMtYCsrUCbqfMBzfUEbJtpxLr5bo c2D9O8x4bQZpRI2sENcuURf3SrXwjQXbmxxUOvEEyg1QkxlpVIwaVxxATBzLejs0bl3r inTzAx4CqyTMRXbMBafGfRKzCPhUhK2L/KzxGkb7cdgM00/WcpQTlmqDh1XTtImVjJfN d7xrVK59AvoC2VM7dANSnynHRfHvP1/1wBScsYVDlZlCrVgDFIB6pd9OxOIrmfSfVLlQ +FP9YZi22DPfGxaLEMoirzAC4zOrsQLuDtIG2xzcDw063SIbQRLmxX9MQGB7EA2RfYyN rZIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714145398; x=1714750198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4bQrmumSWoqJQMi/l6xj2yc8RNYXdlpvWVWdoITuaG8=; b=BQlXTykAod0/AITt5Slpke8U6bfKbcw8TiYx3cy7t/dw/R48JqzdAZbF1FNzP5fzOP RQdq3GHYzj9vc5HTmydOKnkZ3S+QHP8dZqWnbE3MeHYfnv1vDy80lALkiG3mK2wBjinS ebM/IgEST7gwNBIYXDBCzB86lXVoUd8rPG8s12bw5qN3bH0wmEgZqIIKaqHLvh02u9fg 3c2/6nupTgGRiNd5tD5pQXFIPiiigwjG5JDg8UsgEj0kkyaCYphLVtCjiiph4ffWuAFc /TsaRFVYF/tPfefJW4lxOjocuJF02jCY8AtPIWr1LRupeadFdH/awAV2mRyliE2l1nwQ rQ8w== X-Forwarded-Encrypted: i=1; AJvYcCVM6iXCuSLxETOTPOeu5HGOxFM2IlodRTLE9opdWk3SBM113Qwq3lfXslEcGmW6FljpaZZA5HaghKwlhamVk7rKujot6xzTBiNxlVbUQ3FfJyk= X-Gm-Message-State: AOJu0YySIBGTYk9uA3tPJxwszYlC42zDtOlELTbc8anaE5CebI+sv6zF FlF5fcI/R2gzccmJSGSoHIm1EVuAl1sHm/NZSh8eaOwtcgnEsen0OAU0QDdOuhM= X-Google-Smtp-Source: AGHT+IHMerJdt74ThT9W2AwuFt/nqHhB935A349L3A9erdfLScSRYmjfvTF+QLgGqsuEAmQiV3l5MA== X-Received: by 2002:a05:600c:4f11:b0:419:87ab:f6db with SMTP id l17-20020a05600c4f1100b0041987abf6dbmr2369314wmq.23.1714145398045; Fri, 26 Apr 2024 08:29:58 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1926:f73e:8b99:1c0a]) by smtp.googlemail.com with ESMTPSA id i13-20020a05600c354d00b00419fba938d8sm22628687wmq.27.2024.04.26.08.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:29:57 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 4/4] ASoC: meson: axg-tdm: add continuous clock support Date: Fri, 26 Apr 2024 17:29:41 +0200 Message-ID: <20240426152946.3078805-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426152946.3078805-1-jbrunet@baylibre.com> References: <20240426152946.3078805-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_082959_690843_8B21BCFB X-CRM114-Status: GOOD ( 15.92 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Some devices may need the clocks running, even while paused. Add support for this use case. Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-tdm-formatter.c | 40 +++++++++++++++++++++++++++++ sound/soc/meson/axg-tdm-interface.c | 16 +++++++++++- sound/soc/meson/axg-tdm.h | 5 ++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c index 63333a2b0a9c..a6579efd3775 100644 --- a/sound/soc/meson/axg-tdm-formatter.c +++ b/sound/soc/meson/axg-tdm-formatter.c @@ -392,6 +392,46 @@ void axg_tdm_stream_free(struct axg_tdm_stream *ts) } EXPORT_SYMBOL_GPL(axg_tdm_stream_free); +int axg_tdm_stream_set_cont_clocks(struct axg_tdm_stream *ts, + unsigned int fmt) +{ + int ret = 0; + + if (fmt & SND_SOC_DAIFMT_CONT) { + /* Clock are already enabled - skipping */ + if (ts->clk_enabled) + return 0; + + ret = clk_prepare_enable(ts->iface->mclk); + if (ret) + return ret; + + ret = clk_prepare_enable(ts->iface->sclk); + if (ret) + goto err_sclk; + + ret = clk_prepare_enable(ts->iface->lrclk); + if (ret) + goto err_lrclk; + + ts->clk_enabled = true; + return 0; + } + + /* Clocks are already disabled - skipping */ + if (!ts->clk_enabled) + return 0; + + clk_disable_unprepare(ts->iface->lrclk); +err_lrclk: + clk_disable_unprepare(ts->iface->sclk); +err_sclk: + clk_disable_unprepare(ts->iface->mclk); + ts->clk_enabled = false; + return ret; +} +EXPORT_SYMBOL_GPL(axg_tdm_stream_set_cont_clocks); + MODULE_DESCRIPTION("Amlogic AXG TDM formatter driver"); MODULE_AUTHOR("Jerome Brunet "); MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c index 8bf3735dedaa..62057c71f742 100644 --- a/sound/soc/meson/axg-tdm-interface.c +++ b/sound/soc/meson/axg-tdm-interface.c @@ -309,6 +309,7 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai); + struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream); int ret; switch (iface->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -346,7 +347,19 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream, return ret; } - return 0; + ret = axg_tdm_stream_set_cont_clocks(ts, iface->fmt); + if (ret) + dev_err(dai->dev, "failed to apply continuous clock setting\n"); + + return ret; +} + +static int axg_tdm_iface_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream); + + return axg_tdm_stream_set_cont_clocks(ts, 0); } static int axg_tdm_iface_trigger(struct snd_pcm_substream *substream, @@ -417,6 +430,7 @@ static const struct snd_soc_dai_ops axg_tdm_iface_ops = { .set_fmt = axg_tdm_iface_set_fmt, .startup = axg_tdm_iface_startup, .hw_params = axg_tdm_iface_hw_params, + .hw_free = axg_tdm_iface_hw_free, .trigger = axg_tdm_iface_trigger, }; diff --git a/sound/soc/meson/axg-tdm.h b/sound/soc/meson/axg-tdm.h index 42f7470b9a7f..daaca10fec9e 100644 --- a/sound/soc/meson/axg-tdm.h +++ b/sound/soc/meson/axg-tdm.h @@ -58,12 +58,17 @@ struct axg_tdm_stream { unsigned int physical_width; u32 *mask; bool ready; + + /* For continuous clock tracking */ + bool clk_enabled; }; struct axg_tdm_stream *axg_tdm_stream_alloc(struct axg_tdm_iface *iface); void axg_tdm_stream_free(struct axg_tdm_stream *ts); int axg_tdm_stream_start(struct axg_tdm_stream *ts); void axg_tdm_stream_stop(struct axg_tdm_stream *ts); +int axg_tdm_stream_set_cont_clocks(struct axg_tdm_stream *ts, + unsigned int fmt); static inline int axg_tdm_stream_reset(struct axg_tdm_stream *ts) {