Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2221535imm; Thu, 7 Jun 2018 07:17:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJJqHzHZRJ4pCfDZhofR7PnTdhRaHUowPR/C8+vq97ebTLerFaW0+uM6O+vHdcWzUngn+p2 X-Received: by 2002:a62:c296:: with SMTP id w22-v6mr1998868pfk.92.1528381034004; Thu, 07 Jun 2018 07:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528381033; cv=none; d=google.com; s=arc-20160816; b=miZKwY5cg9OTapzlOs9NBkEyrUdb6Jlxke8Kb52hop17kLAqBNhw1vQ28vHZmPUq+e SPOowaqv25jINotoTZExGM76Px9meCevk91Ef17xO6u6h9RQo21DT+0ZvTHRyGPDY9dO HOghjFBGo/2RZp2HJLXK0/+TpzRf6LUPleRdmBBQBazHX4A6Dx4neoDoha2zcLmRZf89 Ow+GDs04R644AOYcT1c5QLGhlX4HSv6l2TxZiaDMdeXXWIuVKqReYPBvnlRoa1SbH1Bw oFUyZNqGlKt5jMBd5BV3zGAS5tet6X8Z/fs+zkf129ASo0cijs0J46Vrczk2zR7QdLhU y/lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=qBT6CHNgfajhREYbh4h20f8ApZYudU9R2iHZC8QaF5I=; b=cy/pKa7aoMJwKrmFya3onKhp62vFIuurM2gWd2XPAJLPBjRyGSOOV9efEMsSsCgA1s Rs+A0fxLRj/CL+9I0LCGS7ftVpJtKE4QyE1fdzQHWVZBpm0MlFXOzvYC7IAgrjvBhw8f GWG5Vi2hVVzLWjVH4N4TFyKDCx7Enh2pu4BbNYQjv5uFvBAJv0UbdAkB9kafNlSj3rrF +QUVhxed56dhCh8vvD1c2fYesZn6k58eHu84JECMS9sqxZe8tpaDDr+9QOwc+/xayqxs k5xqSJkjY4Tfg3UzQvGHJdx29puLXOb3uNPfZIothpDRfZNvUIc1RyTV0W9yCeXsI6BB ma3Q== 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 k24-v6si50861293pff.91.2018.06.07.07.16.59; Thu, 07 Jun 2018 07:17:13 -0700 (PDT) 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 S933123AbeFGOJY (ORCPT + 99 others); Thu, 7 Jun 2018 10:09:24 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39238 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933006AbeFGOJE (ORCPT ); Thu, 7 Jun 2018 10:09:04 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb4-0005a0-CU; Thu, 07 Jun 2018 15:09:02 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb0-0002oS-V4; Thu, 07 Jun 2018 15:08:58 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Moshe Shemesh" , "David S. Miller" , "Tariq Toukan" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 090/410] net/mlx4_core: Cleanup FMR unmapping flow In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Tariq Toukan commit fd4a3e2828b4ca35aef40e5bdc1ed7d87b3cb50a upstream. Remove redundant and not essential operations in fmr unmap/free. According to device spec, in FMR unmap it is sufficient to set ownership bit to SW. This allows remapping afterwards. Fixes: 8ad11fb6b073 ("IB/mlx4: Implement FMRs") Signed-off-by: Tariq Toukan Signed-off-by: Moshe Shemesh Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- drivers/net/ethernet/mellanox/mlx4/mr.c | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -944,30 +944,16 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_enable); void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u32 *lkey, u32 *rkey) { - struct mlx4_cmd_mailbox *mailbox; - int err; - if (!fmr->maps) return; - fmr->maps = 0; + /* To unmap: it is sufficient to take back ownership from HW */ + *(u8 *)fmr->mpt = MLX4_MPT_STATUS_SW; - mailbox = mlx4_alloc_cmd_mailbox(dev); - if (IS_ERR(mailbox)) { - err = PTR_ERR(mailbox); - pr_warn("mlx4_ib: mlx4_alloc_cmd_mailbox failed (%d)\n", err); - return; - } + /* Make sure MPT status is visible */ + wmb(); - err = mlx4_HW2SW_MPT(dev, NULL, - key_to_hw_index(fmr->mr.key) & - (dev->caps.num_mpts - 1)); - mlx4_free_cmd_mailbox(dev, mailbox); - if (err) { - pr_warn("mlx4_ib: mlx4_HW2SW_MPT failed (%d)\n", err); - return; - } - fmr->mr.enabled = MLX4_MPT_EN_SW; + fmr->maps = 0; } EXPORT_SYMBOL_GPL(mlx4_fmr_unmap); @@ -977,6 +963,22 @@ int mlx4_fmr_free(struct mlx4_dev *dev, if (fmr->maps) return -EBUSY; + if (fmr->mr.enabled == MLX4_MPT_EN_HW) { + /* In case of FMR was enabled and unmapped + * make sure to give ownership of MPT back to HW + * so HW2SW_MPT command will success. + */ + *(u8 *)fmr->mpt = MLX4_MPT_STATUS_SW; + /* Make sure MPT status is visible before changing MPT fields */ + wmb(); + fmr->mpt->length = 0; + fmr->mpt->start = 0; + /* Make sure MPT data is visible after changing MPT status */ + wmb(); + *(u8 *)fmr->mpt = MLX4_MPT_STATUS_HW; + /* make sure MPT status is visible */ + wmb(); + } ret = mlx4_mr_free(dev, &fmr->mr); if (ret)