Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp23740lql; Fri, 12 Apr 2024 02:22:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfK5IeVeaJyHyM3YCMg/POiQcv9gLE1+7IxF/nasXPaOvXcMQfMkkgi8b2Zr2oR68E3xcv+jVKa4ueQXbgIDxYdAa+I7KxVTAzLoCE1Q== X-Google-Smtp-Source: AGHT+IGg/rVDL1p2YVon2V5GtuPOfD6gFhHTRxnere/CuL2Bo0BgPiNBhBfBvoZbsx9NMtiGBto+ X-Received: by 2002:a17:907:2d88:b0:a51:dc8f:3619 with SMTP id gt8-20020a1709072d8800b00a51dc8f3619mr1512030ejc.67.1712913721111; Fri, 12 Apr 2024 02:22:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712913721; cv=pass; d=google.com; s=arc-20160816; b=rYT6n62av7biQQ4rJBkYOIUmQTE4mreWbLwrLYNDjySrZtKeB1N6gho5+jReaEGHKZ JMj2vX5ipWWgAZBHvwg3dpLm9c5A/zLOGMwPZMZ6rMG4TmOGPGCPL+/Crd8hq+ncTZ4O tTnxWfDImGjfDw0gIKvU9h+v4fy5D5NrOw2uhqWQtDl2EmzXdn+8xq/LCa+RzLv2JF1n 5BY/KH6IoyIGey2CqHX99vpRTDipNaBmpkawvYZTK25zKj/MMu77y3e75CQiFtFoACnF 28jTOMXUX3XD6mOL7/PcA+mR0qBPNjjYQNzISeL4akg8s4Z21UO1AijQIdqEG09DQx0Z lwCg== 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=wDwgXwnM4Lbsl6OALNQvnut8y7znjl9lh1W6xkjjX1w=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=NfzaVd6w+8xxhibLYc+wYRvQANgspMvhy8a5FfBlfQd64qNICuUIUxOeFqSTNhjiu9 YLiQ8nWc2tZfBuh6U909s5Dqe4GGSMATfLSEiaOG9jnlfYxrce3bVi68ZTDt6cC+m9fC Gi1SMG0s/nCoRKOK+iYd/gqK/6g4bFMSDnNBPpBZo+J1mP7blT6+lCjuvB9cOjVPB3Jt aclj4heaFtaWv6ZlagPuj1uH2QFlUEK+Nr7Fp5SzHb47TznZavMVmeL2KMGWZMfEyiMF VEbpCTROtsBonQqfP99l2fhssMror98MbC5VRS7UMy6YRm6eXrpUYDvaum01ni3rWvlI RIwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hisilicon.com dmarc=pass fromdomain=hisilicon.com); spf=pass (google.com: domain of linux-kernel+bounces-142389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.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 l17-20020a1709060e1100b00a4e24dcad27si1491741eji.898.2024.04.12.02.22.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 02:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142389-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=hisilicon.com dmarc=pass fromdomain=hisilicon.com); spf=pass (google.com: domain of linux-kernel+bounces-142389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.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 B3A7B1F224C3 for ; Fri, 12 Apr 2024 09:22:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2663F5490A; Fri, 12 Apr 2024 09:20:54 +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 722C551C5B; Fri, 12 Apr 2024 09:20:50 +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=1712913653; cv=none; b=DUWMwxzckHtteGH8erjQ0yYVlfBc3eusvPWkXtq3iLzTe6PVlram3yG0ktxPYcHSHEyhP1Z/pLBA/6KmPqvXyAc5P5PXA7W/1T8KqreOtvcKqBlQx8c6bt+asL1bLqP1JkBR/3ivh+Zbor2Ie5Cw/pI3Exdilak2TCWtYEGa/WI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712913653; c=relaxed/simple; bh=31rJ8Dui/r7OSm/CEjqbMvt4wFKJXRDqU2+rwk/A7Z8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QenUnwU0DU7apw7Jdi0SvaD2JgPTts3Pw8MMm73/1UVaG+gmF19iCb3vLxpUjb66ntLT2tCz76MTsfq16Sw/uWHHAZmYEqXRWlwtPUF3f3/Li3LYvNQo/v51hZYYpr37kN2fFlyWlAifa7pJxBWM/AiKSzXVCEc3r2QVR57Kys0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com; spf=pass smtp.mailfrom=hisilicon.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hisilicon.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VG9y01FzNz1wr4w; Fri, 12 Apr 2024 17:19:52 +0800 (CST) Received: from kwepemi500006.china.huawei.com (unknown [7.221.188.68]) by mail.maildlp.com (Postfix) with ESMTPS id 728231A016C; Fri, 12 Apr 2024 17:20:48 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 17:20:47 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-next 04/10] RDMA/hns: Fix deadlock on SRQ async events. Date: Fri, 12 Apr 2024 17:16:10 +0800 Message-ID: <20240412091616.370789-5-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240412091616.370789-1-huangjunxian6@hisilicon.com> References: <20240412091616.370789-1-huangjunxian6@hisilicon.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 kwepemi500006.china.huawei.com (7.221.188.68) From: Chengchang Tang xa_lock for SRQ table may be required in AEQ. Use xa_store_irq()/ xa_erase_irq() to avoid deadlock. Fixes: 81fce6291d99 ("RDMA/hns: Add SRQ asynchronous event support") Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_main.c | 1 + drivers/infiniband/hw/hns/hns_roce_srq.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 4d94fcb8685a..d202258368ed 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -37,6 +37,7 @@ #include #include #include +#include "hnae3.h" #include "hns_roce_common.h" #include "hns_roce_device.h" #include "hns_roce_hem.h" diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c index e4705ccdfa65..7210e53a82f3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_srq.c +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c @@ -123,7 +123,7 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) return ret; } - ret = xa_err(xa_store(&srq_table->xa, srq->srqn, srq, GFP_KERNEL)); + ret = xa_err(xa_store_irq(&srq_table->xa, srq->srqn, srq, GFP_KERNEL)); if (ret) { ibdev_err(ibdev, "failed to store SRQC, ret = %d.\n", ret); goto err_put; @@ -136,7 +136,7 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) return 0; err_xa: - xa_erase(&srq_table->xa, srq->srqn); + xa_erase_irq(&srq_table->xa, srq->srqn); err_put: hns_roce_table_put(hr_dev, &srq_table->table, srq->srqn); @@ -154,7 +154,7 @@ static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n", ret, srq->srqn); - xa_erase(&srq_table->xa, srq->srqn); + xa_erase_irq(&srq_table->xa, srq->srqn); if (refcount_dec_and_test(&srq->refcount)) complete(&srq->free); -- 2.30.0