From patchwork Thu May 9 20:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 10937603 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 17DB813AD for ; Thu, 9 May 2019 20:12:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0919A28A74 for ; Thu, 9 May 2019 20:12:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F170C28AE7; Thu, 9 May 2019 20:12:31 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52D3128A74 for ; Thu, 9 May 2019 20:12:31 +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 555F21878; Thu, 9 May 2019 22:11:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 555F21878 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1557432749; bh=iRrsa+fjyqpHjPyjLRHbIxPcUN7HXJQJpUEj9xxgbYI=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SHHvwM6cFwYRtDRWZbsp6yyv6nCOMhXUto3KJXfpSg1qObJBPbc0HB62xS2oyIv5F RAGyUEbOqzsEmlw/8Dafu6d0qR9V3+lWW506BAWAMdWfzE4+bEHWTQdDrEtjrnV2FL vHAXbTmpo1u8OiXk2BeL2zUf7P0pFqQo7+HkEzxg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6C188F89727; Thu, 9 May 2019 22:10:45 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7CC18F89682; Thu, 9 May 2019 22:10:41 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4C4EAF89682 for ; Thu, 9 May 2019 22:10:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4C4EAF89682 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2019 13:10:35 -0700 X-ExtLoop1: 1 Received: from kli-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.254.111.224]) by fmsmga005.fm.intel.com with ESMTP; 09 May 2019 13:10:34 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Date: Thu, 9 May 2019 15:10:23 -0500 Message-Id: <20190509201027.3906-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509201027.3906-1-pierre-louis.bossart@linux.intel.com> References: <20190509201027.3906-1-pierre-louis.bossart@linux.intel.com> Cc: tiwai@suse.de, broonie@kernel.org, Pierre-Louis Bossart , Kai Vehmanen Subject: [alsa-devel] [PATCH 2/6] ASoC: SOF: fix race in FW boot timeout handling 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kai Vehmanen A race condition exists in handling firmware boot timeout. If FW sends FW_READY just after boot timeout has expired in driver, a kernel exception will result as FW_READY handler will be run while the state is still being cleaned up in snd_sof_run_firmware(). Avoid the race by setting boot_complete also in the error case. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/loader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c index 81c7452aae17..628fae552442 100644 --- a/sound/soc/sof/loader.c +++ b/sound/soc/sof/loader.c @@ -372,6 +372,8 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) msecs_to_jiffies(sdev->boot_timeout)); if (ret == 0) { dev_err(sdev->dev, "error: firmware boot failure\n"); + /* after this point FW_READY msg should be ignored */ + sdev->boot_complete = true; snd_sof_dsp_dbg_dump(sdev, SOF_DBG_REGS | SOF_DBG_MBOX | SOF_DBG_TEXT | SOF_DBG_PCI); return -EIO;