Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp118318pxu; Thu, 10 Dec 2020 20:29:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/88H9KmWMvkfLebpm6vRs9WHjnKiSiVcYb3tTHIatZ7DRRygJnr5Rnpegl+5fzqFgHg/F X-Received: by 2002:a17:906:c83b:: with SMTP id dd27mr9452597ejb.356.1607660996144; Thu, 10 Dec 2020 20:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607660996; cv=none; d=google.com; s=arc-20160816; b=x/DeVNhALNsA0KHKdJ1F8zJVhs+YpZfdA8VLKevdAvu0VQZzuGoM8094V3v5QVGzBM r8yQrio+Ah1NBLYcsjauuLDcP+XFEC1/xX9HFCf41iujxOxiMpMBcvMNtgVnKdQ9sC97 rZfUwl8v4fIU3cARaiEt9a95+tNP5VouGlIipjewzYdSWQBtmggHVC/SZwELBBBKRrjq EXRXSRb2pWqydrJl/xYr9r/hTKbwVu1n6h1yLW7DdRLobn+gr/mUZzAo4/+i62ZSrWAK 83Lqbyy+T/ayY+fdaG6K9G2Q9Oi85fWVoNPjRBfA5pJNUkoSwfnaxhvXwM7/dA1nF2dm WoBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=eTwDo0WUPy75JLNh/Rq4+iCmrX4oKDODA6U6dtBvM/s=; b=qMppTJul9gyU4a4lEC9ZDEoqZ6pUCWUY1pIPVpBJ8bi5KmthlIyC3jNz4szdAO8zz1 r+Xn+B/e549rb2zAQB9GKM4/DitioBNrs0+nQid91CGbvckO1GKW/CPO//H4zMOK209D JTh0j6hz2cFRNzydrxPodalpSu6Joqt9un302xZPR1akcdubggUFhuVt9fZSVT93umlT HE4ambQyio6KC8xGXJN3SzuYMmbdQmmHseify0WaaYCT9NMgQc2apHlEnJODJ+fnf4GS OZFLbBwQof956gf2lALbdQFUT/VVaN0wKXfT6ZukgKtd/7fmcJWgGjGthNs31CUScUlM g1dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l26si3962160ejd.258.2020.12.10.20.29.33; Thu, 10 Dec 2020 20:29:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390352AbgLJOam (ORCPT + 99 others); Thu, 10 Dec 2020 09:30:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:36556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390179AbgLJO2w (ORCPT ); Thu, 10 Dec 2020 09:28:52 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eran Ben Elisha , Saeed Mahameed , Jakub Kicinski Subject: [PATCH 4.9 11/45] net/mlx5: Fix wrong address reclaim when command interface is down Date: Thu, 10 Dec 2020 15:26:25 +0100 Message-Id: <20201210142602.919855348@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210142602.361598591@linuxfoundation.org> References: <20201210142602.361598591@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eran Ben Elisha [ Upstream commit 1d2bb5ad89f47d8ce8aedc70ef85059ab3870292 ] When command interface is down, driver to reclaim all 4K page chucks that were hold by the Firmeware. Fix a bug for 64K page size systems, where driver repeatedly released only the first chunk of the page. Define helper function to fill 4K chunks for a given Firmware pages. Iterate over all unreleased Firmware pages and call the hepler per each. Fixes: 5adff6a08862 ("net/mlx5: Fix incorrect page count when in internal error") Signed-off-by: Eran Ben Elisha Signed-off-by: Saeed Mahameed Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -331,6 +331,24 @@ out_free: return err; } +static u32 fwp_fill_manage_pages_out(struct fw_page *fwp, u32 *out, u32 index, + u32 npages) +{ + u32 pages_set = 0; + unsigned int n; + + for_each_clear_bit(n, &fwp->bitmask, MLX5_NUM_4K_IN_PAGE) { + MLX5_ARRAY_SET64(manage_pages_out, out, pas, index + pages_set, + fwp->addr + (n * MLX5_ADAPTER_PAGE_SIZE)); + pages_set++; + + if (!--npages) + break; + } + + return pages_set; +} + static int reclaim_pages_cmd(struct mlx5_core_dev *dev, u32 *in, int in_size, u32 *out, int out_size) { @@ -354,8 +372,7 @@ static int reclaim_pages_cmd(struct mlx5 if (fwp->func_id != func_id) continue; - MLX5_ARRAY_SET64(manage_pages_out, out, pas, i, fwp->addr); - i++; + i += fwp_fill_manage_pages_out(fwp, out, i, npages - i); } MLX5_SET(manage_pages_out, out, output_num_entries, i);