Received: by 10.213.65.68 with SMTP id h4csp2157200imn; Sun, 8 Apr 2018 21:11:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Fy6Gw+SqTBwFKnkkS2FeXIu+7ENPlSTD+JCLyk3e50RHn9aLST0kBx4kBC4xmb/4EeDHl X-Received: by 2002:a17:902:20eb:: with SMTP id v40-v6mr37191339plg.277.1523247083812; Sun, 08 Apr 2018 21:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523247083; cv=none; d=google.com; s=arc-20160816; b=s0LnMHUgQUfY0kL/GaK1/21q6/cblJhOZpYgau35PYwKlElXh3r9vtjCaxMN1UGvFj qEykOzFpkBoT5l493A3P9EmWvhYn7wnBrk5uFZr/ImBzRGbQkGPwVAQOyr0C9WCXKL5F JhOCyLu46yryMLclXRwVodPFFXCCC8dMf/NB6/uGgqhHNZGWvbCyCjwjfHnUAVExYKeh Kt2WEalA/IsQaOPO3clOszLj4r5ErQJ5XfMD8dRkey522opLSwJU8MWr7QbHfsOrg6tt iXdZ2NBYY+zuL63pp9nj0T0Y0atHjcvetGwVOtCjDqE/6XRSSQc0AGpRa3waK7uQbOqI elRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=unMcAlAJOmQwhsy3rt9qy3UzCxYEXJVdipahEm0BawI=; b=IaNn/ciGQ3ZtRUrgaL9QZWaUk/+ukM+O109gxfD1iTB2fCJipYadO0y44dIdWEey38 M/L/r2JMEvbDI8LhTE7WDP4PDinfLVvc8JD5C1Yvgpr1JjDPI0skv/ZvPK8eXs6QxLud opZ1Vo693XbetDB/gjmi0SXN6BYNp2zJOOlS0l1DmOZ8vjlBEaqf4Panel/svflwmWxm ox5KZWTPuIgNM9TFzOooHdaUi8+yHctFZ6dMVH+RbwH9P50imN17zY6Cx5q3aM0PEYgk UwkdoDejxBXiCNl79nUVXcAMxd2/PUC+e3MXxCWozAdw0SBAaKrdv+FDq29NCb7Lk9SS KGkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=R1oWLkjj; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si11588545pff.280.2018.04.08.21.10.46; Sun, 08 Apr 2018 21:11:23 -0700 (PDT) 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=@microsoft.com header.s=selector1 header.b=R1oWLkjj; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754230AbeDIEFa (ORCPT + 99 others); Mon, 9 Apr 2018 00:05:30 -0400 Received: from mail-bl2nam02on0136.outbound.protection.outlook.com ([104.47.38.136]:51875 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753271AbeDIARy (ORCPT ); Sun, 8 Apr 2018 20:17:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=unMcAlAJOmQwhsy3rt9qy3UzCxYEXJVdipahEm0BawI=; b=R1oWLkjj1rSGeLaSK2PXme59cwa58cYwQyB+srjyANRCS4dlKrT6I1YQ8rhe2yHRozcSdIoJDXSO4CM2IOq5iPU7Hlti+dy3RdKxBKz0G+qDRyLa6K9+F2tLUiKJBpXR6KInIdIzAL3TjBTf6ioeUPjpLX311U/Rfb1KE2RhYus= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1048.namprd21.prod.outlook.com (52.132.128.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:17:47 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:17:47 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Matthias Reichl , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 044/189] ASoC: bcm2835: fix hw_params error when device is in prepared state Thread-Topic: [PATCH AUTOSEL for 4.15 044/189] ASoC: bcm2835: fix hw_params error when device is in prepared state Thread-Index: AQHTz5gg98iVAtp40EeyV2UGyYPEUw== Date: Mon, 9 Apr 2018 00:17:20 +0000 Message-ID: <20180409001637.162453-44-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1048;7:20pkr8FceiKdJMYAKcYUi+SbCSmuIdWrVXopAOSxWGbps/tcW54OqjcLCeNZY3DwtuzzfdU0ErFt6K/CZwb6yUh4/cdYmUH7ebPIf19kmZIR+/if1PQrMP1XyVME4j7sQvL83Uq/ACDLZQB+NThJm+2o4cmmP0sl/IO9uXpXrr/Ps4U/C4JJMmjSszWj6w2quOdRpXgIaaX0ncLHuaCcSP0qL6BT3PZq+ELcSbZhn4YMFqzPk2xssfLSpf79I0ag;20:iiI5wf4l4qQDIhBFFMZdleyC+BcS6m/OCPhJMl6bHm8YfoT5ljj6Z5/I7tYkMsL8sDnZt5vm5pNhGjKEMiZvzSxdDiZVBdAsCB43tX/LDOHZNwebOk1AG0B9iKACU1wQKiwYUvSvqmqoX5L+RGAFzSNddOjzKi1QlefAb4PDSqA= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: b869fad5-1044-477f-c547-08d59daf52f0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1048; x-ms-traffictypediagnostic: DM5PR2101MB1048: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1048;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1048; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(39380400002)(376002)(39860400002)(346002)(396003)(189003)(199004)(86362001)(1076002)(99286004)(6116002)(110136005)(3846002)(54906003)(22452003)(3280700002)(105586002)(2906002)(76176011)(4326008)(6512007)(6436002)(6486002)(3660700001)(6666003)(7736002)(86612001)(25786009)(2900100001)(14454004)(97736004)(53936002)(107886003)(68736007)(102836004)(36756003)(6506007)(26005)(186003)(106356001)(305945005)(5250100002)(72206003)(478600001)(2501003)(10290500003)(81166006)(5660300001)(8676002)(66066001)(316002)(81156014)(2616005)(10090500001)(11346002)(446003)(476003)(8936002)(486006)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1048;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 15U2jFlivHTWS4eRWVk10rg03DE2LB7+bihaKejOCFXAJhBEjSTZ5yFcqQX8vpzCM1sZmzmEBF1cuEHdIdpnwiOXf7I+fygvWIwqbDGCfn8+EyDD5cNMrj0BmSaYupWclx6K7U4c04a3yTNzR9GH33eScXMzehdw8uN2WsdfGntzd646PjqnbIwwOok5SbuSgMThGQkGNeUmyxkaobHtqXu+G5KuUegA49cOU/dTsgEVwTm4wgCpV+uJAEOMb7+kpq2XIEjOAKk4p3b2qPvOP+gq6L/GSRV5+OdXppi9Dn9IbIBhjk6M8lmCvapJo9AKfQvTCGQVjrOf+KYrYn92zF3rCvvGlnpjSTNkvCvXUfnddoFM+7D+jvqcN7aQtvpUgXj5qdqUcpgW3hxFBfoj1QCQS1AE9XfugDap03YeqKw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b869fad5-1044-477f-c547-08d59daf52f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:20.6666 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1048 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias Reichl [ Upstream commit 8d5737a5f53902a916ee1e1cb248c9b8b883b2ea ] If bcm2835 is configured as bitclock master calling hw_params() after prepare() fails with EBUSY. This also makes it impossible to use bcm2835 in full duplex mode. The error is caused by the split clock setup: clk_set_rate is called in hw_params, clk_prepare_enable in prepare. As hw_params doesn't check if the clock was already enabled clk_set_rate fails with EBUSY. Fix this by moving clock startup from prepare to hw_params and let hw_params properly deal with an already set up or enabled clock. Signed-off-by: Matthias Reichl Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/bcm/bcm2835-i2s.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c index 2e449d7173fc..d5f73a8ab893 100644 --- a/sound/soc/bcm/bcm2835-i2s.c +++ b/sound/soc/bcm/bcm2835-i2s.c @@ -130,6 +130,7 @@ struct bcm2835_i2s_dev { struct regmap *i2s_regmap; struct clk *clk; bool clk_prepared; + int clk_rate; }; =20 static void bcm2835_i2s_start_clock(struct bcm2835_i2s_dev *dev) @@ -419,10 +420,19 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_subst= ream *substream, } =20 /* Clock should only be set up here if CPU is clock master */ - if (bit_clock_master) { - ret =3D clk_set_rate(dev->clk, bclk_rate); - if (ret) - return ret; + if (bit_clock_master && + (!dev->clk_prepared || dev->clk_rate !=3D bclk_rate)) { + if (dev->clk_prepared) + bcm2835_i2s_stop_clock(dev); + + if (dev->clk_rate !=3D bclk_rate) { + ret =3D clk_set_rate(dev->clk, bclk_rate); + if (ret) + return ret; + dev->clk_rate =3D bclk_rate; + } + + bcm2835_i2s_start_clock(dev); } =20 /* Setup the frame format */ @@ -618,8 +628,6 @@ static int bcm2835_i2s_prepare(struct snd_pcm_substream= *substream, struct bcm2835_i2s_dev *dev =3D snd_soc_dai_get_drvdata(dai); uint32_t cs_reg; =20 - bcm2835_i2s_start_clock(dev); - /* * Clear both FIFOs if the one that should be started * is not empty at the moment. This should only happen --=20 2.15.1