From patchwork Sat Jan 15 01:22:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 12714292 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 40533C433F5 for ; Sat, 15 Jan 2022 01:24:22 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 26DE11A2B; Sat, 15 Jan 2022 02:23:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 26DE11A2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642209860; bh=cyoXQFU5Scs3dE10aZJ6OXBvyY7F1mVGQXXcgvRfM6k=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rbymkHOJK9H6XuSsFfqYb9oWA+XWQIos0zDRgvyiI2QeBWgNhowR6L2V8S78DWLMy Re665P0oN7Rwj/baEf9rqc6cVaHZ5qqMCFCGynIYuNjaDC3kbihxdQhrUIoMJ9Qsy0 7ey+efRoYpgA0548hIYI9IKH6efX1qcQ5/BRaI2U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8FFEAF8030F; Sat, 15 Jan 2022 02:23:29 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2A3A0F8030F; Sat, 15 Jan 2022 02:23:28 +0100 (CET) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id B0854F800CE for ; Sat, 15 Jan 2022 02:23:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B0854F800CE X-IronPort-AV: E=Sophos;i="5.88,290,1635174000"; d="scan'208";a="106547798" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 15 Jan 2022 10:23:17 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id D0001417EAE4; Sat, 15 Jan 2022 10:23:14 +0900 (JST) From: Lad Prabhakar To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Lad Prabhakar , Biju Das Subject: [PATCH v2 1/5] ASoC: sh: rz-ssi: Drop calling rz_ssi_pio_recv() recursively Date: Sat, 15 Jan 2022 01:22:59 +0000 Message-Id: <20220115012303.29651-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Cc: Cezary Rojewski , Pavel Machek , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Instead of recursively calling rz_ssi_pio_recv() use a loop instead to read the samples from RX fifo. Inspiration for this patch is to avoid recursion, as recursion is unwelcome in kernel due to limited stack use. Also to add this driver will later be used on RZ/A2 SoC's which runs with limited memory. This also fixes an issue where the return value of rz_ssi_pio_recv() was ignored when called recursively. Fixes: 03e786bd4341 ("ASoC: sh: Add RZ/G2L SSIF-2 driver") Reported-by: Pavel Machek Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das Reviewed-by: Cezary Rojewski --- v1->v2 * Used a do while loop * Fixed comments pointed by Cezary. --- sound/soc/sh/rz-ssi.c | 65 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index fa0cc08f70ec..637802117c6c 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -414,51 +414,48 @@ static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) u16 *buf; int fifo_samples; int frames_left; - int samples = 0; + int samples; int i; if (!rz_ssi_stream_is_valid(ssi, strm)) return -EINVAL; runtime = substream->runtime; - /* frames left in this period */ - frames_left = runtime->period_size - (strm->buffer_pos % - runtime->period_size); - if (frames_left == 0) - frames_left = runtime->period_size; - /* Samples in RX FIFO */ - fifo_samples = (rz_ssi_reg_readl(ssi, SSIFSR) >> - SSIFSR_RDC_SHIFT) & SSIFSR_RDC_MASK; - - /* Only read full frames at a time */ - while (frames_left && (fifo_samples >= runtime->channels)) { - samples += runtime->channels; - fifo_samples -= runtime->channels; - frames_left--; - } - - /* not enough samples yet */ - if (samples == 0) - return 0; + do { + /* frames left in this period */ + frames_left = runtime->period_size - + (strm->buffer_pos % runtime->period_size); + if (!frames_left) + frames_left = runtime->period_size; + + /* Samples in RX FIFO */ + fifo_samples = (rz_ssi_reg_readl(ssi, SSIFSR) >> + SSIFSR_RDC_SHIFT) & SSIFSR_RDC_MASK; + + /* Only read full frames at a time */ + samples = 0; + while (frames_left && (fifo_samples >= runtime->channels)) { + samples += runtime->channels; + fifo_samples -= runtime->channels; + frames_left--; + } - /* calculate new buffer index */ - buf = (u16 *)(runtime->dma_area); - buf += strm->buffer_pos * runtime->channels; + /* not enough samples yet */ + if (!samples) + break; - /* Note, only supports 16-bit samples */ - for (i = 0; i < samples; i++) - *buf++ = (u16)(rz_ssi_reg_readl(ssi, SSIFRDR) >> 16); + /* calculate new buffer index */ + buf = (u16 *)runtime->dma_area; + buf += strm->buffer_pos * runtime->channels; - rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0); - rz_ssi_pointer_update(strm, samples / runtime->channels); + /* Note, only supports 16-bit samples */ + for (i = 0; i < samples; i++) + *buf++ = (u16)(rz_ssi_reg_readl(ssi, SSIFRDR) >> 16); - /* - * If we finished this period, but there are more samples in - * the RX FIFO, call this function again - */ - if (frames_left == 0 && fifo_samples >= runtime->channels) - rz_ssi_pio_recv(ssi, strm); + rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0); + rz_ssi_pointer_update(strm, samples / runtime->channels); + } while (!frames_left && fifo_samples >= runtime->channels); return 0; } From patchwork Sat Jan 15 01:23:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 12714294 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 1481AC433F5 for ; Sat, 15 Jan 2022 01:25:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D72711F5E; Sat, 15 Jan 2022 02:24:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D72711F5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642209909; bh=KE+1xRVMuiZlLZfJVaybpgvVtxSCq2cVwrqPntT13vE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mEQ6fHsJtLXgNWfvUDKG0UISqHZQRZg/9UlIqLJgEdqc36t1reoyu4KMs6tcUPjQX V+21llW05r8KAlfkLUcO9jB0ZkywatlqKUJDipJqUIRLkoPyzJA8s+l4D5aWvf/oz8 6PZ79g0RYrz68LiZK3nBtH1scUKz7Pofo4GMqAKE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 854A5F80515; Sat, 15 Jan 2022 02:23:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 77BB2F8027C; Sat, 15 Jan 2022 02:23:31 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 02D73F8027C for ; Sat, 15 Jan 2022 02:23:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 02D73F8027C X-IronPort-AV: E=Sophos;i="5.88,290,1635174000"; d="scan'208";a="107116841" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jan 2022 10:23:20 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 37065417EAC6; Sat, 15 Jan 2022 10:23:18 +0900 (JST) From: Lad Prabhakar To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v2 2/5] ASoC: sh: rz-ssi: Make the data structures available before registering the handlers Date: Sat, 15 Jan 2022 01:23:00 +0000 Message-Id: <20220115012303.29651-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Cc: Cezary Rojewski , alsa-devel@alsa-project.org, Pavel Machek , Lad Prabhakar , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Initialize the spinlock and make the data structures available before registering the interrupt handlers. Reported-by: Pavel Machek Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- v1->v2 * No change --- sound/soc/sh/rz-ssi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index 637802117c6c..89428945d48b 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -972,6 +972,9 @@ static int rz_ssi_probe(struct platform_device *pdev) ssi->playback.priv = ssi; ssi->capture.priv = ssi; + spin_lock_init(&ssi->lock); + dev_set_drvdata(&pdev->dev, ssi); + /* Error Interrupt */ ssi->irq_int = platform_get_irq_byname(pdev, "int_req"); if (ssi->irq_int < 0) @@ -1019,8 +1022,6 @@ static int rz_ssi_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_resume_and_get(&pdev->dev); - spin_lock_init(&ssi->lock); - dev_set_drvdata(&pdev->dev, ssi); ret = devm_snd_soc_register_component(&pdev->dev, &rz_ssi_soc_component, rz_ssi_soc_dai, ARRAY_SIZE(rz_ssi_soc_dai)); From patchwork Sat Jan 15 01:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 12714293 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 BCC7DC433F5 for ; Sat, 15 Jan 2022 01:25:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EF4C71FBA; Sat, 15 Jan 2022 02:24:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF4C71FBA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642209899; bh=/5Ua/xSkATE0MmgluOqNKOkwms8PD+hVxfOiPEfK1JQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aJdgKh5Pwn5ms6kBzIbrovMk876HRUQ706WeRjlMCKtshnqCgeFoENdcC4NeJ7w4M nM+h9lXuAlvOLZg9nxYWZDOkLWV4XLB3NZZ/vBvJ8v/GDGhf5asVcWzkaxfH7piohy DUZ1+yut1hIlz0Bcwaj2RTqXhJq3VFMJLUc8CzKI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E9D2FF80507; Sat, 15 Jan 2022 02:23:32 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 731E5F800CE; Sat, 15 Jan 2022 02:23:31 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 54B27F80141 for ; Sat, 15 Jan 2022 02:23:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 54B27F80141 X-IronPort-AV: E=Sophos;i="5.88,290,1635174000"; d="scan'208";a="107116846" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jan 2022 10:23:24 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9B5B5417EAC4; Sat, 15 Jan 2022 10:23:21 +0900 (JST) From: Lad Prabhakar To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v2 3/5] ASoC: sh: rz-ssi: Drop ssi parameter from rz_ssi_stream_init() Date: Sat, 15 Jan 2022 01:23:01 +0000 Message-Id: <20220115012303.29651-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Cc: Cezary Rojewski , alsa-devel@alsa-project.org, Pavel Machek , Lad Prabhakar , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ssi parameter is unused in rz_ssi_stream_init() so just drop it. While at it, change the return type of rz_ssi_stream_init() to void instead of int. Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- v1->v2 * No change --- sound/soc/sh/rz-ssi.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index 89428945d48b..50699e94772b 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -201,9 +201,8 @@ static int rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, return ret; } -static int rz_ssi_stream_init(struct rz_ssi_priv *ssi, - struct rz_ssi_stream *strm, - struct snd_pcm_substream *substream) +static void rz_ssi_stream_init(struct rz_ssi_stream *strm, + struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -219,8 +218,6 @@ static int rz_ssi_stream_init(struct rz_ssi_priv *ssi, /* fifo init */ strm->fifo_sample_size = SSI_FIFO_DEPTH; - - return 0; } static void rz_ssi_stream_quit(struct rz_ssi_priv *ssi, @@ -723,9 +720,7 @@ static int rz_ssi_dai_trigger(struct snd_pcm_substream *substream, int cmd, rz_ssi_reg_mask_setl(ssi, SSIFCR, SSIFCR_SSIRST, 0); udelay(5); - ret = rz_ssi_stream_init(ssi, strm, substream); - if (ret) - goto done; + rz_ssi_stream_init(strm, substream); if (ssi->dma_rt) { bool is_playback; From patchwork Sat Jan 15 01:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 12714295 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 B7F76C433FE for ; Sat, 15 Jan 2022 01:25:14 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EB4772026; Sat, 15 Jan 2022 02:24:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EB4772026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642209912; bh=wF6uXjkDxXmRq6U6p/WnhMqw8MgE506nI4jm/toT8/Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=J+ylRwpjh2d03DgNJtIOEnNacEu5QHMA+ivAnMC2emsQxLsoh98ZBKyqEJ4mO36IJ tWTSLciJk06QesgTbxA+FgHNvzGvQoDPyxps7yNvvY3ubeh4Hu0dzP4PoMjotypnmA tn/+n2VqxN04qlVTyM0AafsxZ9EjVhfOFdAEPPfs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3735AF80517; Sat, 15 Jan 2022 02:23:35 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2DB9AF80511; Sat, 15 Jan 2022 02:23:33 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 2D1CCF8032B for ; Sat, 15 Jan 2022 02:23:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2D1CCF8032B X-IronPort-AV: E=Sophos;i="5.88,290,1635174000"; d="scan'208";a="107116851" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jan 2022 10:23:27 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 052E1417EAC6; Sat, 15 Jan 2022 10:23:24 +0900 (JST) From: Lad Prabhakar To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v2 4/5] ASoC: sh: rz-ssi: Change return type of rz_ssi_stream_is_valid() to bool Date: Sat, 15 Jan 2022 01:23:02 +0000 Message-Id: <20220115012303.29651-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Cc: Cezary Rojewski , alsa-devel@alsa-project.org, Pavel Machek , Lad Prabhakar , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" rz_ssi_stream_is_valid() never returns an int, it returns the result of a condition which is either true or false. While at it, drop "!!" as the expression is boolean. Reported-by: Pavel Machek Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- v1->v2 * No change --- sound/soc/sh/rz-ssi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index 50699e94772b..2da43eecfb3e 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -188,14 +188,14 @@ static inline bool rz_ssi_is_dma_enabled(struct rz_ssi_priv *ssi) return (ssi->playback.dma_ch && (ssi->dma_rt || ssi->capture.dma_ch)); } -static int rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, - struct rz_ssi_stream *strm) +static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, + struct rz_ssi_stream *strm) { unsigned long flags; - int ret; + bool ret; spin_lock_irqsave(&ssi->lock, flags); - ret = !!(strm->substream && strm->substream->runtime); + ret = strm->substream && strm->substream->runtime; spin_unlock_irqrestore(&ssi->lock, flags); return ret; From patchwork Sat Jan 15 01:23:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 12714296 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 2E540C433EF for ; Sat, 15 Jan 2022 01:25:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6DF092051; Sat, 15 Jan 2022 02:24:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6DF092051 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642209942; bh=WC1H1I1T9U2owRoxa9c4TueFytMdUJy5Fwdu3+crg9k=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oOjVbhEoy0WM2YRd868whNoSswlwXYmcSR68QVllKTPbITJg+6hWcbNa7x6D5UGGz 5dJpg8bLWV8NT9DDZYyznE6r5Z1r9mWD6h01jMK2zFuF24deeEiayXiArzquTGqG3i ZsXPFr6g1LfKsIzJ9fqTX3/N/128icPn2jjDzO40= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B451EF80519; Sat, 15 Jan 2022 02:23:36 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27976F80519; Sat, 15 Jan 2022 02:23:35 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 34D4AF8050F for ; Sat, 15 Jan 2022 02:23:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 34D4AF8050F X-IronPort-AV: E=Sophos;i="5.88,290,1635174000"; d="scan'208";a="107116855" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jan 2022 10:23:30 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6473D417EAC4; Sat, 15 Jan 2022 10:23:28 +0900 (JST) From: Lad Prabhakar To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Subject: [PATCH v2 5/5] ASoC: sh: rz-ssi: Add rz_ssi_set_substream() helper function Date: Sat, 15 Jan 2022 01:23:03 +0000 Message-Id: <20220115012303.29651-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Cc: Cezary Rojewski , alsa-devel@alsa-project.org, Pavel Machek , Lad Prabhakar , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" A copy of substream pointer is stored in priv structure during rz_ssi_dai_trigger() callback ie in SNDRV_PCM_TRIGGER_START case and the pointer is assigned to NULL in case of SNDRV_PCM_TRIGGER_STOP. The driver used the locks only in rz_ssi_stream_is_valid() and assigned the local substream pointer to NULL in rz_ssi_dai_trigger() callback but never locked it while making a local copy. This patch adds the rz_ssi_set_substream() helper function to set the substream pointer with locks acquired and replaces the instances of setting the local substream pointer with the rz_ssi_set_substream() function. Reported-by: Pavel Machek Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- v1->v2 * Dropped rz_ssi_get_substream() helper. --- sound/soc/sh/rz-ssi.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index 2da43eecfb3e..07fdbcfa5b63 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -188,6 +188,17 @@ static inline bool rz_ssi_is_dma_enabled(struct rz_ssi_priv *ssi) return (ssi->playback.dma_ch && (ssi->dma_rt || ssi->capture.dma_ch)); } +static void rz_ssi_set_substream(struct rz_ssi_stream *strm, + struct snd_pcm_substream *substream) +{ + struct rz_ssi_priv *ssi = strm->priv; + unsigned long flags; + + spin_lock_irqsave(&ssi->lock, flags); + strm->substream = substream; + spin_unlock_irqrestore(&ssi->lock, flags); +} + static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) { @@ -206,7 +217,7 @@ static void rz_ssi_stream_init(struct rz_ssi_stream *strm, { struct snd_pcm_runtime *runtime = substream->runtime; - strm->substream = substream; + rz_ssi_set_substream(strm, substream); strm->sample_width = samples_to_bytes(runtime, 1); strm->dma_buffer_pos = 0; strm->period_counter = 0; @@ -224,11 +235,8 @@ static void rz_ssi_stream_quit(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) { struct snd_soc_dai *dai = rz_ssi_get_dai(strm->substream); - unsigned long flags; - spin_lock_irqsave(&ssi->lock, flags); - strm->substream = NULL; - spin_unlock_irqrestore(&ssi->lock, flags); + rz_ssi_set_substream(strm, NULL); if (strm->oerr_num > 0) dev_info(dai->dev, "overrun = %d\n", strm->oerr_num);