Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp124578lqr; Wed, 5 Jun 2024 00:29:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0VhQwgnwRYl1dqvYinVGJKYdlwT6EThZifDNH3WTQaYElHOtipQldCBlLUEErbMkYhjyMlsWxdTJJslsAWg0y4jXXRMdX8hyejZF2HQ== X-Google-Smtp-Source: AGHT+IECGG8x6LNv5CwRjR/oBVvH3tuT4SOALnfnc18dj5RsuDxI+OMArqkApgRi5Y8v4ZHyko6e X-Received: by 2002:a17:902:d503:b0:1f6:7a56:eefd with SMTP id d9443c01a7336-1f6a5a84875mr22281905ad.63.1717572586629; Wed, 05 Jun 2024 00:29:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717572586; cv=pass; d=google.com; s=arc-20160816; b=zHRheN8nQ+GM2BZBN8pkLqexwvQnl8sZ0Cyq7CJdOpKX1SQpV0uncX1kULB+JjXCE9 LeZAt+Wb5xN/mqIJzhjrMuSrx1vItmo3kWwaczCHrToWj7XqnLfWadr5xP5XxZ2Y5E13 /MdZ+SchGPoLT8slAaYIgN27aujGI733oct1JZbUq74oOtG5myS6oZw17Jq7ueYIFlB3 ToxEJPqBDq7xFEJukz15lFxaUSRGzYs8NCd+RoXZVxJ7Y41YylU85/k8tPtjUgiVo6+5 q4712vGHfnnGGB33deRkD1K8TL9XwbRa1oAB9aWe2t6clpz8rUc/KVVfY87C2Wcn1Yf9 w+rA== 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=icQgEKVwug1YXsESNFTk9+DQnGaSe2E1KZaTswr4NvA=; fh=8eoVmgxLw0HCyOKEL9MuHelSJxvYTGQ3f7Aprt836Kg=; b=BjfjzrMxyfjzYEL2lnBhn04JcoHn/gQ698LAcCCT1McT+AxLCE7N8E/OskyNkzDsbv YQsjmBBWFEu3mMBpalBqOvRQDL1hiytRT64ZUPMSaezP7ZOcmSkbGj0YAXxtqMG4rUMh Q/v67Q//BmIu6bdZGoE80bRGDmeAiLBP1C64yL0mg9NP44s4ROkQMVvDvpXjkEUKHlLf ulJmkBIKmLCnm/Clz+fo0ZKINUkEB+rAL7HOSYPUzTjg2VfS5g9UwNH9o3ul0k2YZdgA jju2uOQWt70z7c4T+V8D7AnycbYLrSvSK2o66ro7nBDNEg4OhESei7Ls8KIsSoosMA1I zClA==; 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-201879-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201879-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6613adb74si67653455ad.257.2024.06.05.00.29.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 00:29:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201879-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-201879-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201879-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4AFB0283640 for ; Wed, 5 Jun 2024 07:27:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B6B113AA4D; Wed, 5 Jun 2024 07:26:44 +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 2736F1922C6; Wed, 5 Jun 2024 07:26:41 +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=1717572403; cv=none; b=Vi5hPkJkso4D0RdKfiUnk7LbXlHXtpmRA6Xg+hwiyBewLEWxp0FIgcMdr1qUeXZNk3jTKnEDvvacnSrsxfz54GJYj/Nw06BibPMO0Mchr9XOKgXxM6Ruij3E9nQOsC3vaVkZ8oiGH4GS1Wikq2hsqkEfdYLIKliCWrDsaJ5eG8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717572403; c=relaxed/simple; bh=FKIZEf2ysiTZQR58LOzGdSvTtcWUNam11v1970Usiqc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n1SdPc3wCXlpS22JerXuBkTMyX2RsSTJa2SKlMjYRCr8zBC4OmgopeZFdZsifajUCCOQdHW0FGcrClgYwI4FZkMPIFBCJnIgqiYy17PNITz26CPfltG3o5REdt4eFqg/rPy7B9vkier78suZeSLpBO6iUlmVihpI1z6h8uaLbA0= 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.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VvJrq04TNzcldM; Wed, 5 Jun 2024 15:25:15 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 1127C14011A; Wed, 5 Jun 2024 15:26:24 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) 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.39; Wed, 5 Jun 2024 15:26:08 +0800 From: Jijie Shao To: , , , , , , CC: , , , , , , Subject: [PATCH net 1/2] net: hns3: fix kernel crash problem in concurrent scenario Date: Wed, 5 Jun 2024 15:20:57 +0800 Message-ID: <20240605072058.2027992-2-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240605072058.2027992-1-shaojijie@huawei.com> References: <20240605072058.2027992-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: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600007.china.huawei.com (7.193.23.208) From: Yonglong Liu When link status change, the nic driver need to notify the roce driver to handle this event, but at this time, the roce driver may uninit, then cause kernel crash. To fix the problem, when link status change, need to check whether the roce registered, and when uninit, need to wait link update finish. Fixes: 45e92b7e4e27 ("net: hns3: add calling roce callback function when link status change") Signed-off-by: Yonglong Liu Signed-off-by: Jijie Shao --- .../hisilicon/hns3/hns3pf/hclge_main.c | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 43cc6ee4d87d..82574ce0194f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3086,9 +3086,7 @@ static void hclge_push_link_status(struct hclge_dev *hdev) static void hclge_update_link_status(struct hclge_dev *hdev) { - struct hnae3_handle *rhandle = &hdev->vport[0].roce; struct hnae3_handle *handle = &hdev->vport[0].nic; - struct hnae3_client *rclient = hdev->roce_client; struct hnae3_client *client = hdev->nic_client; int state; int ret; @@ -3112,8 +3110,15 @@ static void hclge_update_link_status(struct hclge_dev *hdev) client->ops->link_status_change(handle, state); hclge_config_mac_tnl_int(hdev, state); - if (rclient && rclient->ops->link_status_change) - rclient->ops->link_status_change(rhandle, state); + + if (test_bit(HCLGE_STATE_ROCE_REGISTERED, &hdev->state)) { + struct hnae3_handle *rhandle = &hdev->vport[0].roce; + struct hnae3_client *rclient = hdev->roce_client; + + if (rclient && rclient->ops->link_status_change) + rclient->ops->link_status_change(rhandle, + state); + } hclge_push_link_status(hdev); } @@ -11319,6 +11324,12 @@ static int hclge_init_client_instance(struct hnae3_client *client, return ret; } +static bool hclge_uninit_need_wait(struct hclge_dev *hdev) +{ + return test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) || + test_bit(HCLGE_STATE_LINK_UPDATING, &hdev->state); +} + static void hclge_uninit_client_instance(struct hnae3_client *client, struct hnae3_ae_dev *ae_dev) { @@ -11327,7 +11338,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, if (hdev->roce_client) { clear_bit(HCLGE_STATE_ROCE_REGISTERED, &hdev->state); - while (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) + while (hclge_uninit_need_wait(hdev)) msleep(HCLGE_WAIT_RESET_DONE); hdev->roce_client->ops->uninit_instance(&vport->roce, 0); -- 2.30.0