From patchwork Tue May 13 14:41:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 4168241 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 65F809F334 for ; Tue, 13 May 2014 14:41:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 798A320145 for ; Tue, 13 May 2014 14:41:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A3282020E for ; Tue, 13 May 2014 14:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933688AbaEMOll (ORCPT ); Tue, 13 May 2014 10:41:41 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:36824 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933421AbaEMOll (ORCPT ); Tue, 13 May 2014 10:41:41 -0400 Received: from [192.168.1.117] ([178.119.65.67]) by andre.telenet-ops.be with bizsmtp id 1Shg1o00u1T3uRu01Shg4V; Tue, 13 May 2014 16:41:40 +0200 Message-ID: <53722F24.3020509@acm.org> Date: Tue, 13 May 2014 16:41:40 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Roland Dreier CC: Sagi Grimberg , Vu Pham , David Dillow , Sebastian Parschauer , linux-rdma Subject: [PATCH v2 5/9] IB/srp: Introduce srp_finish_mapping() References: <53722E4F.7070709@acm.org> In-Reply-To: <53722E4F.7070709@acm.org> X-Enigmail-Version: 1.6 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.5 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 This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Roland Dreier Cc: David Dillow Cc: Sagi Grimberg Cc: Vu Pham Cc: Sebastian Parschauer --- drivers/infiniband/ulp/srp/ib_srp.c | 42 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index cc81c2f..c3c8333 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -935,16 +935,6 @@ static int srp_map_finish_fmr(struct srp_map_state *state, struct ib_pool_fmr *fmr; u64 io_addr = 0; - if (!state->npages) - return 0; - - if (state->npages == 1) { - srp_map_desc(state, state->base_dma_addr, state->fmr_len, - target->rkey); - state->npages = state->fmr_len = 0; - return 0; - } - fmr = ib_fmr_pool_map_phys(dev->fmr_pool, state->pages, state->npages, io_addr); if (IS_ERR(fmr)) @@ -954,10 +944,32 @@ static int srp_map_finish_fmr(struct srp_map_state *state, state->nfmr++; srp_map_desc(state, 0, state->fmr_len, fmr->fmr->rkey); - state->npages = state->fmr_len = 0; + return 0; } +static int srp_finish_mapping(struct srp_map_state *state, + struct srp_target_port *target) +{ + int ret = 0; + + if (state->npages == 0) + return 0; + + if (state->npages == 1) + srp_map_desc(state, state->base_dma_addr, state->fmr_len, + target->rkey); + else + ret = srp_map_finish_fmr(state, target); + + if (ret == 0) { + state->npages = 0; + state->fmr_len = 0; + } + + return ret; +} + static void srp_map_update_start(struct srp_map_state *state, struct scatterlist *sg, int sg_index, dma_addr_t dma_addr) @@ -998,7 +1010,7 @@ static int srp_map_sg_entry(struct srp_map_state *state, * avoided using FMR on such page fragments. */ if (dma_addr & ~dev->fmr_page_mask || dma_len > dev->fmr_max_size) { - ret = srp_map_finish_fmr(state, target); + ret = srp_finish_mapping(state, target); if (ret) return ret; @@ -1017,7 +1029,7 @@ static int srp_map_sg_entry(struct srp_map_state *state, while (dma_len) { if (state->npages == SRP_FMR_SIZE) { - ret = srp_map_finish_fmr(state, target); + ret = srp_finish_mapping(state, target); if (ret) return ret; @@ -1040,7 +1052,7 @@ static int srp_map_sg_entry(struct srp_map_state *state, */ ret = 0; if (len != dev->fmr_page_size) { - ret = srp_map_finish_fmr(state, target); + ret = srp_finish_mapping(state, target); if (!ret) srp_map_update_start(state, NULL, 0, 0); } @@ -1083,7 +1095,7 @@ backtrack: } } - if (use_fmr == SRP_MAP_ALLOW_FMR && srp_map_finish_fmr(state, target)) + if (use_fmr == SRP_MAP_ALLOW_FMR && srp_finish_mapping(state, target)) goto backtrack; req->nfmr = state->nfmr;