From patchwork Wed Oct 23 06:53:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 3086191 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A88619F2B7 for ; Wed, 23 Oct 2013 06:53:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7D46202C1 for ; Wed, 23 Oct 2013 06:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB6DC202B8 for ; Wed, 23 Oct 2013 06:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196Ab3JWGxh (ORCPT ); Wed, 23 Oct 2013 02:53:37 -0400 Received: from mail-ee0-f49.google.com ([74.125.83.49]:38301 "EHLO mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051Ab3JWGxg (ORCPT ); Wed, 23 Oct 2013 02:53:36 -0400 Received: by mail-ee0-f49.google.com with SMTP id e51so149649eek.8 for ; Tue, 22 Oct 2013 23:53:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fpHjlIgkr8ZIHHP53m7xGpeC11ih/L4h27Vwc42mTr4=; b=ZODUT0Rr52NwuWJhvOk+GyuijAOTxPc3LC4RMC04RgUvNfyuCrvMp7tgyZc12NMm2B xNW9Z7Tab0VNCUeNNhjnktVfwqNT4PtQbHzxNwdKV/NPMn8OBw4xwhdhmZ5xSk02ApAC PZKDVUktpXgDFc/4PluuDbIy8Jiq7JJrD9C1bn9YF7cv47xAFn6rGPwPQ70tH4rzOiuJ 6Eu6rWIlw/H22oyRaqSeX0jAgFGf6DD0zCt7GlKT/wATmETnTGWHsqk/fpBjMa9GXsgU mXJJYKHHn2CLbs+osyFmgOLa0PYriZ1eNgUkau2rG1GbqTp7zDKfc6OXuOWJiEtnpQLr ii5Q== X-Gm-Message-State: ALoCoQnPflxpgM1ZU6c4bri2C+ne6CyZ7SIO0c9kc5b2uv9Mru6PshG4Rw3a/l3YQD67v3DGKFgF X-Received: by 10.14.122.8 with SMTP id s8mr86318eeh.106.1382511215711; Tue, 22 Oct 2013 23:53:35 -0700 (PDT) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id m54sm66275769eex.2.2013.10.22.23.53.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Oct 2013 23:53:35 -0700 (PDT) From: Eli Cohen To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, amirv@mellanox.com, ogerlitz@mellanox.com, yevgenyp@mellanox.com, Moshe Lazer , Eli Cohen Subject: [PATCH for-next 5/9] IB/mlx5: Fix srq free in destroy qp Date: Wed, 23 Oct 2013 09:53:17 +0300 Message-Id: <1382511201-7061-6-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1382511201-7061-1-git-send-email-eli@mellanox.com> References: <1382511201-7061-1-git-send-email-eli@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Moshe Lazer On destroy QP the driver walks over the relevant CQ and removes CQEs reported for the destroyed QP. It also frees the related SRQ entry without checking that this is actually SRQ related CQE. In case of a CQ used for both send and receive QP, we could free srq entries for send CQEs. This patch resolves this issue by verifying that this is a SRQ related CQE by checking the SRQ number in the CQE is not zero. Signed-off-by: Moshe Lazer Signed-off-by: Eli Cohen --- drivers/infiniband/hw/mlx5/cq.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index e7c64c5..8459186 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -750,17 +750,9 @@ int mlx5_ib_destroy_cq(struct ib_cq *cq) return 0; } -static int is_equal_rsn(struct mlx5_cqe64 *cqe64, struct mlx5_ib_srq *srq, - u32 rsn) +static int is_equal_rsn(struct mlx5_cqe64 *cqe64, u32 rsn) { - u32 lrsn; - - if (srq) - lrsn = be32_to_cpu(cqe64->srqn) & 0xffffff; - else - lrsn = be32_to_cpu(cqe64->sop_drop_qpn) & 0xffffff; - - return rsn == lrsn; + return rsn == (ntohl(cqe64->sop_drop_qpn) & 0xffffff); } void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 rsn, struct mlx5_ib_srq *srq) @@ -790,8 +782,8 @@ void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 rsn, struct mlx5_ib_srq *srq) while ((int) --prod_index - (int) cq->mcq.cons_index >= 0) { cqe = get_cqe(cq, prod_index & cq->ibcq.cqe); cqe64 = (cq->mcq.cqe_sz == 64) ? cqe : cqe + 64; - if (is_equal_rsn(cqe64, srq, rsn)) { - if (srq) + if (is_equal_rsn(cqe64, rsn)) { + if (srq && (ntohl(cqe64->srqn) & 0xffffff)) mlx5_ib_free_srq_wqe(srq, be16_to_cpu(cqe64->wqe_counter)); ++nfreed; } else if (nfreed) {