From patchwork Wed Oct 23 06:53:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 3086201 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 C18A99F2B7 for ; Wed, 23 Oct 2013 06:53:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB820202C3 for ; Wed, 23 Oct 2013 06:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF257202B8 for ; Wed, 23 Oct 2013 06:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751166Ab3JWGxj (ORCPT ); Wed, 23 Oct 2013 02:53:39 -0400 Received: from mail-ee0-f44.google.com ([74.125.83.44]:63569 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051Ab3JWGxi (ORCPT ); Wed, 23 Oct 2013 02:53:38 -0400 Received: by mail-ee0-f44.google.com with SMTP id b47so190200eek.31 for ; Tue, 22 Oct 2013 23:53:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cr3gkhV7thaQ5Oa0mU6l+yLVzWnSlTHxATEQUMfcS98=; b=erqLeij/hKFOWS89nuUBfbUsjFh4l8txYBGCrdWWUX4xdUHcSdfM7IHHu4R2AsKMV5 XU6wEOPVHDqFWhsBifNeWfsh8+QcxmbahJgtgKI9cYbgPedp05xHs8cZhe5mP+5H5uEL cVGumLE9TEpfaOXZQXnTkw9hg+gMtKD2UsqXVqPM/DMUkai16I20yavPtn3q24ZolNpi a7nGgPK15yX3tPYaV2Qw9dWlTVBMpDQuaxt8yH0gHC113mWSn14bpTs3Tyn7/hfNF9O6 LQJn4FlDv/m3gS3cX/D2Ok9rwgUEp/5W+PHcNs1i/ciRkytBFWK00hOfIXFFhMGVVD/e aMOA== X-Gm-Message-State: ALoCoQlEWF8SVL1xwtlPcxQQyfscOeQOmUs7uzFTLddYq8OxO6j9BovRcDMoE2LpkVI8l0Sg6SX5 X-Received: by 10.15.35.196 with SMTP id g44mr151592eev.18.1382511217781; Tue, 22 Oct 2013 23:53:37 -0700 (PDT) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id bn13sm66202911eeb.11.2013.10.22.23.53.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Oct 2013 23:53:37 -0700 (PDT) From: Eli Cohen To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, amirv@mellanox.com, ogerlitz@mellanox.com, yevgenyp@mellanox.com, Eli Cohen Subject: [PATCH for-next 6/9] mlx5: Fix cleanup flow when DMA mapping fails Date: Wed, 23 Oct 2013 09:53:18 +0300 Message-Id: <1382511201-7061-7-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1382511201-7061-1-git-send-email-eli@mellanox.com> References: <1382511201-7061-1-git-send-email-eli@mellanox.com> 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.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 If DMA mapping fails, the driver cleared the object that holds the previously DMA mapped pages. Fix this by allocating a new object for the command that reports back to firmware that pages can't be supplied. Signed-off-by: Eli Cohen --- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index 7b12acf..a0d0da3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -181,6 +181,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, { struct mlx5_manage_pages_inbox *in; struct mlx5_manage_pages_outbox out; + struct mlx5_manage_pages_inbox *nin; struct page *page; int inlen; u64 addr; @@ -247,13 +248,20 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, out_alloc: if (notify_fail) { - memset(in, 0, inlen); + nin = kzalloc(sizeof(*nin), GFP_KERNEL); + if (!nin) { + mlx5_core_warn(dev, "allocation failed\n"); + goto unmap; + } memset(&out, 0, sizeof(out)); - in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); - in->hdr.opmod = cpu_to_be16(MLX5_PAGES_CANT_GIVE); - if (mlx5_cmd_exec(dev, in, sizeof(*in), &out, sizeof(out))) - mlx5_core_warn(dev, "\n"); + nin->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); + nin->hdr.opmod = cpu_to_be16(MLX5_PAGES_CANT_GIVE); + if (mlx5_cmd_exec(dev, nin, sizeof(*nin), &out, sizeof(out))) + mlx5_core_warn(dev, "page notify failed\n"); + kfree(nin); } + +unmap: for (i--; i >= 0; i--) { addr = be64_to_cpu(in->pas[i]); page = remove_page(dev, addr);