Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2282678lqt; Mon, 22 Apr 2024 06:50:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWUjk3AvxKiIzyD+dzrQSW5v3cPHFQohENyUhyBDqdST6G+3+fGNUj+1OmXTEbasrTaPQKMOj6ofjE1egbsupM6NEDxqFSDqEWkJdec8w== X-Google-Smtp-Source: AGHT+IG6RggbW7S443AoDbsjW36v+fVELkJ6hnKBE7c1zpK+C/0t5zv2BRaClGzE4LiI0CzWrviM X-Received: by 2002:a17:907:7292:b0:a55:8f2a:950d with SMTP id dt18-20020a170907729200b00a558f2a950dmr7508358ejc.16.1713793858747; Mon, 22 Apr 2024 06:50:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713793858; cv=pass; d=google.com; s=arc-20160816; b=ICfpr4cFgws9ovHVS/eVUmq9ZGdPdKOHLM9v/zDRO6P7vOUsk1f04nezhAglrVjbQl xOCxFg1Am/e50mg7Vrd0xkhYVCYbcAusw8XBKGbV/x5bUp64KwQvKV8h1jFwcmyOKmvo tBt+Iam733m4XxCwiU7A+ivQaH54B7g1FScxWdlWj6y4s/COYHOqvNgAi4kAb9GO4gXF CQALC/rBV+CD3gekiQs90i3koR/X8GioYFRLEQhxxSONKOeg+BRf37bC15f1Em6KnnmL mOKJzII+ePEfCrHD1ab9gO1iqtmgk4IfVZt6sTl6HXGb95R/CUG85Jt0RsnEyObTE7Hh lO+g== 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=eR5Z8rZGIExUzcq0phJbxZgeKR5rMBZ8ZinvBT9RtxU=; fh=wlJpaq28YZ1RSdkPro/WCKkiCQaYFufuKgqCgdtEhqE=; b=Mn+GpsTfDYVTcP9pSdnnI9pIj7Lc5yfduMPOcPTtUZ+bGDTv58VchcbSS/OZ0ckT42 TLe/N9DllLTrKliLpmi9UDZJXJias+h8gAyNil0LN25NvLfbIaYNjz3NJMnzrBf3c9vo qIW428SCfjnVKehsBjUX1Q5FnZRt+4G8ozK7+mKym1rYSb3lBMOpZHW8GvFF8KRkeT/z KT5Pa8kERnpQMOHctHYtVHz0otkOyyomnzcz7+o3JvmyX+B34n2pxy/kBmRDxyt1ZOAU ZYLqoqe630koMUbFbGRn6vQFfmILUMDCxcpQYlG4ZPekcHlp0cWgf7qHZfcHupZXW0Zp 20Xg==; 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-153493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gs40-20020a1709072d2800b00a55bd5d6cb8si900938ejc.958.2024.04.22.06.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 06:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-153493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153493-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 787601F21CB7 for ; Mon, 22 Apr 2024 13:50:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDAB015217C; Mon, 22 Apr 2024 13:50:02 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 E12B21514E2; Mon, 22 Apr 2024 13:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713793802; cv=none; b=tCYjc/e1oDSIVwGEoU1msrXCWLb4x5p72aeeFkGmbTFuGRbAc7MeqR6aQ8xuU0dV3YZKAFzUjfOpnd6OIsUsY3E/QYrT1M9A2CHNl+k/H5gL5qeZi4EL9naYQjDKXI6pqw+UevFBSlDaTPfrbZRtWRXDVxv75JDZLv4Yep3IM4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713793802; c=relaxed/simple; bh=5yvgi9mrQAF3qOurmIWeU5dX0slS7fJ6ldV2mGba9Lc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JzU4BxWJr2Xsk/4KtjelO975nY3TXsDDD5hk82jQb39wwckjmIsbGqJiASlemakL/KbLfm40RL0Hw+rDQfg/UXbwcxHTMeK/cKCXVLimvDzVtET6rTMy8eCfuQgK+sjOmQkQl1pj94EK977IIcP8MrT01gbVrJatluJLjNns5NA= 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.188 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.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VNRNy5vlqzXmCw; Mon, 22 Apr 2024 21:46:26 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 6D5F318007D; Mon, 22 Apr 2024 21:49:53 +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; Mon, 22 Apr 2024 21:49:52 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , Subject: [PATCH net 7/7] net: hns3: fix kernel crash when devlink reload during vf initialization Date: Mon, 22 Apr 2024 21:43:27 +0800 Message-ID: <20240422134327.3160587-8-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240422134327.3160587-1-shaojijie@huawei.com> References: <20240422134327.3160587-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 done before the hardware is initialized. So, processing the devlink reload during initialization may lead to kernel crash. This patch fixes this by taking devl_lock during initialization. Fixes: cd6242991d2e ("net: hns3: add support for registering devlink for VF") Signed-off-by: Yonglong Liu Signed-off-by: Jijie Shao --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 08db8e84be4e..3ee41943d15f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2849,6 +2849,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) if (ret) goto err_devlink_init; + devl_lock(hdev->devlink); + ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw); if (ret) goto err_cmd_queue_init; @@ -2950,6 +2952,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) hclgevf_task_schedule(hdev, round_jiffies_relative(HZ)); timer_setup(&hdev->reset_timer, hclgevf_reset_timer, 0); + devl_unlock(hdev->devlink); return 0; err_config: @@ -2960,6 +2963,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) err_cmd_init: hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw); err_cmd_queue_init: + devl_unlock(hdev->devlink); hclgevf_devlink_uninit(hdev); err_devlink_init: hclgevf_pci_uninit(hdev); -- 2.30.0