From patchwork Tue Apr 11 15:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 82046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2673054vqo; Tue, 11 Apr 2023 08:47:20 -0700 (PDT) X-Google-Smtp-Source: AKy350YXRpbtV5vri8idC8qXcx8cVBGXbW3+HSxbq78ORPgfHL4oOta/dC6BmhAfvWqBe3v/Hk2X X-Received: by 2002:a05:6a20:a613:b0:e4:2a2c:869d with SMTP id bb19-20020a056a20a61300b000e42a2c869dmr2753283pzb.43.1681228040614; Tue, 11 Apr 2023 08:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681228040; cv=none; d=google.com; s=arc-20160816; b=1LcaMRge2vRjLUWB9jc2A2I0vriAEbDlcP+94gTDm8gaD8FoCsMmz6WS5JUA14gYQ4 UEkQ8uGoLwmUs1G+65Fe83ap+bX2WeifEA6KNyZPPVVas/cPnrnxSPTFjbTRsbfY372W 5fa7kZtA0iNvje2B75ulXwvAqdm6jh9OsCgqoARSYfdvLbLifmhtY+dwdrrBjNlfm9LW V2hDLUSuKA4t4UqjO/iWQlG9BdUtXQcqjjTfjMLifsQtUkmSu716koFSbZsbNJtC0PA9 7cozJh5c8OMEIyYSOwF8DtYjZesWXuLYnAMEMxbMl+HWe5nKupyB+LKJKtdEz2gqsa/V vIgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VR8dS9XHi/tcgg98tMyvu5oqdaqQI1zEFWEB3e2GIBY=; b=mt+rgaQmF6/aemFi80HVYNLOlZc5hcZ+XUeuvYvYEBZhOdBZ+EHdVRjgSzhxv0wCA3 64lLFhMGQN/GEcDSei/9dT292UQk0JirODILTyXY2EnM6B24/CqwxngJd5d6Jw3o83nX 46wHyW6EjrKULpj1W28BAcWvLG/5336603xOaBON2pXx2Xz3XLzrDoABDU8DA1DlBdgt RVXxbExSp6RdyR4UnI0gL66jCaKiLW9f3Tg6Y1/wpGTPsq4qDrRPSfhrGt62GSMgIsip 62qQVDwJHKSySlW9tNCtrzvIuy7koXgs26anIuxwKqaQVASecpRyDn/QxU3NGv5FV3Mx dVFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Rdn+cz2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020a63fa51000000b0050318a4a5casi2469782pgk.408.2023.04.11.08.47.07; Tue, 11 Apr 2023 08:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Rdn+cz2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbjDKPZs (ORCPT + 99 others); Tue, 11 Apr 2023 11:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbjDKPZj (ORCPT ); Tue, 11 Apr 2023 11:25:39 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10F914C15 for ; Tue, 11 Apr 2023 08:25:36 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33B5cuXH012801; Tue, 11 Apr 2023 10:25:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=VR8dS9XHi/tcgg98tMyvu5oqdaqQI1zEFWEB3e2GIBY=; b=Rdn+cz2PuBzL5/nLw7ZZd+bzotn5bAQU7bm7EuXWXvgYoH/upMoYC6qDk5Abml4ndy4v cyHFtHdwxs4Otgq4BRmxkDBoUMLbKPBbAGDUdhX74rD20VEHeBLSxtygp1UscMXrYb8+ 6/0UbjZ7capl9N97eQhA4fSl6TAaX7l38P711OEAeBwwY8D27mE4/pXCxtvmQ540AxOO y+p2Py6Jv/on7ImAJZCpLKMvGxOoLQnzY0bPDQ1KAaGYv8E7k5yWywsEq2OOENX4dhRz 3kgBXZyz4g6bmiiUq3gSJy22bJht4Pxz/5eYqnjnx0XHY0KX0IGa230Ftk3ds7xtxdKY Fg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3pu4pq54a3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Apr 2023 10:25:31 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 11 Apr 2023 10:25:28 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 11 Apr 2023 10:25:28 -0500 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 6EED115B6; Tue, 11 Apr 2023 15:25:28 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , Richard Fitzgerald Subject: [PATCH 3/6] ASoC: cs35l56: Skip first init_completion wait in dsp_work if init_done Date: Tue, 11 Apr 2023 16:25:25 +0100 Message-ID: <20230411152528.329803-4-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230411152528.329803-1-rf@opensource.cirrus.com> References: <20230411152528.329803-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: j7ttbEAZI4NGRR5EORvwAyFKfnenpTWr X-Proofpoint-ORIG-GUID: j7ttbEAZI4NGRR5EORvwAyFKfnenpTWr X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762895373600669159?= X-GMAIL-MSGID: =?utf-8?q?1762895373600669159?= At the start of dsp_work() only wait for init_completion if !init_done. This allows system suspend to re-queue dsp_work() without having to do a dummy complete() of init_completion. A dummy completion in system suspend would have to be conditional on init_done. But that would create a possible race condition between our system resume and cs35l56_init() in the corner case that we suspend right after the SoundWire core has enumerated and reported ATTACHED. It is safer and simpler to have cs35l56_init() as the only place that init_completion is completed, and dsp_work() as the only place that it is consumed. Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/cs35l56.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index 997a5c5acaab..62c44276c121 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -866,7 +866,8 @@ static void cs35l56_dsp_work(struct work_struct *work) unsigned int val; int ret = 0; - if (!wait_for_completion_timeout(&cs35l56->init_completion, + if (!cs35l56->init_done && + !wait_for_completion_timeout(&cs35l56->init_completion, msecs_to_jiffies(5000))) { dev_err(cs35l56->dev, "%s: init_completion timed out\n", __func__); goto complete;