Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558702pxb; Mon, 24 Jan 2022 12:11:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLV7JNq2GG00ChavVOZS7n/gBdH4cG+ZiL7Iiho5pFpTBodsQ0ho8h83OttOFhXbvxeaHR X-Received: by 2002:a63:4147:: with SMTP id o68mr13137525pga.204.1643055106175; Mon, 24 Jan 2022 12:11:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055106; cv=none; d=google.com; s=arc-20160816; b=NAgOVXVG47i78u3HuwR5MqfUGzfEjXqIzsiRDQ7omLTcdUqU+kzJRNbtZ3kF3SENdt uexMiOxVyEBZVEiYGyv4PNzqoUgbJ174YVvzVkJYmc2wR+WvDdqM7AueyZ3tg4jBqFTi qaNyQ9r7Xki8U6zc+eMk4y8BTUiUsJw12aLSGBTg9//xKpfdPFC6hXAyfDOQLmdlU9g3 mTc919Bm3+Us0mprzrbP16fn8khKnP4OHT/vvz1450CVE6GgKpYX2yqsPmWqg+7SVeHn +3TggpFk9n2eL3lrw7i2MqFj4Ks/Pe2HLh+lyncTTI09BnQv8JItGlJp5Pc1trfLIBXA XYSQ== 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=lrRI38HfWEU7oK/t3GVaSQdNzZcFWsfvMCa/TvNstVU=; b=J/wbvukH5n9yeaL/b07lWimqI+sZi2B3BmgsN4xMxfxhCpQGevywM65dtu3v83Dlid WzVbRNVbWcKDCGbLhx2JfsJvpc4LvR3oTSiHonZbP85Xy42C+wa78dNPmAHw2JGI1EbF naNejL5sFbLZzkjC8rCO4pxRfjV+Mc3LJmi+fcbX+9Y1wM1f/ABqNb3hCbb77o/HbKUc 4ptTTS6ShJxAbtFxisfVuSoe3drAp26YFEQrChxhfIIJJyLNxe29hs92qILrdoqsns9P A2yWJIbxaVEd4r6PHRSxjACB81vYGvLyCAra5VUaz8qyFAekkSUCbDNpL8exwdvlrayN xhFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iqhaJDh1; 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 w125si13114415pfw.250.2022.01.24.12.11.28; Mon, 24 Jan 2022 12:11:46 -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=iqhaJDh1; 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 S1348253AbiAXTPG (ORCPT + 99 others); Mon, 24 Jan 2022 14:15:06 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:32836 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345813AbiAXTGZ (ORCPT ); Mon, 24 Jan 2022 14:06:25 -0500 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 6141E603DE; Mon, 24 Jan 2022 19:06:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25BAAC340E5; Mon, 24 Jan 2022 19:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051184; bh=2C18HuDLscgc4+tKatxU9QstG6/auVKahETKdInN1gE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqhaJDh1lxqDHj3g3dngicRQ2tjXlGkIsyZpRGZPZWgBIRKxrFbdTmcwPnYEboUdl YYSrn9eAdqVB7h5fScfsQzLVqvNI3N0a0gs5ZgfdDIfj/BcMnl7fgLKaWxY59SsMRt Ct8zxF8c56ROrpSm9BKUKH88pZkWEYJSBk2Kjin0= 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 4.14 082/186] misc: lattice-ecp3-config: Fix task hung when firmware load failed Date: Mon, 24 Jan 2022 19:42:37 +0100 Message-Id: <20220124183939.758150635@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 626fdcaf25101..645d26536114f 100644 --- a/drivers/misc/lattice-ecp3-config.c +++ b/drivers/misc/lattice-ecp3-config.c @@ -81,12 +81,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) */ @@ -108,7 +108,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); @@ -121,7 +121,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; } /* @@ -160,7 +160,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"); @@ -186,7 +186,7 @@ static void firmware_load(const struct firmware *fw, void *context) release_firmware(fw); kfree(buffer); - +out: complete(&data->fw_loaded); } -- 2.34.1