Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3975735pxb; Tue, 25 Jan 2022 00:25:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoqYSV5GMlRBqgjQ9Bt5siuZ+i2BCioSmE3VQuZaRxOft1A59Q2nnoqv46SJ6ve55m3p29 X-Received: by 2002:a17:907:dab:: with SMTP id go43mr7072329ejc.400.1643099151945; Tue, 25 Jan 2022 00:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099151; cv=none; d=google.com; s=arc-20160816; b=p9RWTYbBnxPmO03YhhIP9DR9rrGeXb3mnJ3nnfNQwxJadvro3hGczpNjvFRc+pSPj0 A8p7lPx/5F5I4iNtxIVAVj/4R72cRqti+zCkVTH1rSsPp6FRnp0DiOqfPaOMbpOLCNTp r/faqBcD147cgOhanzdfU8VKJB6DOdk5N8bCpaj/xKbmRAX88E3irEDA+WDiJeGdnkSn G8DjJBQ2wmJXBDaBKl5UbwW6SUEDCYz4xClcyAjy8OdmUGoyoPSkDgiMnHIyLer9pXLu k7mEOE0/rgkMdV0/2QYqL8P94MRDHysRgd68YY7x2uidTl5ePtrbDkyVj8lu639mQ2u/ veRA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jmlN//sGNdBpEWFsbGgMfOru/ZdHdPm1wxLoB7qoMe0=; b=MeCfoUgMDS/++bHt8RnuLltwwEHe0I6Xuh6Nao+3pNfFU3XHWyX1MloDOp/vxScFa+ iB6rYR0FS2pw/BoR9k6wu8nZKOLrSFyz/vCoebdrxdtLkrzn8VdmaVQIGVwe9SGvj3d9 rtYP13cJNWYKpLKOywtUvNhYqXHjWrn8mjnumwUvyDoVmX1dLlyf/RFj21Ptl0e+c/Il 0IQSDr2iQZykYzZEQh2DSlx9GkCcIFfXIaC96acd7eND0n+fV26YvdevubiYFlHJHkYN us16RE0h0jAbn6nKtuTyhDWs5AkjD6kpvk95yCsowZkd/r/2q2sFr9JedR7iMk7iyqCc BMJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KyQ/xIIP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp8si4535670ejc.716.2022.01.25.00.25.27; Tue, 25 Jan 2022 00:25:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KyQ/xIIP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3421654AbiAYC1Z (ORCPT + 99 others); Mon, 24 Jan 2022 21:27:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377325AbiAXUFR (ORCPT ); Mon, 24 Jan 2022 15:05:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3533C061378; Mon, 24 Jan 2022 11:31:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5075661318; Mon, 24 Jan 2022 19:31:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 225D0C340E5; Mon, 24 Jan 2022 19:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052700; bh=mgxWZWBc0Eucoc+hoIoXSz+Ix0iMdTBDwuB1PKnJCCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KyQ/xIIPUL0fktyDtNXio+ounmH1MkzXxCs4tJm9BlrTF7OF1sse4HRO1inwNouc1 n49/rCAqKQ1pAPXV3TeTBj6aDQ95UiA3ErYWZq+zWPxBKQc1iZK+sqClrBMILPiOtt kYSUA9HIHnDsdgaJf+46V4i3Yn+5H2CgqP6YdaA8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wei Yongjun , Sasha Levin Subject: [PATCH 5.4 147/320] misc: lattice-ecp3-config: Fix task hung when firmware load failed Date: Mon, 24 Jan 2022 19:42:11 +0100 Message-Id: <20220124183958.645541290@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Yongjun [ Upstream commit fcee5ce50bdb21116711e38635e3865594af907e ] When firmware load failed, kernel report task hung as follows: INFO: task xrun:5191 blocked for more than 147 seconds. Tainted: G W 5.16.0-rc5-next-20211220+ #11 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:xrun state:D stack: 0 pid: 5191 ppid: 270 flags:0x00000004 Call Trace: __schedule+0xc12/0x4b50 kernel/sched/core.c:4986 schedule+0xd7/0x260 kernel/sched/core.c:6369 (discriminator 1) schedule_timeout+0x7aa/0xa80 kernel/time/timer.c:1857 wait_for_completion+0x181/0x290 kernel/sched/completion.c:85 lattice_ecp3_remove+0x32/0x40 drivers/misc/lattice-ecp3-config.c:221 spi_remove+0x72/0xb0 drivers/spi/spi.c:409 lattice_ecp3_remove() wait for signals from firmware loading, but when load failed, firmware_load() does not send this signal. This cause device remove hung. Fix it by sending signal even if load failed. Fixes: 781551df57c7 ("misc: Add Lattice ECP3 FPGA configuration via SPI") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20211228125522.3122284-1-weiyongjun1@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/lattice-ecp3-config.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/misc/lattice-ecp3-config.c b/drivers/misc/lattice-ecp3-config.c index 884485c3f7232..3a0d2b052ed29 100644 --- a/drivers/misc/lattice-ecp3-config.c +++ b/drivers/misc/lattice-ecp3-config.c @@ -77,12 +77,12 @@ static void firmware_load(const struct firmware *fw, void *context) if (fw == NULL) { dev_err(&spi->dev, "Cannot load firmware, aborting\n"); - return; + goto out; } if (fw->size == 0) { dev_err(&spi->dev, "Error: Firmware size is 0!\n"); - return; + goto out; } /* Fill dummy data (24 stuffing bits for commands) */ @@ -104,7 +104,7 @@ static void firmware_load(const struct firmware *fw, void *context) dev_err(&spi->dev, "Error: No supported FPGA detected (JEDEC_ID=%08x)!\n", jedec_id); - return; + goto out; } dev_info(&spi->dev, "FPGA %s detected\n", ecp3_dev[i].name); @@ -117,7 +117,7 @@ static void firmware_load(const struct firmware *fw, void *context) buffer = kzalloc(fw->size + 8, GFP_KERNEL); if (!buffer) { dev_err(&spi->dev, "Error: Can't allocate memory!\n"); - return; + goto out; } /* @@ -156,7 +156,7 @@ static void firmware_load(const struct firmware *fw, void *context) "Error: Timeout waiting for FPGA to clear (status=%08x)!\n", status); kfree(buffer); - return; + goto out; } dev_info(&spi->dev, "Configuring the FPGA...\n"); @@ -182,7 +182,7 @@ static void firmware_load(const struct firmware *fw, void *context) release_firmware(fw); kfree(buffer); - +out: complete(&data->fw_loaded); } -- 2.34.1