From patchwork Wed Sep 11 18:29:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13800972 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 302F0185B7B for ; Wed, 11 Sep 2024 18:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080639; cv=none; b=rmxhBQmyF7xtDyFK2Vmcbn1TGeNuFpQHPPvvnBQJSoUCnRg3xgVxnd09MHD95kl6sN4TbuLTJCzriW2GDQL+/176+tTO78O9IJKbJ4hwgUzUs4UMxZ3f5Z+5oGDDe94kgsbZ2PAZP9eSFfV/sdcs6asiGbsu0j8O5k5P64qAYKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080639; c=relaxed/simple; bh=9L7/UMGLYd23DqnqG0vpJIms0XbZ75xz8nRJnSIrlDU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=TIRB2UyHSf1DD9mHacnZssIC35WZ3tk5u0b7ppe3hFpFy7oesTbf3ss5NHL3CvKyQp/bYOLQJHguKJXL15NSiPGrHXVBugehEN2nT6nyZ2FbBJqc5iJkWQxcP+NsYkLA2bvA5gV90/Vdk5WhVnMhwfeyo/S11C6ZjNLKl0caJAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=ImIR+yT8; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ImIR+yT8" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2d88690837eso108381a91.2 for ; Wed, 11 Sep 2024 11:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1726080637; x=1726685437; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=ASJBR2WWDc5Ivil9kGHYQQCa3Eo0/d547rlwumu8ksM=; b=ImIR+yT8jFBgc73ZsoYmKBnu32H9c2/T6gJvuUqQWDMraVNSjQefc7ZhP7lHycxgBY IQBRoRdcqH/pURVbsxQrpg5sioTyFuZtFCndin9OMTK/FIHDTQ8go1cUPi+4ULu4fTQc t2hnc6ubxWJ3X8UynxXvXO606Ayi/4qdNWOq0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726080637; x=1726685437; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ASJBR2WWDc5Ivil9kGHYQQCa3Eo0/d547rlwumu8ksM=; b=jd3f9HodVpgjNebhJQFuWgBrj6Bg1yYVTFUT888eS06ihz4+7yI7IylxeKAdznoYkk jaPoeYIXXJmxsMw9w0/8f4WduVBfgwiFdb1cSJEjxIImVoxx6c+VKXbTummbU7SQpJEV +4oiyxyvJ6nBdoUZOowTBNz8bs54ibrBP2X6T82FT7Zh8+iS00t/BWAPipFft5KPIndL 9FK8YhTag6tUPSAt8ZGznBwuJV6+KbVJGg5p48ZCrbOuI4luMxCqu9MAuThciDLYjvUb pQkWTpN5XMXUmm7/WHB3YHzxbLZF1Uzh7BKDFbInTysSdhdB4XIKYtA8N8jYRwY7ns43 Zb2A== X-Gm-Message-State: AOJu0YzP8b2u0YztU1RYDm7dcgsx5BWU8HU2DSNwlFemvq51hQgGnapq J/XBQNXGTgdvArvuM3ugIOR93ZgZ8EpufDWBWGxpx2JA/FdlYK+Ba5oROrY3VA== X-Google-Smtp-Source: AGHT+IGZZbQg06YFwBWUxmSzoDr+bay7AO1SZnQxHtrGkB2dUKBswt4uLLrvt/f2U3v1OhkooCS1PA== X-Received: by 2002:a17:90a:7407:b0:2d8:8252:f675 with SMTP id 98e67ed59e1d1-2dba007f0a6mr149600a91.39.1726080637062; Wed, 11 Sep 2024 11:50:37 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db043c59c9sm8903996a91.24.2024.09.11.11.50.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Sep 2024 11:50:34 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, kalesh-anakkur.purayil@broadcom.com, Selvin Xavier Subject: [PATCH 1/4] RDMA/bnxt_re: Fix a possible memory leak Date: Wed, 11 Sep 2024 11:29:36 -0700 Message-Id: <1726079379-19272-2-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> References: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Kalesh AP In bnxt_re_setup_chip_ctx() when bnxt_qplib_map_db_bar() fails driver is not freeing the memory allocated for "rdev->chip_ctx". Fixes: 0ac20faf5d83 ("RDMA/bnxt_re: Reorg the bar mapping") Signed-off-by: Selvin Xavier Signed-off-by: Kalesh AP --- drivers/infiniband/hw/bnxt_re/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 16a84ca..72719c8 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -186,8 +186,11 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev) bnxt_re_set_db_offset(rdev); rc = bnxt_qplib_map_db_bar(&rdev->qplib_res); - if (rc) + if (rc) { + kfree(rdev->chip_ctx); + rdev->chip_ctx = NULL; return rc; + } if (bnxt_qplib_determine_atomics(en_dev->pdev)) ibdev_info(&rdev->ibdev, From patchwork Wed Sep 11 18:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13800973 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E169C185B7B for ; Wed, 11 Sep 2024 18:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080645; cv=none; b=M0kT60QYb8cWzqjFzbZGsJGHUIYqPd8AvKIYYpffAd8/2/UESAxXGXhJ3FSZgLJ+lbKPBd8f3fJwUZie7rx521NeZXhEVUCit7G22wMwf82k1sCgzsjUPbkPtWpEIn2qHlefzg6niw91ZyorPFwmIG1Ey2o3RJfwDOgSPMnPmjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080645; c=relaxed/simple; bh=RAHEbb/L3GHBY0KmyIFigaHmB+Zy8cl5UTiMWrSXoJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=KW6jySROtpK7UYjlU6YUqH/WQmgjKDG2d1JlOnDiBeVNfJG8rUR7zZdFpKGFRKZUB2jMqUBadXBwPlw2SnQprY/1xFFmex8LBEb22NXPyMFvzBMbdQqaSEutjtS/i2dSmU3wO5VJgXU7GCA6ZqBiaLTOY+RxhZOpovIA/8wqeyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=ZzCAVY3a; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ZzCAVY3a" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2d87f34a650so72889a91.1 for ; Wed, 11 Sep 2024 11:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1726080643; x=1726685443; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=03ASqymI4RekJ50OKXabyHgax5n64huK2dd3ddiQAlM=; b=ZzCAVY3a7SjP7I+QnvfK0FDSIrDnpiGstBtALiyTNany3lrR6lGSfZHwgiJgZwiSAd F9wuu5tVSPHKGVzP7cZK5ikNCuD440Y5EiHJ+1HxWZG4/SFGGYFQYjWyjp5xYGSpmKhY T22gLey+FQKZBoJTm6cGqc7meAZmBKlVaP0JY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726080643; x=1726685443; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=03ASqymI4RekJ50OKXabyHgax5n64huK2dd3ddiQAlM=; b=NzlHJxA16xiyryD/OzXu0+syUk4n52masHoHLs25fuyNzPn4j5EYdr/zW4gT00faq+ OfmF9ELliVTqWOAhjOLN6tE/1Hryqlzk/NcjXa3wID1JoaORprlRHLVAWO86Zz3j3SLe ZGT+8BBd1mdTsk8ytEIUPVZbeyXAitYUO/QCaZeGsjhcBCxmOMyTR0j2xfvFQm41UIsV /zQ5HRndh4n1skOAIhieGftpudiivOBf29/+clLKJwoeYsAssT3KAHs2s6CeSP0brBS7 bSnvAwvVMf6XoEe2GSb2VWVwLRKathZG9urWZjM3VEUp4K/26UDnQevZAmIZ2B5c3Cha is8g== X-Gm-Message-State: AOJu0Ywhx518x3uomTayVcu/D6SKaH3tjF+RKopKN3zT041y+PeJSxmN HCsVSENHKEmLGKqUXofXuRI0FEXSraAtqh6HDkodNNceYMPvNV6jra+8609hgA== X-Google-Smtp-Source: AGHT+IHFC2/WVtgDC+uBoq6F83l3zP3byj0A+mlwYj5lGRgf/3BKcT6O6lauE09rqPWca4a5slhjrw== X-Received: by 2002:a17:90a:9b07:b0:2da:6e46:ad48 with SMTP id 98e67ed59e1d1-2db9fc19c32mr465184a91.1.1726080641968; Wed, 11 Sep 2024 11:50:41 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db043c59c9sm8903996a91.24.2024.09.11.11.50.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Sep 2024 11:50:39 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, kalesh-anakkur.purayil@broadcom.com, Saravanan Vajravel , Selvin Xavier Subject: [PATCH 2/4] RDMA/bnxt_re: Fix incorrect AVID type in WQE structure Date: Wed, 11 Sep 2024 11:29:37 -0700 Message-Id: <1726079379-19272-3-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> References: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Saravanan Vajravel Driver uses internal data structure to construct WQE frame. It used avid type as u16 which can accommodate up to 64K AVs. When outstanding AVID crosses 64K, driver truncates AVID and hence it uses incorrect AVID to WR. This leads to WR failure due to invalid AV ID and QP is moved to error state with reason set to 19 (INVALID AVID). When RDMA CM path is used, this issue hits QP1 and it is moved to error state Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Reviewed-by: Selvin Xavier Reviewed-by: Chandramohan Akula Signed-off-by: Saravanan Vajravel Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.h b/drivers/infiniband/hw/bnxt_re/qplib_fp.h index b62df87..820611a 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.h @@ -170,7 +170,7 @@ struct bnxt_qplib_swqe { }; u32 q_key; u32 dst_qp; - u16 avid; + u32 avid; } send; /* Send Raw Ethernet and QP1 */ From patchwork Wed Sep 11 18:29:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13800974 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 448F1185B7B for ; Wed, 11 Sep 2024 18:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080648; cv=none; b=hbTiMej/MNkoHyAcUhCgnwB0k5dtIfbAWUc9LNLXOPpjZ6R/KwkOHY42brnRxYM2llnorVbX4/ryYhtQZPPaty48hSVhdku/BIvKXuJk2ZNDDZ0Vil7P+g4mM9f1eAJn2DCo1YT4be4Lx/UgwHKngKmn2SH6J3HvP8mlMRlcUmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080648; c=relaxed/simple; bh=yHJBT0zktJrwBrQeXQk5Sz2r4oLmjnHknn8GxycdboY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=uINS3IJEdaO7TRzksQ6AIPJB4LfnRXwDSX5BH7Bj1gJ5n5nJfWz/f6m00yQgekcAJjL9/oFdQhR5bRu9TjDuCkfJBa+BwqN9THU4C7VWWe0trWItBSoQGEDfCtBUsg8jTk9Be6x98qfDsTgL+D9cu9tSZh14ZiGBgmygoTz7CpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Q3CpBEoX; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Q3CpBEoX" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2d89229ac81so121312a91.0 for ; Wed, 11 Sep 2024 11:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1726080646; x=1726685446; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=zfPUA/rgj8ZO5zioWhOvpSaAURSYsjgbOH0/+cb7F4w=; b=Q3CpBEoXPunKd2WqgQNSDdS5ZUeMGI0ttt1hubj8NaAvfYXeQ2dHnz1+2OqJC1fbkv Q/BEwGAnweNn/CEDN7MPeClvYUGHPDuqiE47AoIQ+QkYx8xlnAlhks4XMIktImOH7gYD fSLwthnLvsK93Wv/4ZclfKFH35kn0kCRqm3Rw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726080646; x=1726685446; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zfPUA/rgj8ZO5zioWhOvpSaAURSYsjgbOH0/+cb7F4w=; b=HpMQ/ayO4/hj+Pmqi7xxywgkrzSyREsWEqtY9HEeMmcpflnlwXwGEruTPcVzX9X5LR 7q58WnEOhwE6QUNV4Kr/wbZ7rEevyh/UgCwqCyBTQhxy/wWKOVlCMBumaKLJ/m+bJnUC psQ7j0cxFRrsRSVNS5cWyeK6wxxVfvWwEUmmjodpgxKpIObOGh0QUHNE9SqKu3rOF0vY Ehcvo3crKqybutE2SkV4f4/1rDy3JN6Pftiys85IMGWf1UsYkWN+a8o7ZiMJkqGUYbEc bPIVft6v5foLMkoNye4r/hGa1RvtiPijA+AKVwJbv2M8rkFYaU5WXvyNTrHIJrHAJklD ex2g== X-Gm-Message-State: AOJu0Yz8e4AzNveXKXeyJVyGXOB8d8pagZRtzga6FDMzOrA4dppYL8tZ Sb7G6ULwSqsmEdGvjQpgKDvDueph38NOURvGNkTYZBS11DUHwe10Q/NbF2gVkw== X-Google-Smtp-Source: AGHT+IGk8rWXghLIr8rlw7K4ecESAOLfLZ3bFPV/9jTQzleufcYWlBp6O8YS1mgwrjWsCQ+3EU1HFg== X-Received: by 2002:a17:90a:5143:b0:2d3:cc31:5fdc with SMTP id 98e67ed59e1d1-2db9ff778camr238583a91.5.1726080646268; Wed, 11 Sep 2024 11:50:46 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db043c59c9sm8903996a91.24.2024.09.11.11.50.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Sep 2024 11:50:44 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, kalesh-anakkur.purayil@broadcom.com, Selvin Xavier Subject: [PATCH 3/4] RDMA/bnxt_re: Add a check for memory allocation Date: Wed, 11 Sep 2024 11:29:38 -0700 Message-Id: <1726079379-19272-4-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> References: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Kalesh AP __alloc_pbl() can return error when memory allocation fails. Driver is not checking the status on one of the instances. Fixes: 0c4dcd602817 ("RDMA/bnxt_re: Refactor hardware queue memory allocation") Reviewed-by: Selvin Xavier Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/qplib_res.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c index dfc943f..1fdffd6 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -244,6 +244,8 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, sginfo.pgsize = npde * pg_size; sginfo.npages = 1; rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_0], &sginfo); + if (rc) + goto fail; /* Alloc PBL pages */ sginfo.npages = npbl; From patchwork Wed Sep 11 18:29:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13800975 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47FAA185B7B for ; Wed, 11 Sep 2024 18:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080654; cv=none; b=XCzjhogJJ+BvnCxxITQvzX5OGUxKalWZ9UtTEpBE6Ji1fTW1bqht1AQpVlIUrlRM0as3/EaOG6elN1miwvOPN4Y/vocRdnCkdUEcuh+SnwRBj3fWKXBVp9LmYqCjBVljHyhLt3ZrsVqTwAdimHYV2mB9EcdYLgUdEHfYMhGvQNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726080654; c=relaxed/simple; bh=TFhIUDjNNH8A27fvpNJ0/3PPGEnLoedez1gLe8fwGFY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=eBfKB5BbIuma+0zG5iHsiPmQcogk6Qs764cANpXCUn5eHeBLlPjK8xvQBTvVheRf4mMHYG7Gd8+X5SnoP9ykXFwy1X6GhEwre68pYXCzPyZCDWUqzXI2OTsglam5vXonoViPkEkDSVfjH1rc0B1Ikuh17OpBqca+PQx9Bkj/W3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=FVcguovH; arc=none smtp.client-ip=209.85.215.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="FVcguovH" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-6bce380eb96so141137a12.0 for ; Wed, 11 Sep 2024 11:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1726080653; x=1726685453; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=iDJP6e9UtZclHxRKRcKW7PoXjp4eF1sxnMZsWT6VSdk=; b=FVcguovHep7TTJn/LKkIl8+n/38i/rC4tA7o1y+FKFoPlXp4RPvu84Y0BuU7I+bWBS 8krYPa4n6ZEcpW7RoGJqwQqfXtvRkfjEJ6STDuV/HIh00ZiI1OCOkdwxAmnC7xJtrB2o vDZDpHMgEu8rxNeeTyfJD4yW3rlxzf0u9UZso= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726080653; x=1726685453; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iDJP6e9UtZclHxRKRcKW7PoXjp4eF1sxnMZsWT6VSdk=; b=Jn3tGEFPGw2Jv2kr801z4ORNqONJdpqiPLUGmLqmM1Gh3iH/9agqs74J4lHnE6RVL4 FRsfh9Vee4OUD4d7YCX8QNhE02OudEQYHviJ94NIZLSCpvJI372qkB/3wHBLmIxAkVxe N06A07egB4AahqhoJk/czh0iTO6eriZpYHS0MoNNq6EdWWfrTW0NyA5KteHdiPObkN++ ae4Yiva7qBxM4QKlEQAb19uRVoNENnZ51oeGknQe3/d1G2Pq7oywZb0Pqd3BODxUhQ/2 sObo1xpWWYl/gcr1+ZoNW24U1rL7u32UdmqbxaRhNQcgWYKRuBv6IvWnFQzc62WkLtpS Gpuw== X-Gm-Message-State: AOJu0Yw13DvtM+iBe4o9qQ20QTuhlw0h/jLUCbOkQwRecxJOY3+YpG+Z QztIX9gDMR05cjcW/+Nzn/MPjZcMRqhpl/W1QkR1/KDNytndwc/epEZ4u8kJHA== X-Google-Smtp-Source: AGHT+IHo6BH+gfiKDDMSU3+QJoyuV8z6/3f5x/HlZuFF8IFbMTCnJTegp2gBkYaEiCQDO/OjUmineQ== X-Received: by 2002:a05:6a21:330b:b0:1cf:4c48:5bf8 with SMTP id adf61e73a8af0-1cf76237d83mr241821637.44.1726080652411; Wed, 11 Sep 2024 11:50:52 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db043c59c9sm8903996a91.24.2024.09.11.11.50.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Sep 2024 11:50:48 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, kalesh-anakkur.purayil@broadcom.com, Selvin Xavier Subject: [PATCH 4/4] RDMA/bnxt_re: synchronize the qp-handle table array Date: Wed, 11 Sep 2024 11:29:39 -0700 Message-Id: <1726079379-19272-5-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> References: <1726079379-19272-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: There is a race between the CREQ tasklet and destroy qp when accessing the qp-handle table. There is a chance of reading a valid qp-handle in the CREQ tasklet handler while the QP is already moving ahead with the destruction. Fixing this race by implementing a table-lock to synchronize the access. Fixes: f218d67ef004 ("RDMA/bnxt_re: Allow posting when QPs are in error") Fixes: 84cf229f4001 ("RDMA/bnxt_re: Fix the qp table indexing") Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 5 +++++ drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 12 ++++++++---- drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index 42e98e5..5d36216 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c @@ -1524,12 +1524,15 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct creq_destroy_qp_resp resp = {}; struct bnxt_qplib_cmdqmsg msg = {}; struct cmdq_destroy_qp req = {}; + unsigned long flags; u32 tbl_indx; int rc; + spin_lock_irqsave(&rcfw->tbl_lock, flags); tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw); rcfw->qp_tbl[tbl_indx].qp_id = BNXT_QPLIB_QP_ID_INVALID; rcfw->qp_tbl[tbl_indx].qp_handle = NULL; + spin_unlock_irqrestore(&rcfw->tbl_lock, flags); bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)&req, CMDQ_BASE_OPCODE_DESTROY_QP, @@ -1540,8 +1543,10 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, sizeof(resp), 0); rc = bnxt_qplib_rcfw_send_message(rcfw, &msg); if (rc) { + spin_lock_irqsave(&rcfw->tbl_lock, flags); rcfw->qp_tbl[tbl_indx].qp_id = qp->id; rcfw->qp_tbl[tbl_indx].qp_handle = qp; + spin_unlock_irqrestore(&rcfw->tbl_lock, flags); return rc; } diff --git a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c index 3ffaef0c..993c356 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c @@ -637,17 +637,21 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, case CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION: err_event = (struct creq_qp_error_notification *)qp_event; qp_id = le32_to_cpu(err_event->xid); + spin_lock(&rcfw->tbl_lock); tbl_indx = map_qp_id_to_tbl_indx(qp_id, rcfw); qp = rcfw->qp_tbl[tbl_indx].qp_handle; + if (!qp) { + spin_unlock(&rcfw->tbl_lock); + break; + } + bnxt_qplib_mark_qp_error(qp); + rc = rcfw->creq.aeq_handler(rcfw, qp_event, qp); + spin_unlock(&rcfw->tbl_lock); dev_dbg(&pdev->dev, "Received QP error notification\n"); dev_dbg(&pdev->dev, "qpid 0x%x, req_err=0x%x, resp_err=0x%x\n", qp_id, err_event->req_err_state_reason, err_event->res_err_state_reason); - if (!qp) - break; - bnxt_qplib_mark_qp_error(qp); - rc = rcfw->creq.aeq_handler(rcfw, qp_event, qp); break; default: /* diff --git a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.h b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.h index 45996e6..07779ae 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.h @@ -224,6 +224,8 @@ struct bnxt_qplib_rcfw { struct bnxt_qplib_crsqe *crsqe_tbl; int qp_tbl_size; struct bnxt_qplib_qp_node *qp_tbl; + /* To synchronize the qp-handle hash table */ + spinlock_t tbl_lock; u64 oos_prev; u32 init_oos_stats; u32 cmdq_depth;