Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp671567lqb; Fri, 15 Mar 2024 03:14:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX29/oWTqjZZUvUkpTYTbIkICA3PiJN/NUun7AWvsiho2rv5c5vfcpH+JkkfNbBkOphfGVoJ19U5muxIO0Gfg335KFj0MA0kT7PLqUIvg== X-Google-Smtp-Source: AGHT+IF4kSQHK+LekL5j2rYGmUNMrxbZiukXhIflmdN8R/KGIz5ZLlgfubO99I56VqGuVqgzi5aM X-Received: by 2002:a17:90a:94cc:b0:29b:aea0:1883 with SMTP id j12-20020a17090a94cc00b0029baea01883mr4091640pjw.2.1710497659959; Fri, 15 Mar 2024 03:14:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710497659; cv=pass; d=google.com; s=arc-20160816; b=L4vVMo1gyTfEs/uq844vsNOyTeKqRvjl2xPOUgM1DMqbDKqmlQ/zUcu5pST5XXza+8 fe/XNjPk0ckqRSGFBiakDNpN7KLRaY6hith304qB3JzuV634P/nkfZuSfR3lo65Ge5dc fjmz7z4rdnxQnfi0MdQPuAdncmJc6LvZPY4TL2boOLD49DVnkJdzzrGIzm9+MD0fp2E6 ihJvOXP/6kqSwMbrn+GvxR1HydHAUwe16puGgZMdworIGEfhrKhuZ29alSO9p1JdvszZ 4kDzsNMqgMCC13MbhZ68pfWpXYvJBxv87NbUpWkP4TQd43THEuHg4ZGfa3GTRyMQWg5e mueg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=HU3MdveyUtTZ/B/MTBzpI+gpbZxcaNZ2k4RS9Uuegcc=; fh=28Gsh8p/Rrgoh0ZJgxMb30MiNZzzGa/AucmCEg5DMJI=; b=dPBSe+YpJVIz3eeLXNBjAa5ciBum5tXj5Xd8quPAlepqRjE9t5jBvoeHsvcH1zbdr2 +DVYYbywpmxzvt7r7os1j00iqhrpEkqnx3xRuNUpyV+m0n59wg8l1a04vnCKCc1xB/zn zcqCA/9uaPqMvo6gZglzCCj+/DCjHLLmI8Oxeg2iyPlVK9NVZ2rxLhwZwlLPENosE0j2 /cFXIkbVWe8uw6xfymlUfnoOBS1T0LioBiMRhNkyxojxD/9jJMKeoruX8356TjVz1E2u yud6M275E2UihLvEpdFSO6jx5RQkjQVMiWZmLPzahSQnPdLq927XGYmhLAspEy+ynrnn GTqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-104247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104247-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f2-20020a17090ab94200b0029b7c068ef6si2492453pjw.162.2024.03.15.03.14.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 03:14:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-104247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104247-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4D2F6B22B38 for ; Fri, 15 Mar 2024 10:13:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4E461B5B3; Fri, 15 Mar 2024 10:12:27 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A2E718C31; Fri, 15 Mar 2024 10:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710497547; cv=none; b=hEmlxvy2bx4Sr68noqncMX0ksjx2aJJgKif/oLIzfStfm5JcOLUUGwGDrTugfppWNOi00SFEVI/NztYsrmU+tx0Nbd2eoqMN95DmRrSy6UNxZE+45TnTrfTfytZ2DO0vILaFCG7QmUExiWS9bQwdZ5Bkcm/98AB5CdVG8AiKOtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710497547; c=relaxed/simple; bh=fFexEFvf3qY+UAxuDxDfmyzLxsCkJobefOmJN2deFBY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HRIyUKI4JSD4aECbKqIiAujLZx32OgA4XNecv9RlBi0hQIR5RC5E7KSXEUa+7xsJc0DELm7z9iISioYtxtQRt0HmeGFbKiNOikc0BeiIogUrqSE001Aikoj45ZRPvCHzlWDk8Wqt9+oX/1on2K0r9z9vthJktq+v7DM9eRa6Kgw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tx0NW1ydHz2Bg1G; Fri, 15 Mar 2024 18:09:47 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 44C1C180061; Fri, 15 Mar 2024 18:12:16 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 15 Mar 2024 18:12:15 +0800 From: Jijie Shao To: , , , , , CC: , , , , , Subject: [PATCH net 2/3] net: hns3: fix kernel crash when devlink reload during pf initialization Date: Fri, 15 Mar 2024 18:07:47 +0800 Message-ID: <20240315100748.2913882-3-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240315100748.2913882-1-shaojijie@huawei.com> References: <20240315100748.2913882-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600007.china.huawei.com (7.193.23.208) From: Yonglong Liu The devlink reload process will access the hardware resources, but the register operation is before the hardware initialize done, so, if process the devlink reload during initializetion, may lead the kernel crash. This patch check whether the NIC is initialized to fix the problem. Fixes: b741269b2759 ("net: hns3: add support for registering devlink for PF") Signed-off-by: Yonglong Liu Signed-off-by: Jijie Shao --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c index 9a939c0b217f..80db4f7b05f6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c @@ -40,8 +40,9 @@ static int hclge_devlink_reload_down(struct devlink *devlink, bool netns_change, struct pci_dev *pdev = hdev->pdev; int ret; - if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) { - dev_err(&pdev->dev, "reset is handling\n"); + if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) || + !test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state)) { + dev_err(&pdev->dev, "reset is handling or driver removed\n"); return -EBUSY; } -- 2.30.0