Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1678864pxu; Sun, 6 Dec 2020 03:48:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwRo9HPYqoKk+X0dvUwDUA2GM48qPiId6SpV7q2qCvdFhE/S0wYlmivmoQuzeJR9c3AT61 X-Received: by 2002:a50:b2c1:: with SMTP id p59mr16012785edd.318.1607255306328; Sun, 06 Dec 2020 03:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607255306; cv=none; d=google.com; s=arc-20160816; b=Q98YMMHhtrVyZKzawJ9aftls6ABlxpfra6waxacrLCpSf4lKXBWwKUWhoXNbzV0ExE yEBQ6Vffyszw/9vbC6+pOHDZ+DBhDTZs9DtlJiPA3l+PSo4+7Npd8HUgo4d56No2SSxT uTr6ki+aO9yoXetTCEbDOHHtEtBbY00/bHs5GjCz9vaC2xWUXbEH2Oy6u6AAp6FMHNDO jL7CxRehDM+7OVHVRsoVSHNRD0xKElw5jlDRxLrpbcBi89vM6AjHd/9mDk5A87PiChmN Ug4yjDqhOmaWF6F/A6BjyGlbAkPCvnpnjKsAMOQySXH++I62sIAaO6tSfiotCQ1LKI6Z M6pw== 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=RLXKAxIpYi4fAx034KegEtlOWCKnTtw8lYZf9z7Xkjg=; b=TjxeqfxTESTvX1zMjrb+RVdKEDYfCxlbEmwaKxCXc4zi1/2lMaS4/EmjetDCIOZ2/2 tg+w/hgWwjPux2uVdH6C2F+EvBdxkZGIwMj59sz5F6ZeQDojUAHGkjhvOEZmST9tVHpX jb0ZBAl7uQDeLvmHM8eTnuu8XbbDXNwCvB3OYIVNuvYYoEucnmjg0u4QuiL+2zNFPq/M a52X5qwjoUmFgtlHGnww6Sy02etImcSuhUd6XgxgzKqFPxdLH5XgZINpbVhr0l8XgE0N OuqkNzN7+Im6n3cCBht2rGrraemulSb2fFxptV2iApJRQwwH1zokr3Ee6pALel95PLMh ZOIg== 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 e8si1782816edq.377.2020.12.06.03.48.03; Sun, 06 Dec 2020 03:48:26 -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 S1729187AbgLFLqS (ORCPT + 99 others); Sun, 6 Dec 2020 06:46:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:45702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727866AbgLFLpd (ORCPT ); Sun, 6 Dec 2020 06:45:33 -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 5.9 37/46] net/mlx5: Fix wrong address reclaim when command interface is down Date: Sun, 6 Dec 2020 12:17:45 +0100 Message-Id: <20201206111558.245562509@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201206111556.455533723@linuxfoundation.org> References: <20201206111556.455533723@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 @@ -422,6 +422,24 @@ static void release_all_pages(struct mlx npages, ec_function, func_id); } +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) { @@ -448,8 +466,7 @@ static int reclaim_pages_cmd(struct mlx5 fwp = rb_entry(p, struct fw_page, rb_node); p = rb_next(p); - 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);