Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp761342rdb; Thu, 18 Jan 2024 19:59:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMNytnUuQY08qgq1V4jHEuP+RnzcJoymrMmq4xma+lwOXjHlXEDjLPmntUQw8KtKAMlH2i X-Received: by 2002:a05:6214:27c4:b0:681:55a9:a9cd with SMTP id ge4-20020a05621427c400b0068155a9a9cdmr2546964qvb.8.1705636782622; Thu, 18 Jan 2024 19:59:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705636782; cv=pass; d=google.com; s=arc-20160816; b=oGyDX2/7KRW8nr+Ol3ixqVQFxJ5G/ENOIIT7y50XBvobUsrsvwq/k6fn88jRo083gO CCJfpPlAJ2Z4exqgEbwg0x3qzCZu+usx6ydjOP0cwrDdvXiveYqhSRsDNchAMYvOAlDv lbFwQi8xJYcTZIJxW7sjVsVlQswMWTB70ztFiihtJ7Q2RMVWJsg5cI2X4AlXuychaxzC ioRVXgrUwQEda+Fru3d6O7RoVct09+fJ7oPbOx5wa3FDvxQ3Hc07caOUsiJsJsb5zzy0 m0w5D8WljFu1t6k5v41Tald5EsHVtBzDiMw3NgnN5w5CUvW4jGzgvbMYCLUv+c1QMGHP 3qoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=tL//60B5oP2gQd2LSZPPIPCOhrs6XqbosD7E/EYlW+s=; fh=e5iw0ukL31u6fMn+hZYiSOp4yisu2h+6CljD+X3bH78=; b=XWxK6/rBzX4ZEOuJg5nYVhpThxwmGz/9Ig1gmoWU0/an3qZPlqs4EpGkaW4HZ82lCf Ht/Ectz6EuvdKFoynYR/fis4DXiC4oeF4zLrXQ05WGLsabqJtUDbXreVKiOx531UdgO2 KF0ystRsqFYPUv8AiWqD6tWs/v2iU8Z3SYAInHfkvPdXlL1Qgx+fCURJ20F/G3ThdrI/ MW4caQuMr08PbX5YbEbpAxUZ6YpCe4TaWrj94/utIRKkX9cE2v3TZI0SxfKM13yVyg7v AhBipGEV1dQOsfBxb2INKAINJ9tLjeuDu+nq7gedP8O2ZSyQnWB96+RoHfcf1TCjN0AL x4uA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=RO99e9Xo; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-30753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a16-20020a0ca990000000b0067f8dc03511si15692521qvb.80.2024.01.18.19.59.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 19:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=RO99e9Xo; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-30753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6295C1C21C4F for ; Fri, 19 Jan 2024 03:59:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B4EF3C32; Fri, 19 Jan 2024 03:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="RO99e9Xo" Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D3B38F48; Fri, 19 Jan 2024 03:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705636770; cv=none; b=LgnsZ7zcwKSlWmIVyXWFCUb+1X7c68Q32KdyhDTEc3tVN6g/mO1sMnz5i0bM0ZDlsQmx7VpWyflWwN1qzFkjEDnDpNaLXUufSZE0NTkW7R8xxqe9jtfpKgkq0p2pAVoBm1b0rk3aUQ3k7yVd/IyeUOQwNr3wVmsF0SXN1g5Nr/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705636770; c=relaxed/simple; bh=erj5klnlnF8zBpQAMLBV9/ypyQNvxGJzuVGpigf1qvQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=NewkTP8HnhJPFXDAVnJ1G2YKfRPMmvBLEKcSkdMJt5tJPdYv6fFV4xsOeyrMq+3LU9J/x1NjeNrqjFf0Hikxv/y4DZhhWyTVCf7q6xL32DWFW1WosG7ViQD27UxhEJVybkdyYzZtm3Oz+lrCt/i5P9cvJ64y2QdN2TDjoXO4VQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=RO99e9Xo; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40J1lcBO023246; Thu, 18 Jan 2024 19:59:19 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=pfpt0220; bh=tL//60B5 oP2gQd2LSZPPIPCOhrs6XqbosD7E/EYlW+s=; b=RO99e9XobIbZ81stFI0tit++ QiZI5UxDvhNYXPlA3w3+M/2Mxl/93iurTY47vczOZp3dLMvCME4GlaKR+9aLoifs W+w2nzhMtTOvDpp0osk/d8MTe2VYK2umnUOg2pwlQWX1nkACmBa6AE6Sk/3ugVLx rBg5ImRKSOTES1nSU0dpFkmEX6JyxJ6lGWbhbYeLnaXZbA/iGyQr1BSmJeyIlemx IvEQhUxyhEFghntSsWLive8U4o+PyiqcCr9YRFfF8Fe6CnmhTgZB6beHBc+rolZs v1Rs+55EIjiIVxXOZ2pVTjsm/rW8sagVwVrMI0ulwYKlandrKetE8W6WD8PlVw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vpvex4yvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 18 Jan 2024 19:59:19 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 Jan 2024 19:59:17 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 Jan 2024 19:59:17 -0800 Received: from localhost.localdomain (unknown [10.111.135.16]) by maili.marvell.com (Postfix) with ESMTP id 4D5E23F708C; Thu, 18 Jan 2024 19:59:17 -0800 (PST) From: Jenishkumar Maheshbhai Patel To: , , , , , , , CC: Jenishkumar Maheshbhai Patel Subject: [net v4 PATCH 1/1] net: mvpp2: clear BM pool before initialization Date: Thu, 18 Jan 2024 19:59:14 -0800 Message-ID: <20240119035914.2595665-1-jpatel2@marvell.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: n_DiqHUIo33uo9j_Dl5wT7e3FDwMUYd_ X-Proofpoint-GUID: n_DiqHUIo33uo9j_Dl5wT7e3FDwMUYd_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-18_12,2024-01-17_01,2023-05-22_02 Register value persist after booting the kernel using kexec which results in kernel panic. Thus clear the BM pool registers before initialisation to fix the issue. Fixes: 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Jenishkumar Maheshbhai Patel --- v1-v2: -Move comments outside the loop -remove unrequired brances. v2-v3: -improve readability -correct register read API v3-v4: -optimize the code -improve readability .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 820b1fabe297..23adf53c2aa1 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -614,12 +614,38 @@ static void mvpp23_bm_set_8pool_mode(struct mvpp2 *priv) mvpp2_write(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG, val); } +/* Cleanup pool before actual initialization in the OS */ +static void mvpp2_bm_pool_cleanup(struct mvpp2 *priv, int pool_id) +{ + unsigned int thread = mvpp2_cpu_to_thread(priv, get_cpu()); + u32 val; + int i; + + /* Drain the BM from all possible residues left by firmware */ + for (i = 0; i < MVPP2_BM_POOL_SIZE_MAX; i++) + mvpp2_thread_read(priv, thread, MVPP2_BM_PHY_ALLOC_REG(pool_id)); + + put_cpu(); + + /* Stop the BM pool */ + val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(pool_id)); + val |= MVPP2_BM_STOP_MASK; + mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(pool_id), val); +} + static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) { enum dma_data_direction dma_dir = DMA_FROM_DEVICE; int i, err, poolnum = MVPP2_BM_POOLS_NUM; struct mvpp2_port *port; + if (priv->percpu_pools) + poolnum = mvpp2_get_nrxqs(priv) * 2; + + /* Clean up the pool state in case it contains stale state */ + for (i = 0; i < poolnum; i++) + mvpp2_bm_pool_cleanup(priv, i); + if (priv->percpu_pools) { for (i = 0; i < priv->port_count; i++) { port = priv->port_list[i]; @@ -629,7 +655,6 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) } } - poolnum = mvpp2_get_nrxqs(priv) * 2; for (i = 0; i < poolnum; i++) { /* the pool in use */ int pn = i / (poolnum / 2); -- 2.25.1