Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2759742lqp; Mon, 25 Mar 2024 08:28:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMW4bErYjB3NtzVS4bgqGoes+b2dzckfD22vOUh9h55zI5rcVFmUVkmeDDsGI+f/BdB1YPZ8L+nVETTUbpGKrDKO6+mUlSpf+0JKv72A== X-Google-Smtp-Source: AGHT+IHWeD/IH9xbaL9z08Eg7B9z4+Xy38r8RuZtieBbb0/qw1vzdHgdtluhnk0azVCve82OIJuT X-Received: by 2002:ac2:4d95:0:b0:513:5bdb:10f7 with SMTP id g21-20020ac24d95000000b005135bdb10f7mr4678903lfe.14.1711380535358; Mon, 25 Mar 2024 08:28:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711380535; cv=pass; d=google.com; s=arc-20160816; b=PdYKNvmmK+heEJlgaeOJoRyPCW/S0l2pWJy5XOWs00+l84/y2jUbYravDnkJ17wkvA ySVGKGfOvkQUfuaUW0oyk3ewYM9m8x6Vow7VEFSMrjlFCWUyn24E90lEo2wDCb710eXm hDpGCMFcpLu3oFtvYwEzgukirZg6bsTdXHJSu7KsenLuCyo/ZhlFSe/zzUPQM4sEUaaS i/eFF1zal2NHiJQ876IurTONkmruGeqLCC2J+cIicrSBrhw8onYM8k2qdiI0LKVWymDL Q+MEA5Bm/FxVaMwYLVAPRTEKrujR26N79ZjrsOh6CKCSkp/H/RfWLZ/iskUMZR+ZijB9 ODxA== 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=KxTkAB5EJ/JMwA5jrqjp3qxJsNtjpDvc2rvxzHauQ+s=; fh=LZIznCWl7/3IV5DJhE2wFP/Bkf5v4IlpVAEOQJqr0SE=; b=CLdweZXtC6CGY95tPQIJA5SI7A1R+JDLFjJt36DuV5A/t8e9EQULw9P4MC6KP36TFD iCTHO1YZcepRxP67pCU2SOzroIlSsHReFsD9cirtIQz1Hz+WptfhX08nNI+1dc5pYSHB RGBPJN4cAI17KllB0zSHHrffozh7Sr7m6ncEPxIJSUJn9UWKGbrpuArVPcEF+/QuzAkK B3jTJwQavAB71wx7E3D+N+SpRlCbEaAohLcm+jtmNbwxD48dO8boNxuDxUDvGSfa4fmd Dj3j3y0OXkHjhcXNa3TvymILZ2sejicXyueBfDdLEIgD9kYp0GJk403umgfLK83P5ZnS fC1A==; 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-117052-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117052-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. [147.75.80.249]) by mx.google.com with ESMTPS id z22-20020a170906271600b00a470bbe8f57si2416753ejc.487.2024.03.25.08.28.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:28:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117052-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-117052-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117052-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 92D4D1F61C4E for ; Mon, 25 Mar 2024 15:27:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 088F913A3EC; Mon, 25 Mar 2024 12:47:52 +0000 (UTC) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (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 509726FE2D; Mon, 25 Mar 2024 12:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370871; cv=none; b=pCbIDMHTFiSCAR43gBUFEPbgyqQy0BdZtcF0kiRbqpAAVEMs2STBXynqhfCAu0+dXU09+PzFzK9lFk8v87xmUoHA/3BJTDxSzIp0liVzqRC7y012VHkk8Dayy/WZy6ENxmOFnSX15Ox3z6Mq8MhPyvjeCE6FB18818RkeyAOwwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370871; c=relaxed/simple; bh=mBicbAa7DcKhcQvMOw8XzGlYsNKqsCpwlWVUsLePb4Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nCzk8QsHmFvuzcC77X2CvrPIoYLR7qsvY7PHk8duNOq+8yeokF54o05to0n5xptpQDmWmh/KOGHu7/68WgMsrXUPlN9X0cIFQcWMgZBpNvqgNLcQw9ndcDG5L/p2YIXG9TM2gxNe4ssR9BesRqd7U4SKyNHmLi3+iHSILFghAUY= 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.32 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.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4V3CPG3jtWz1vxgV; Mon, 25 Mar 2024 20:46:58 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id F253C1A0188; Mon, 25 Mar 2024 20:47:46 +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, 25 Mar 2024 20:47:46 +0800 From: Jijie Shao To: , , , , , , , , CC: , , , , , Subject: [PATCH V4 net 2/3] net: hns3: fix kernel crash when devlink reload during pf initialization Date: Mon, 25 Mar 2024 20:43:10 +0800 Message-ID: <20240325124311.1866197-3-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240325124311.1866197-1-shaojijie@huawei.com> References: <20240325124311.1866197-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: dggems704-chm.china.huawei.com (10.3.19.181) 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: 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_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index b4afb66efe5c..ff6a2ed23ddb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -11626,6 +11626,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) if (ret) goto err_pci_uninit; + devl_lock(hdev->devlink); + /* Firmware command queue initialize */ ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw); if (ret) @@ -11805,6 +11807,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) hclge_task_schedule(hdev, round_jiffies_relative(HZ)); + devl_unlock(hdev->devlink); return 0; err_mdiobus_unreg: @@ -11817,6 +11820,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) err_cmd_uninit: hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw); err_devlink_uninit: + devl_unlock(hdev->devlink); hclge_devlink_uninit(hdev); err_pci_uninit: pcim_iounmap(pdev, hdev->hw.hw.io_base); -- 2.30.0