From patchwork Mon Sep 3 20:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Cvek X-Patchwork-Id: 10586359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 903835A4 for ; Mon, 3 Sep 2018 20:25:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E7DE29323 for ; Mon, 3 Sep 2018 20:25:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 720EF29328; Mon, 3 Sep 2018 20:25:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FB6229323 for ; Mon, 3 Sep 2018 20:25:31 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7651A267668; Mon, 3 Sep 2018 22:25:27 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 728402676D5; Mon, 3 Sep 2018 22:25:25 +0200 (CEST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by alsa0.perex.cz (Postfix) with ESMTP id 13F7E2673F4 for ; Mon, 3 Sep 2018 22:25:22 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id k5-v6so1720963wre.10 for ; Mon, 03 Sep 2018 13:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GvbRZGDMbummQAcywlyELDB3jq5uEM325z25XKdUN08=; b=P8NyYjbzSzU8F+5hdNjbwtm1sccLTcyfQlH3NnKs+gHgVzJkacjQZyjQ+rEVsfUyuP O6TBXMx8Mb13xdh8rNBHxbzaqwjUqYImMMuq7EW6MmFDu3ESbuw3Qu/2XcrUBcxblZwo izoDw9ZDDfZ/K6/Fn/hZtxvJP+RzgNvu0yb0MOX01pDoAAnTN8GwhEHWIGqo/76uTqYi 8wLk1CkaVj2a9Vk92eOxyrbsg37OzmQnamJhBErqwTQRORnmSOCCrTE1vlJ9IUAczcKH qFkW+WmvwPWOjtW8zyOTd2k/GOgkTAKSTPuwRpMSQj2f6G1bADnz69DwN5/EN2BH5c6s 0TvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GvbRZGDMbummQAcywlyELDB3jq5uEM325z25XKdUN08=; b=bQHp0kNg3bTvfaZAp64/FxP5rLgQwMoykip94nXm0HvqiLaoeiQnWhYTNsLJotcLo5 Lz9Runn49UXoHKLrEpMsuiP/h5Ig93gXU+YRON/VV+Z/GJ8Z5JoHTM5JON1GazqE4FNH rW8G5JmQfSEE6jMCxBdGwKZujE5y/bWHll3MfmE7/oM29qg/XyvHOU6P4fuZwm8CkZhO XWwiia0XxyRo751pL69sQNk4ozbxdWO+JpU6dC7GjdnvBj9pA4AvnxBoFVCu8Uk/PdII KiH6VotV3ejKNroD9bissLANM+YYqBAZxDqcWR8KHUj5Lp0iULLxVgcCzlRx/daCDOBo YvVA== X-Gm-Message-State: APzg51D+C+DrUuVjdXF71s3IcZoVFRJzhdXH0Zg85LZhqZnDDTkNHSi5 +m0/t6SCi0AtgYnNBvKubMw= X-Google-Smtp-Source: ANB0VdZ/qXLK9rjraovA1BZFPmbSx6M+QTU7jiMktpLHS8pcJkK1R68jxx0ISPQsNmXfRHl/3XuAag== X-Received: by 2002:a5d:4a44:: with SMTP id v4-v6mr20160621wrs.278.1536006322534; Mon, 03 Sep 2018 13:25:22 -0700 (PDT) Received: from kontron.lan ([2001:1ae9:ff1:f191:9d19:a27b:b87:e103]) by smtp.gmail.com with ESMTPSA id 124-v6sm19525317wmk.20.2018.09.03.13.25.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:25:21 -0700 (PDT) From: petrcvekcz@gmail.com X-Google-Original-From: petrcvekcz.gmail.com To: daniel@zonque.org, haojian.zhuang@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, marek.vasut@gmail.com Date: Mon, 3 Sep 2018 22:25:01 +0200 Message-Id: <5110d62c9a1d266da0675cd11f196adad4b12cec.1536006242.git.petrcvekcz@gmail.com> X-Mailer: git-send-email 2.18.0 Cc: alsa-devel@alsa-project.org, dbaryshkov@gmail.com, Petr Cvek , dirk@opfer-online.de, zhouqiao@marvell.com, philipp.zabel@gmail.com, lost.distance@yahoo.com, robert.jarzmik@free.fr Subject: [alsa-devel] [PATCH] ASoC: pxa: remove duplicated snd_soc_component_driver ops X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Petr Cvek The sound soc drivers which are using a platform driver pxa-pcm-audio and cpu dai drivers from the pxa tree have defined pxa2xx_soc_pcm_new() twice. The function will get called in soc_new_pcm() for two components (platform and cpu dai) which causes a double allocation of DMA resources and later during a close of the playback/capture a kernel warning: WARNING: CPU: 0 PID: 892 at drivers/dma/dmaengine.c:788 dma_release_channel+0x44/0xa0 chan reference count 0 != 1 Modules linked in: snd_soc_magician snd_soc_pxa2xx snd_pxa2xx_lib ... CPU: 0 PID: 892 Comm: aplay Tainted: G C 4.18.0-rc6-next-20180726-magician+ #16 Hardware name: HTC Magician [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (__warn+0xd4/0xec) [] (__warn) from [] (warn_slowpath_fmt+0x44/0x6c) [] (warn_slowpath_fmt) from [] (dma_release_channel+0x44/0xa0) [] (dma_release_channel) from [] (snd_dmaengine_pcm_close_release_chan+0x44/0xb1c [snd_pcm_dmaengine]) [] (snd_dmaengine_pcm_close_release_chan [snd_pcm_dmaengine]) from [] (soc_pcm_components_close+0x8c/0xac [snd_soc_core]) [] (soc_pcm_components_close [snd_soc_core]) from [] (soc_pcm_close+0xe4/0xd44 [snd_soc_core]) [] (soc_pcm_close [snd_soc_core]) from [] (snd_pcm_release_substream+0x88/0x108 [snd_pcm]) [] (snd_pcm_release_substream [snd_pcm]) from [] (snd_pcm_release+0x5c/0xd2c [snd_pcm]) [] (snd_pcm_release [snd_pcm]) from [] (__fput+0xdc/0x1e8) [] (__fput) from [] (task_work_run+0xc4/0xd4) [] (task_work_run) from [] (do_work_pending+0xc0/0xc8) [] (do_work_pending) from [] (slow_work_pending+0xc/0x20) Exception stack(0xc2fdffb0 to 0xc2fdfff8) ffa0: 00000000 0154d1a0 01542a3c 00000000 ffc0: 0154d150 00000000 0009283c 00000006 000003f0 0154d4c8 00000000 0154d4c8 ffe0: b6ee7d70 bef13960 b6e547b8 b6cfe018 60000010 00000004 The problem was found for cpu dai drivers: pxa-i2s and pxa-ssp and by a calltrace sent from Robert Jarzmik on pxa-ac97 (although there was no observed kernel warning). The git grep shows these 3 cpu dai drivers are the only one which assign the .pcm_new to pxa2xx_soc_pcm_new() and almost every machine which is using one of these cpu dai drivers is using the platform driver pxa-pcm-audio too. The only exception is TTC_DKB board which is using a platform driver mmp-pcm-audio. A quick look in the code of mmp-pcm-audio shows it allocates the DMA in the similar way as PXA. The solution is to remove one of pxa2xx_soc_pcm_new() assignments and the patch does it for 3 cpu dai drivers (SSP/I2S/AC97). The result was tested on HTC Magician board (SSP for playback, I2S for capture) and the DMA buffers are correctly allocated. Signed-off-by: Petr Cvek Acked-by: Robert Jarzmik Tested-by: Robert Jarzmik --- sound/soc/pxa/pxa-ssp.c | 3 --- sound/soc/pxa/pxa2xx-ac97.c | 3 --- sound/soc/pxa/pxa2xx-i2s.c | 3 --- 3 files changed, 9 deletions(-) diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 69033e1a84e6..9689a1552d53 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -867,9 +867,6 @@ static struct snd_soc_dai_driver pxa_ssp_dai = { static const struct snd_soc_component_driver pxa_ssp_component = { .name = "pxa-ssp", - .ops = &pxa2xx_pcm_ops, - .pcm_new = pxa2xx_soc_pcm_new, - .pcm_free = pxa2xx_pcm_free_dma_buffers, }; #ifdef CONFIG_OF diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 9f779657bc86..c52b33802bf2 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -214,9 +214,6 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { static const struct snd_soc_component_driver pxa_ac97_component = { .name = "pxa-ac97", - .ops = &pxa2xx_pcm_ops, - .pcm_new = pxa2xx_soc_pcm_new, - .pcm_free = pxa2xx_pcm_free_dma_buffers, }; #ifdef CONFIG_OF diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index 42820121e5b9..e7184de0de04 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -364,9 +364,6 @@ static struct snd_soc_dai_driver pxa_i2s_dai = { static const struct snd_soc_component_driver pxa_i2s_component = { .name = "pxa-i2s", - .ops = &pxa2xx_pcm_ops, - .pcm_new = pxa2xx_soc_pcm_new, - .pcm_free = pxa2xx_pcm_free_dma_buffers, }; static int pxa2xx_i2s_drv_probe(struct platform_device *pdev)