From patchwork Tue Dec 1 22:20:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chien Tung X-Patchwork-Id: 64063 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB1MJlFS031857 for ; Tue, 1 Dec 2009 22:20:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754072AbZLAWT6 (ORCPT ); Tue, 1 Dec 2009 17:19:58 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754133AbZLAWT6 (ORCPT ); Tue, 1 Dec 2009 17:19:58 -0500 Received: from mga14.intel.com ([143.182.124.37]:30492 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754072AbZLAWT5 (ORCPT ); Tue, 1 Dec 2009 17:19:57 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 01 Dec 2009 14:20:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,316,1257148800"; d="scan'208";a="217648764" Received: from ctung-mobl.amr.corp.intel.com (HELO ctung-MOBL.intel.com) ([10.232.237.216]) by azsmga001.ch.intel.com with SMTP; 01 Dec 2009 14:20:03 -0800 Received: by ctung-MOBL.intel.com (sSMTP sendmail emulation); Tue, 01 Dec 2009 16:20:02 -0600 Date: Tue, 1 Dec 2009 16:20:02 -0600 From: Chien Tung To: Roland Dreier Cc: linux-rdma@vger.kernel.org Subject: [PATCH 8/9] RDMA/nes: Add max_cqe check to nes_create_cq() Message-ID: <20091201222002.GA7488@ctung-MOBL> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c index b59ca56..6f625a9 100644 --- a/drivers/infiniband/hw/nes/nes_hw.c +++ b/drivers/infiniband/hw/nes/nes_hw.c @@ -482,7 +482,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { nesadapter->max_irrq_wr = (u32temp >> 16) & 3; nesadapter->max_sge = 4; - nesadapter->max_cqe = 32767; + nesadapter->max_cqe = 32766; if (nes_read_eeprom_values(nesdev, nesadapter)) { printk(KERN_ERR PFX "Unable to read EEPROM data.\n"); diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index e929684..e09d3ed 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c @@ -527,7 +527,7 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop props->max_qp_wr = nesdev->nesadapter->max_qp_wr - 2; props->max_sge = nesdev->nesadapter->max_sge; props->max_cq = nesibdev->max_cq; - props->max_cqe = nesdev->nesadapter->max_cqe - 1; + props->max_cqe = nesdev->nesadapter->max_cqe; props->max_mr = nesibdev->max_mr; props->max_mw = nesibdev->max_mr; props->max_pd = nesibdev->max_pd; @@ -1543,6 +1543,9 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, unsigned long flags; int ret; + if (entries > nesadapter->max_cqe) + return ERR_PTR(-EINVAL); + err = nes_alloc_resource(nesadapter, nesadapter->allocated_cqs, nesadapter->max_cq, &cq_num, &nesadapter->next_cq); if (err) {