From patchwork Thu Oct 31 13:26:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 3120531 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 A7EB49F3E2 for ; Thu, 31 Oct 2013 13:27:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C9BC203E6 for ; Thu, 31 Oct 2013 13:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C28272045A for ; Thu, 31 Oct 2013 13:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754394Ab3JaN1B (ORCPT ); Thu, 31 Oct 2013 09:27:01 -0400 Received: from mail-ea0-f177.google.com ([209.85.215.177]:58791 "EHLO mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754280Ab3JaN1A (ORCPT ); Thu, 31 Oct 2013 09:27:00 -0400 Received: by mail-ea0-f177.google.com with SMTP id f15so1360355eak.8 for ; Thu, 31 Oct 2013 06:26:59 -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=Y1u5UreWBvihq92lE/FHix31SxwpGeBD+nsDdamtrnw=; b=lcT1RcmZ67/Sa9xMiqfJ99slj48N29IpFbNVbUntPPJEh4Mgg2a9b/3XGiTt2Mjgai 5MQUp6cnFit/qLCOUEqu0Eu44YAwlKFSNlhIWlAGSx4ehRPd+ByUL3KmC/wrKDDAZC2u 9sDugphabnV+ulXq2FeCDSdsvkVC+fNUWWQnxWQyYPc8B0xpC8Ki6/x2ghu2GyK70aDW bmgcvi33Kap6+ORPCjcqbMxDMzDyiMWDPOANHmek8ALNE89ZGvTqK77LjXaovXR2sDCW 3sQ/R63i0EXv/mZs5XC1xGaAgkOdtlEo5IzI/aw4cgCM+vK50gTose15fy6XMrumfDp2 5UEQ== X-Gm-Message-State: ALoCoQn7h4r3lpea09Zu5uF5AJOz9XDrGN0Be6pDpNjNvgcpW94j7XExsf99VWGWuWYxGslT6M0s X-Received: by 10.14.29.67 with SMTP id h43mr3231803eea.7.1383226019668; Thu, 31 Oct 2013 06:26:59 -0700 (PDT) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id w6sm8544356eeo.12.2013.10.31.06.26.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 31 Oct 2013 06:26:59 -0700 (PDT) From: Eli Cohen To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, amirv@mellanox.com, ogerlitz@mellanox.com, yevgenyp@mellanox.com, Eli Cohen Subject: [PATCH for-next 4/6] IB/mlx4: Fix device max capabilities check Date: Thu, 31 Oct 2013 15:26:34 +0200 Message-Id: <1383225996-14828-5-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.8.4.1 In-Reply-To: <1383225996-14828-1-git-send-email-eli@mellanox.com> References: <1383225996-14828-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.4 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 Move the check on max supported CQEs after the final number of entries is evaluated. Signed-off-by: Eli Cohen --- drivers/infiniband/hw/mlx4/cq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index d5e60f4..ea29951 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c @@ -365,7 +365,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) mutex_lock(&cq->resize_mutex); - if (entries < 1 || entries > dev->dev->caps.max_cqes) { + if (entries < 1) { err = -EINVAL; goto out; } @@ -376,6 +376,11 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) goto out; } + if (entries > dev->dev->caps.max_cqes) { + err = -EINVAL; + goto out; + } + if (ibcq->uobject) { err = mlx4_alloc_resize_umem(dev, cq, entries, udata); if (err)