Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3490306pxf; Mon, 29 Mar 2021 03:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYYWHie+KxKjFwDUHIKvTfFcjcG8+jUt2+3F1zJrPqeyhIqEE4Un/WfI86eydOrip2tdsY X-Received: by 2002:a17:906:d797:: with SMTP id pj23mr28228957ejb.367.1617015017368; Mon, 29 Mar 2021 03:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617015017; cv=none; d=google.com; s=arc-20160816; b=orjQ7aLSt4BJWItSE7mofbAGl1rs4e9QrJj070v71DLGRh5MTRnJhIFxmwcgmPXwqr Q+reiPMJZxk3pfAOPUK09uk4ilcFXwWWhepij3s92EEMIFPpg9r8v77oqlc/GhNIXsIa WHV6fkXRD6LoV1PXH3ho2ns6vGKDLSFUrsZJptn6n89n72ZuFFfilxfpVKLS8tG9GLUE 2Gd+F+6T0lH0tsPGaZxu7MF/NXqMnPIh3UO7/7xWE9j99+HC1v01cyOdxchPIxJIZ/wy tmlguN9yOyPAqs6aqH1yon7wKK/kB8erFSSmVj0zk2VE5mkA1I7RnzFb7keym5MwIYO7 fhXg== 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:dkim-signature; bh=DnVdXDvJd6ZTquH89JxAewvX97yd4ztwffBLD3onuNA=; b=0qgThRW9mkW2Zo6FQvuQbaezhgAYmmrLwETjKOEF9bjjRTO6dAoUeZa6qb5fSUxQKY HN4KJtXnxtEmiDh9gPhna5gMGcsZz1lbA+9KgtcdXZPDQs4C6vRxSx+BrQCwX0aFAkuU 789se+MqMWxpcDqULv7Vntv0WbalIpJWa9UZxTCraXTUPZQhK341YroQ0/K5H5Wx5O8V MjoNkUxo4DSvISMWlU6nWbemYWuKrkVX5AuhGltAVt/tAxDhDu3DBxrAqYcePUik4OCM 6MR0z8PRSbcdHHKvgK72Pml205tDGWf+ERiWE7NXaoCxLq7513tonYFQMjt2Iwwinoj/ 3omw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BuwsOliU; 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=pass (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 r16si12771632edw.458.2021.03.29.03.49.54; Mon, 29 Mar 2021 03:50:17 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BuwsOliU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234479AbhC2Iio (ORCPT + 99 others); Mon, 29 Mar 2021 04:38:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234182AbhC2IXJ (ORCPT ); Mon, 29 Mar 2021 04:23:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8619361481; Mon, 29 Mar 2021 08:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006187; bh=GAO/aHh5HfP4Qn8Y9b4sPnLNDBe//JDfYBy7SdgXTvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BuwsOliUsrMZPv8Ffcw90uqzaPfgPXCJx6Ad6S0uTDolKD8uWszcOOvg2Fh6roOkR jYuKxQ3zsq1zUweOXakz7js25wnuhF0r/f1EewV1qUs8eNfWaOWimmO09KBz8Prvgm EBbdy340gcGY8fx4KR7JUFUSqjiSFuxHY30HvkAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rakesh Babu , Hariprasad Kelam , Sunil Kovvuri Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 150/221] octeontx2-af: Formatting debugfs entry rsrc_alloc. Date: Mon, 29 Mar 2021 09:58:01 +0200 Message-Id: <20210329075634.176505771@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Rakesh Babu [ Upstream commit f7884097141b615b6ce89c16f456a53902b4eec3 ] With the existing rsrc_alloc's format, there is misalignment for the pcifunc entries whose VF's index is a double digit. This patch fixes this. pcifunc NPA NIX0 NIX1 SSO GROUP SSOWS TIM CPT0 CPT1 REE0 REE1 PF0:VF0 8 5 PF0:VF1 9 3 PF0:VF10 18 10 PF0:VF11 19 8 PF0:VF12 20 11 PF0:VF13 21 9 PF0:VF14 22 12 PF0:VF15 23 10 PF1 0 0 Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status") Signed-off-by: Rakesh Babu Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../marvell/octeontx2/af/rvu_debugfs.c | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c index 809f50ab0432..c018121d4cc5 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c @@ -144,12 +144,14 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { - int index, off = 0, flag = 0, go_back = 0, off_prev; + int index, off = 0, flag = 0, go_back = 0, len = 0; struct rvu *rvu = filp->private_data; int lf, pf, vf, pcifunc; struct rvu_block block; int bytes_not_copied; + int lf_str_size = 12; int buf_size = 2048; + char *lfs; char *buf; /* don't allow partial reads */ @@ -159,12 +161,18 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) return -ENOSPC; - off += scnprintf(&buf[off], buf_size - 1 - off, "\npcifunc\t\t"); + + lfs = kzalloc(lf_str_size, GFP_KERNEL); + if (!lfs) + return -ENOMEM; + off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size, + "pcifunc"); for (index = 0; index < BLK_COUNT; index++) - if (strlen(rvu->hw->block[index].name)) - off += scnprintf(&buf[off], buf_size - 1 - off, - "%*s\t", (index - 1) * 2, - rvu->hw->block[index].name); + if (strlen(rvu->hw->block[index].name)) { + off += scnprintf(&buf[off], buf_size - 1 - off, + "%-*s", lf_str_size, + rvu->hw->block[index].name); + } off += scnprintf(&buf[off], buf_size - 1 - off, "\n"); for (pf = 0; pf < rvu->hw->total_pfs; pf++) { for (vf = 0; vf <= rvu->hw->total_vfs; vf++) { @@ -173,14 +181,15 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, continue; if (vf) { + sprintf(lfs, "PF%d:VF%d", pf, vf - 1); go_back = scnprintf(&buf[off], buf_size - 1 - off, - "PF%d:VF%d\t\t", pf, - vf - 1); + "%-*s", lf_str_size, lfs); } else { + sprintf(lfs, "PF%d", pf); go_back = scnprintf(&buf[off], buf_size - 1 - off, - "PF%d\t\t", pf); + "%-*s", lf_str_size, lfs); } off += go_back; @@ -188,20 +197,22 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, block = rvu->hw->block[index]; if (!strlen(block.name)) continue; - off_prev = off; + len = 0; + lfs[len] = '\0'; for (lf = 0; lf < block.lf.max; lf++) { if (block.fn_map[lf] != pcifunc) continue; flag = 1; - off += scnprintf(&buf[off], buf_size - 1 - - off, "%3d,", lf); + len += sprintf(&lfs[len], "%d,", lf); } - if (flag && off_prev != off) - off--; - else - go_back++; + + if (flag) + len--; + lfs[len] = '\0'; off += scnprintf(&buf[off], buf_size - 1 - off, - "\t"); + "%-*s", lf_str_size, lfs); + if (!strlen(lfs)) + go_back += lf_str_size; } if (!flag) off -= go_back; @@ -213,6 +224,7 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, } bytes_not_copied = copy_to_user(buffer, buf, off); + kfree(lfs); kfree(buf); if (bytes_not_copied) -- 2.30.1