From patchwork Fri Dec 18 13:55:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 7884351 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 48A45BEEE5 for ; Fri, 18 Dec 2015 14:00:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6551203E6 for ; Fri, 18 Dec 2015 14:00:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E7492041D for ; Fri, 18 Dec 2015 14:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932297AbbLROAu (ORCPT ); Fri, 18 Dec 2015 09:00:50 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:52975 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932132AbbLROAt (ORCPT ); Fri, 18 Dec 2015 09:00:49 -0500 Received: from chello080109146114.tirol.surfer.at ([80.109.146.114] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9vaS-0008M0-39; Fri, 18 Dec 2015 14:00:48 +0000 From: Christoph Hellwig To: Santosh Shilimkar Cc: linux-rdma@vger.kernel.org Subject: [PATCH] rds: use local_dma_lkey Date: Fri, 18 Dec 2015 14:55:53 +0100 Message-Id: <1450446953-18848-1-git-send-email-hch@lst.de> X-Mailer: git-send-email 1.9.1 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html 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, T_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 We now alwasy have a per-PD local_dma_lkey available. Make use of that fact in rds and stop registering our own MR. Signed-off-by: Christoph Hellwig --- drivers/staging/rdma/ehca/ehca_mrmw.c | 1 - net/rds/iw.c | 19 +------------------ net/rds/iw.h | 9 --------- net/rds/iw_cm.c | 6 +----- net/rds/iw_recv.c | 2 +- net/rds/iw_send.c | 7 ++++--- 6 files changed, 7 insertions(+), 37 deletions(-) diff --git a/drivers/staging/rdma/ehca/ehca_mrmw.c b/drivers/staging/rdma/ehca/ehca_mrmw.c index 1814af7..06b832b 100644 --- a/drivers/staging/rdma/ehca/ehca_mrmw.c +++ b/drivers/staging/rdma/ehca/ehca_mrmw.c @@ -1339,7 +1339,6 @@ int ehca_reg_internal_maxmr( e_mr->ib.ib_mr.pd = &e_pd->ib_pd; e_mr->ib.ib_mr.uobject = NULL; atomic_inc(&(e_pd->ib_pd.usecnt)); - atomic_set(&(e_mr->ib.ib_mr.usecnt), 0); *e_maxmr = e_mr; return 0; diff --git a/net/rds/iw.c b/net/rds/iw.c index c74bc8b74..27e9c5e 100644 --- a/net/rds/iw.c +++ b/net/rds/iw.c @@ -71,7 +71,6 @@ static void rds_iw_add_one(struct ib_device *device) spin_lock_init(&rds_iwdev->spinlock); - rds_iwdev->dma_local_lkey = !!(device->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY); rds_iwdev->max_wrs = device->max_qp_wr; rds_iwdev->max_sge = min(device->max_sge, RDS_IW_MAX_SGE); @@ -80,20 +79,10 @@ static void rds_iw_add_one(struct ib_device *device) if (IS_ERR(rds_iwdev->pd)) goto free_dev; - if (!rds_iwdev->dma_local_lkey) { - rds_iwdev->mr = ib_get_dma_mr(rds_iwdev->pd, - IB_ACCESS_REMOTE_READ | - IB_ACCESS_REMOTE_WRITE | - IB_ACCESS_LOCAL_WRITE); - if (IS_ERR(rds_iwdev->mr)) - goto err_pd; - } else - rds_iwdev->mr = NULL; - rds_iwdev->mr_pool = rds_iw_create_mr_pool(rds_iwdev); if (IS_ERR(rds_iwdev->mr_pool)) { rds_iwdev->mr_pool = NULL; - goto err_mr; + goto err_pd; } INIT_LIST_HEAD(&rds_iwdev->cm_id_list); @@ -103,9 +92,6 @@ static void rds_iw_add_one(struct ib_device *device) ib_set_client_data(device, &rds_iw_client, rds_iwdev); return; -err_mr: - if (rds_iwdev->mr) - ib_dereg_mr(rds_iwdev->mr); err_pd: ib_dealloc_pd(rds_iwdev->pd); free_dev: @@ -132,9 +118,6 @@ static void rds_iw_remove_one(struct ib_device *device, void *client_data) if (rds_iwdev->mr_pool) rds_iw_destroy_mr_pool(rds_iwdev->mr_pool); - if (rds_iwdev->mr) - ib_dereg_mr(rds_iwdev->mr); - ib_dealloc_pd(rds_iwdev->pd); list_del(&rds_iwdev->list); diff --git a/net/rds/iw.h b/net/rds/iw.h index 5af01d1..b0f6f46 100644 --- a/net/rds/iw.h +++ b/net/rds/iw.h @@ -111,7 +111,6 @@ struct rds_iw_connection { /* alphabet soup, IBTA style */ struct rdma_cm_id *i_cm_id; struct ib_pd *i_pd; - struct ib_mr *i_mr; struct ib_cq *i_send_cq; struct ib_cq *i_recv_cq; @@ -160,7 +159,6 @@ struct rds_iw_connection { /* Protocol version specific information */ unsigned int i_flowctl:1; /* enable/disable flow ctl */ - unsigned int i_dma_local_lkey:1; unsigned int i_fastreg_posted:1; /* fastreg posted on this connection */ /* Batched completions */ unsigned int i_unsignaled_wrs; @@ -184,11 +182,9 @@ struct rds_iw_device { struct list_head conn_list; struct ib_device *dev; struct ib_pd *pd; - struct ib_mr *mr; struct rds_iw_mr_pool *mr_pool; int max_sge; unsigned int max_wrs; - unsigned int dma_local_lkey:1; spinlock_t spinlock; /* protect the above */ }; @@ -265,11 +261,6 @@ static inline void rds_iw_dma_sync_sg_for_device(struct ib_device *dev, } #define ib_dma_sync_sg_for_device rds_iw_dma_sync_sg_for_device -static inline u32 rds_iw_local_dma_lkey(struct rds_iw_connection *ic) -{ - return ic->i_dma_local_lkey ? ic->i_cm_id->device->local_dma_lkey : ic->i_mr->lkey; -} - /* ib.c */ extern struct rds_transport rds_iw_transport; extern struct ib_client rds_iw_client; diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c index aea4c91..78d5f52 100644 --- a/net/rds/iw_cm.c +++ b/net/rds/iw_cm.c @@ -269,7 +269,6 @@ static int rds_iw_setup_qp(struct rds_connection *conn) /* Protection domain and memory range */ ic->i_pd = rds_iwdev->pd; - ic->i_mr = rds_iwdev->mr; ret = rds_iw_init_qp_attrs(&attr, rds_iwdev, &ic->i_send_ring, rds_iw_send_cq_comp_handler, @@ -341,7 +340,7 @@ static int rds_iw_setup_qp(struct rds_connection *conn) * the posted credit count. */ rds_iw_recv_refill(conn, GFP_KERNEL, GFP_HIGHUSER, 1); - rdsdebug("conn %p pd %p mr %p cq %p %p\n", conn, ic->i_pd, ic->i_mr, + rdsdebug("conn %p pd %p cq %p %p\n", conn, ic->i_pd, ic->i_send_cq, ic->i_recv_cq); out: @@ -446,7 +445,6 @@ int rds_iw_cm_handle_connect(struct rdma_cm_id *cm_id, cm_id->context = conn; rds_iwdev = ib_get_client_data(cm_id->device, &rds_iw_client); - ic->i_dma_local_lkey = rds_iwdev->dma_local_lkey; /* We got halfway through setting up the ib_connection, if we * fail now, we have to take the long route out of this mess. */ @@ -550,7 +548,6 @@ int rds_iw_conn_connect(struct rds_connection *conn) } rds_iwdev = ib_get_client_data(ic->i_cm_id->device, &rds_iw_client); - ic->i_dma_local_lkey = rds_iwdev->dma_local_lkey; dest.sin_family = AF_INET; dest.sin_addr.s_addr = (__force u32)conn->c_faddr; @@ -649,7 +646,6 @@ void rds_iw_conn_shutdown(struct rds_connection *conn) ic->i_cm_id = NULL; ic->i_pd = NULL; - ic->i_mr = NULL; ic->i_send_cq = NULL; ic->i_recv_cq = NULL; ic->i_send_hdrs = NULL; diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c index a66d179..d45178f 100644 --- a/net/rds/iw_recv.c +++ b/net/rds/iw_recv.c @@ -351,7 +351,7 @@ void rds_iw_recv_init_ack(struct rds_iw_connection *ic) sge->addr = ic->i_ack_dma; sge->length = sizeof(struct rds_header); - sge->lkey = rds_iw_local_dma_lkey(ic); + sge->lkey = ic->rds_iwdev->pd->local_dma_lkey; wr->sg_list = sge; wr->num_sge = 1; diff --git a/net/rds/iw_send.c b/net/rds/iw_send.c index e20bd50..06c3450 100644 --- a/net/rds/iw_send.c +++ b/net/rds/iw_send.c @@ -457,7 +457,7 @@ rds_iw_xmit_populate_wr(struct rds_iw_connection *ic, sge = rds_iw_data_sge(ic, send->s_sge); sge->addr = buffer; sge->length = length; - sge->lkey = rds_iw_local_dma_lkey(ic); + sge->lkey = ic->rds_iwdev->pd->local_dma_lkey; sge = rds_iw_header_sge(ic, send->s_sge); } else { @@ -469,7 +469,7 @@ rds_iw_xmit_populate_wr(struct rds_iw_connection *ic, sge->addr = ic->i_send_hdrs_dma + (pos * sizeof(struct rds_header)); sge->length = sizeof(struct rds_header); - sge->lkey = rds_iw_local_dma_lkey(ic); + sge->lkey = ic->rds_iwdev->pd->local_dma_lkey; } /* @@ -903,7 +903,8 @@ int rds_iw_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op) else { send->s_sge[j].addr = ib_sg_dma_address(ic->i_cm_id->device, scat); send->s_sge[j].length = len; - send->s_sge[j].lkey = rds_iw_local_dma_lkey(ic); + send->s_sge[j].lkey = + ic->rds_iwdev->pd->local_dma_lkey; } sent += len;