Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4361345ybf; Wed, 4 Mar 2020 02:27:03 -0800 (PST) X-Google-Smtp-Source: ADFU+vtr0kS4NIcOnquDvkbyJV5v4Fqj2xHf2Zep0rdadtZsTG/9bAGVCmuSNw18P8r7qYnFztoN X-Received: by 2002:aca:314f:: with SMTP id x76mr1247133oix.117.1583317623694; Wed, 04 Mar 2020 02:27:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583317623; cv=none; d=google.com; s=arc-20160816; b=m2rgy2sK/URhcr7o/Wal2gfTtuuDy9eu4CJKRT1tAzHzuJxTC6zX/IloiXg/ghphsU SENIhqkK9d8i8RcAy/ZdS8AhQmvffFMp0Q1UFgR2mUt81+Ankv18ziawQfe1H0p73tMC K7rFrN0LQrhbcyLbLNgrXQBsn8eXcS2MidR7Pemh2pnHlfWesae1EHQjn+z4AjxnfbjR 9DWi0IWXA9R8WygRN8Huzl1NH5pwPaEzQWZxr/2vjFN9pdV0pa16KFmqMNuQKmq+Yfms kwxJyFPCkAFRPbhGjMo0ztaxL82r+O57FfV8EcfPS89yKKOg6vojYcwRFnBAlKZ0zq3W 6Ypg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=ZL/hYWSULbj6x3ZEI1ztfUStLGR/8nzqOo/SfYwvvnY=; b=G38g6tCBXflHWAu+DHRBJvtXnH/p8+ZkjzC4SAzhZpZ8UpDLVOH/6BrEuFNOVptM1B i2zsOOBp4Leg2B+mDrB4B8LnAqLXm96LyyPVXTSn5i7FHbFVTKiDWhA3bPecJXPFYkZ0 mltKIqa5BNYjKg6M0lt5v06PaFp8o0t7m+vvzBEcY5GrrFYPwtHyyiXKYsb0HHCQIiz0 LBBWkAz02xiB2nRIIZeQdo9hHzus4yCpJZRTJYURrFxX3LA3642wlqCzOFseMH5WUfwp 81WUSoxYyM+1iJ71K1Mx06lwLmCsSIhIMaZjdt5AP8XlibhSrCMpaG5pY3C9HAS5o0O5 jbLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=t+4FxdbG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si882007oih.41.2020.03.04.02.26.51; Wed, 04 Mar 2020 02:27:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=t+4FxdbG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728998AbgCDKZN (ORCPT + 99 others); Wed, 4 Mar 2020 05:25:13 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:16832 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726860AbgCDKZN (ORCPT ); Wed, 4 Mar 2020 05:25:13 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 024ANBVf004135; Wed, 4 Mar 2020 11:24:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=ZL/hYWSULbj6x3ZEI1ztfUStLGR/8nzqOo/SfYwvvnY=; b=t+4FxdbGMrlxGrf27faP6F1SoKWIqs9eP/2ZVF2eGmRkuD5A49uXW0bgNykDxpL+YQlZ qkbLwSrwB67hQG0P4nn2nzbRe0Wjfpj5+P3+rMs+ouHC+GKbJJq87f7sbKae9OgV0tZ4 4X7F0cppQ8oJqdcmn+qJezc3uFkdIcd8cD0nrZlId5L9s45TY1lIX8VuD75bBe3ceWLP Od+wl0IHmgWP+EW7jZVh61jeZef+XpMrL2BLoOhGou9C2ctPy4ODNOy2AThX2hwC3heM muJmngJcNGENl2AmHL8s/6GYL0U2TdXm2FHTt59+ba726GUR8DL3mCH9AMJh1kyXiid6 ew== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2yfdyd0qbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Mar 2020 11:24:16 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1FD35100038; Wed, 4 Mar 2020 11:24:11 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag6node2.st.com [10.75.127.17]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E02BE2A76A6; Wed, 4 Mar 2020 11:24:11 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG6NODE2.st.com (10.75.127.17) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 4 Mar 2020 11:24:11 +0100 From: Olivier Moysan To: , , , , , CC: , , , , Subject: [PATCH] ASoC: stm32: sai: manage rebind issue Date: Wed, 4 Mar 2020 11:24:06 +0100 Message-ID: <20200304102406.8093-1-olivier.moysan@st.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG6NODE2.st.com (10.75.127.17) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-04_01:2020-03-04,2020-03-04 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit e894efef9ac7 ("ASoC: core: add support to card rebind") allows to rebind the sound card after a rebind of one of its component. With this commit, the sound card is actually rebound, but may be no more functional. The following problems have been seen with STM32 SAI driver. 1) DMA channel is not requested: With the sound card rebind the simplified call sequence is: stm32_sai_sub_probe snd_soc_register_component snd_soc_try_rebind_card snd_soc_instantiate_card devm_snd_dmaengine_pcm_register The problem occurs because the pcm must be registered, before snd_soc_instantiate_card() is called. Modify SAI driver, to change the call sequence as follows: stm32_sai_sub_probe devm_snd_dmaengine_pcm_register snd_soc_register_component snd_soc_try_rebind_card 2) DMA channel is not released: dma_release_channel() is not called when devm_dmaengine_pcm_release() is executed. This occurs because SND_DMAENGINE_PCM_DRV_NAME component, has already been released through devm_component_release(). devm_dmaengine_pcm_release() should be called before devm_component_release() to avoid this problem. Call snd_dmaengine_pcm_unregister() and snd_soc_unregister_component() explicitly from SAI driver, to have the right sequence. Signed-off-by: Olivier Moysan --- sound/soc/stm/stm32_sai_sub.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c index 0bbf9ed5e48b..48dfcdd13574 100644 --- a/sound/soc/stm/stm32_sai_sub.c +++ b/sound/soc/stm/stm32_sai_sub.c @@ -1547,21 +1547,21 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) return ret; } - ret = devm_snd_soc_register_component(&pdev->dev, &stm32_component, - &sai->cpu_dai_drv, 1); - if (ret) - return ret; - - if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) - conf = &stm32_sai_pcm_config_spdif; - - ret = devm_snd_dmaengine_pcm_register(&pdev->dev, conf, 0); + ret = snd_dmaengine_pcm_register(&pdev->dev, conf, 0); if (ret) { if (ret != -EPROBE_DEFER) dev_err(&pdev->dev, "PCM DMA register error %d\n", ret); return ret; } + ret = snd_soc_register_component(&pdev->dev, &stm32_component, + &sai->cpu_dai_drv, 1); + if (ret) + return ret; + + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) + conf = &stm32_sai_pcm_config_spdif; + return 0; } @@ -1570,6 +1570,8 @@ static int stm32_sai_sub_remove(struct platform_device *pdev) struct stm32_sai_sub_data *sai = dev_get_drvdata(&pdev->dev); clk_unprepare(sai->pdata->pclk); + snd_dmaengine_pcm_unregister(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); return 0; } -- 2.17.1