From patchwork Tue Aug 6 15:34:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipul Pandya X-Patchwork-Id: 2839441 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 9FB8A9F3B9 for ; Tue, 6 Aug 2013 15:41:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93F61201C8 for ; Tue, 6 Aug 2013 15:41:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 605AA201B2 for ; Tue, 6 Aug 2013 15:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755841Ab3HFPlt (ORCPT ); Tue, 6 Aug 2013 11:41:49 -0400 Received: from stargate.chelsio.com ([67.207.112.58]:21923 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755607Ab3HFPlt (ORCPT ); Tue, 6 Aug 2013 11:41:49 -0400 Received: from maui.asicdesigners.com (maui.asicdesigners.com [10.192.180.15]) by stargate.chelsio.com (8.13.1/8.13.1) with SMTP id r76Ffkip011128; Tue, 6 Aug 2013 08:41:46 -0700 Received: from strawberry.blr.asicdesigners.com.com ([10.193.185.96]) by maui.asicdesigners.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 6 Aug 2013 08:41:46 -0700 From: Vipul Pandya To: linux-rdma@vger.kernel.org Cc: roland@purestorage.com, divy@chelsio.com, swise@opengridcomputing.com, vipul@chelsio.com, nirranjan@chelsio.com Subject: [PATCH 4/8] RDMA/cxgb4: Account for unsignled SQ WRs that fails to deal with wrap Date: Tue, 6 Aug 2013 21:04:36 +0530 Message-Id: <1375803280-7916-5-git-send-email-vipul@chelsio.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1375803280-7916-1-git-send-email-vipul@chelsio.com> References: <1375803280-7916-1-git-send-email-vipul@chelsio.com> X-OriginalArrivalTime: 06 Aug 2013 15:41:46.0680 (UTC) FILETIME=[756ADB80:01CE92BB] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Steve Wise When determining how many WRs are completed with a signaled CQE, correctly deal with queue wraps. Signed-off-by: Steve Wise Signed-off-by: Vipul Pandya --- drivers/infiniband/hw/cxgb4/cq.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c index d84b2c0..4e91168 100644 --- a/drivers/infiniband/hw/cxgb4/cq.c +++ b/drivers/infiniband/hw/cxgb4/cq.c @@ -611,9 +611,12 @@ proc_cqe: * to the first unsignaled one, and idx points to the * signaled one. So adjust in_use based on this delta. * if this is not completing any unsigned wrs, then the - * delta will be 0. + * delta will be 0. Handle wrapping also! */ - wq->sq.in_use -= idx - wq->sq.cidx; + if (idx < wq->sq.cidx) + wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx; + else + wq->sq.in_use -= idx - wq->sq.cidx; BUG_ON(wq->sq.in_use < 0 && wq->sq.in_use < wq->sq.size); wq->sq.cidx = (uint16_t)idx;