Received: by 10.223.185.116 with SMTP id b49csp1043884wrg; Fri, 23 Feb 2018 10:54:11 -0800 (PST) X-Google-Smtp-Source: AH8x224KwqiasvORRG2I8YPh9MRblFagzcui9NeUOeDbN6gQssQSJfHg+H/ZBlKmqSVIWJxg3LhG X-Received: by 10.98.135.76 with SMTP id i73mr2700801pfe.140.1519412051488; Fri, 23 Feb 2018 10:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412051; cv=none; d=google.com; s=arc-20160816; b=ktMevx5ecHY5gGK2VbB+g5Tz4bh1QLswMWfXRj2mXheLwHoYs6zEEYLanCvWL5J0Mm J4dxMILuVvFlpivGd1hZulGWEbI0hH8gmOipPsmGTvaIRPJMfvldyleULNqQfRSdTCg/ otlVBw5ijSNXM95wOr1b3u5oWMY3/dhchG00hY4vAs5tw7+7LKLytfXFoXmNJM8okHFt yVdjA/BG4YQTAWv3ZdC/HSA9w6LGWKDPYosOGQN/YnyRNYFDqeR789O3gZQBbWEQgBOI Ballb+ixihlgG8WqTvuvA/lLqweR61suMOLCy7Rnx+O9TMmKHOw/mqmDxrkOponilEwA Hexg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=57xzYLc27KJLdtmrH1dr69vV5VqSvWLkSlADJDWykYs=; b=BPEpAgXKGiu92HYCkCIkZ4qGFGDRQFsxM17/VE2XuLQXQmF8J8ujVJCU/SIQzAi9z7 b/BJtL/kUaUx2rQyXZrx+QZ4fVj0ipqaHx/UYMDol3RjhO+lVHTA0YrofreOUhDr0SdZ ApOKGDttSVlRbhzRFIOe70aXV9wm2WEC3VTHtgu08C4MmnKL/N0audkh0WwKYqP+Mj1M Jr2rtvCr+ykOZUNmfO6TX6h62MYBDC3p+ewIh7qRUK03YJ9QDIhFlsqbXOyOY8kE2YhA BE4MJ01/hkmvrZjVMU3voewczD92mHV1zKYa2QSjEEwAl7yoTPY37jr0OCI77qDtV1pH lWyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63-v6si2149429pla.526.2018.02.23.10.53.55; Fri, 23 Feb 2018 10:54:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935370AbeBWSxS (ORCPT + 99 others); Fri, 23 Feb 2018 13:53:18 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47272 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935345AbeBWSxO (ORCPT ); Fri, 23 Feb 2018 13:53:14 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5AE3E1005; Fri, 23 Feb 2018 18:53:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chien Tin Tung , Shiraz Saleem , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.14 089/159] i40iw: Allocate a sdbuf per CQP WQE Date: Fri, 23 Feb 2018 19:26:37 +0100 Message-Id: <20180223170754.289693711@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chien Tin Tung [ Upstream commit 100d6de2ced538c539d923dc14a1b5cbae234503 ] Currently there is only one sdbuf per Control QP (CQP) for programming Segment Descriptor (SD). If multiple SD work requests are posted simultaneously, the sdbuf is reused by all WQEs and new WQEs can corrupt previous WQEs sdbuf leading to incorrect SD programming. Fix this by allocating one sdbuf per CQP SQ WQE. When an SD command is posted, it will use the corresponding sdbuf for the WQE. Fixes: 86dbcd0f12e9 ("i40iw: add file to handle cqp calls") Signed-off-by: Chien Tin Tung Signed-off-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/i40iw/i40iw_ctrl.c | 43 +++++++++++++++++++++---------- drivers/infiniband/hw/i40iw/i40iw_d.h | 4 ++ 2 files changed, 33 insertions(+), 14 deletions(-) --- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c +++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c @@ -506,7 +506,7 @@ static enum i40iw_status_code i40iw_sc_c ret_code = i40iw_allocate_dma_mem(cqp->dev->hw, &cqp->sdbuf, - 128, + I40IW_UPDATE_SD_BUF_SIZE * cqp->sq_size, I40IW_SD_BUF_ALIGNMENT); if (ret_code) @@ -589,14 +589,15 @@ void i40iw_sc_cqp_post_sq(struct i40iw_s } /** - * i40iw_sc_cqp_get_next_send_wqe - get next wqe on cqp sq - * @cqp: struct for cqp hw - * @wqe_idx: we index of cqp ring + * i40iw_sc_cqp_get_next_send_wqe_idx - get next WQE on CQP SQ and pass back the index + * @cqp: pointer to CQP structure + * @scratch: private data for CQP WQE + * @wqe_idx: WQE index for next WQE on CQP SQ */ -u64 *i40iw_sc_cqp_get_next_send_wqe(struct i40iw_sc_cqp *cqp, u64 scratch) +static u64 *i40iw_sc_cqp_get_next_send_wqe_idx(struct i40iw_sc_cqp *cqp, + u64 scratch, u32 *wqe_idx) { u64 *wqe = NULL; - u32 wqe_idx; enum i40iw_status_code ret_code; if (I40IW_RING_FULL_ERR(cqp->sq_ring)) { @@ -609,21 +610,33 @@ u64 *i40iw_sc_cqp_get_next_send_wqe(stru cqp->sq_ring.size); return NULL; } - I40IW_ATOMIC_RING_MOVE_HEAD(cqp->sq_ring, wqe_idx, ret_code); + I40IW_ATOMIC_RING_MOVE_HEAD(cqp->sq_ring, *wqe_idx, ret_code); cqp->dev->cqp_cmd_stats[OP_REQUESTED_COMMANDS]++; if (ret_code) return NULL; - if (!wqe_idx) + if (!*wqe_idx) cqp->polarity = !cqp->polarity; - wqe = cqp->sq_base[wqe_idx].elem; - cqp->scratch_array[wqe_idx] = scratch; + wqe = cqp->sq_base[*wqe_idx].elem; + cqp->scratch_array[*wqe_idx] = scratch; I40IW_CQP_INIT_WQE(wqe); return wqe; } /** + * i40iw_sc_cqp_get_next_send_wqe - get next wqe on cqp sq + * @cqp: struct for cqp hw + * @scratch: private data for CQP WQE + */ +u64 *i40iw_sc_cqp_get_next_send_wqe(struct i40iw_sc_cqp *cqp, u64 scratch) +{ + u32 wqe_idx; + + return i40iw_sc_cqp_get_next_send_wqe_idx(cqp, scratch, &wqe_idx); +} + +/** * i40iw_sc_cqp_destroy - destroy cqp during close * @cqp: struct for cqp hw */ @@ -3534,8 +3547,10 @@ static enum i40iw_status_code cqp_sds_wq u64 *wqe; int mem_entries, wqe_entries; struct i40iw_dma_mem *sdbuf = &cqp->sdbuf; + u64 offset; + u32 wqe_idx; - wqe = i40iw_sc_cqp_get_next_send_wqe(cqp, scratch); + wqe = i40iw_sc_cqp_get_next_send_wqe_idx(cqp, scratch, &wqe_idx); if (!wqe) return I40IW_ERR_RING_FULL; @@ -3548,8 +3563,10 @@ static enum i40iw_status_code cqp_sds_wq LS_64(mem_entries, I40IW_CQPSQ_UPESD_ENTRY_COUNT); if (mem_entries) { - memcpy(sdbuf->va, &info->entry[3], (mem_entries << 4)); - data = sdbuf->pa; + offset = wqe_idx * I40IW_UPDATE_SD_BUF_SIZE; + memcpy((char *)sdbuf->va + offset, &info->entry[3], + mem_entries << 4); + data = (u64)sdbuf->pa + offset; } else { data = 0; } --- a/drivers/infiniband/hw/i40iw/i40iw_d.h +++ b/drivers/infiniband/hw/i40iw/i40iw_d.h @@ -1516,7 +1516,7 @@ enum i40iw_alignment { I40IW_AEQ_ALIGNMENT = 0x100, I40IW_CEQ_ALIGNMENT = 0x100, I40IW_CQ0_ALIGNMENT = 0x100, - I40IW_SD_BUF_ALIGNMENT = 0x100 + I40IW_SD_BUF_ALIGNMENT = 0x80 }; #define I40IW_WQE_SIZE_64 64 @@ -1524,6 +1524,8 @@ enum i40iw_alignment { #define I40IW_QP_WQE_MIN_SIZE 32 #define I40IW_QP_WQE_MAX_SIZE 128 +#define I40IW_UPDATE_SD_BUF_SIZE 128 + #define I40IW_CQE_QTYPE_RQ 0 #define I40IW_CQE_QTYPE_SQ 1