lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Dec 2020 16:17:16 +0100
From:   Bean Huo <huobean@...il.com>
To:     Adrian Hunter <adrian.hunter@...el.com>,
        "Martin K . Petersen" <martin.petersen@...cle.com>,
        "James E . J . Bottomley" <jejb@...ux.ibm.com>
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Alim Akhtar <alim.akhtar@...sung.com>,
        Avri Altman <avri.altman@....com>,
        Can Guo <cang@...eaurora.org>,
        Stanley Chu <stanley.chu@...iatek.com>
Subject: Re: [PATCH V3] scsi: ufs-debugfs: Add error counters

On Fri, 2020-12-18 at 14:20 +0200, Adrian Hunter wrote:
> People testing have a need to know how many errors might be occurring
> over time. Add error counters and expose them via debugfs.
> 
> A module initcall is used to create a debugfs root directory for
> ufshcd-related items. In the case that modules are built-in, then
> initialization is done in link order, so move ufshcd-core to the top
> of
> the Makefile.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
> Reviewed-by: Avri Altman <avri.altman@....com>
> ---
> 
> 
> Changes in V3:
> 	Fixed link order to ensure correct initcall ordering when
> 	modules are built-in.
> 	Amended commit message accordingly.
> 
> Changes in V2:
> 	Add missing '#include "ufs-debugfs.h"' in ufs-debugfs.c
> 	Reported-by: kernel test robot <lkp@...el.com>
> 
> 
>  drivers/scsi/ufs/Makefile      | 13 +++++---
>  drivers/scsi/ufs/ufs-debugfs.c | 56
> ++++++++++++++++++++++++++++++++++
>  drivers/scsi/ufs/ufs-debugfs.h | 22 +++++++++++++
>  drivers/scsi/ufs/ufshcd.c      | 19 ++++++++++++
>  drivers/scsi/ufs/ufshcd.h      |  5 +++
>  5 files changed, 111 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/scsi/ufs/ufs-debugfs.c
>  create mode 100644 drivers/scsi/ufs/ufs-debugfs.h
> 
> diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
> index 4679af1b564e..06f3a3fe4a44 100644
> --- a/drivers/scsi/ufs/Makefile
> +++ b/drivers/scsi/ufs/Makefile
> @@ -1,5 +1,14 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # UFSHCD makefile
> +
> +# The link order is important here. ufshcd-core must initialize
> +# before vendor drivers.
> +obj-$(CONFIG_SCSI_UFSHCD)		+= ufshcd-core.o
> +ufshcd-core-y				+= ufshcd.o ufs-sysfs.o
> +ufshcd-core-$(CONFIG_DEBUG_FS)		+= ufs-debugfs.o
> +ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
> +ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO)	+= ufshcd-crypto.o
> +
>  obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o
> tc-dwc-g210.o
>  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
> ufshcd-dwc.o tc-dwc-g210.o
>  obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o
> @@ -7,10 +16,6 @@ obj-$(CONFIG_SCSI_UFS_QCOM) += ufs_qcom.o
>  ufs_qcom-y += ufs-qcom.o
>  ufs_qcom-$(CONFIG_SCSI_UFS_CRYPTO) += ufs-qcom-ice.o
>  obj-$(CONFIG_SCSI_UFS_EXYNOS) += ufs-exynos.o
> -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
> -ufshcd-core-y				+= ufshcd.o ufs-sysfs.o
> -ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
> -ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO) += ufshcd-crypto.o
>  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
>  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
>  obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
> diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs/ufs-
> debugfs.c
> new file mode 100644
> index 000000000000..dee98dc72d29
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufs-debugfs.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2020 Intel Corporation
> +
> +#include <linux/debugfs.h>
> +
> +#include "ufs-debugfs.h"
> +#include "ufshcd.h"
> +
> +static struct dentry *ufs_debugfs_root;
> +
> +void __init ufs_debugfs_init(void)
> +{
> +	ufs_debugfs_root = debugfs_create_dir("ufshcd", NULL);
> +}
> +
> +void __exit ufs_debugfs_exit(void)
> +{
> +	debugfs_remove_recursive(ufs_debugfs_root);
> +}
> +
> +static int ufs_debugfs_stats_show(struct seq_file *s, void *data)
> +{
> +	struct ufs_hba *hba = s->private;
> +	struct ufs_event_hist *e = hba->ufs_stats.event;
> +
> +#define PRT(fmt, typ) \
> +	seq_printf(s, fmt, e[UFS_EVT_ ## typ].cnt)
> +
> +	PRT("PHY Adapter Layer errors (except LINERESET): %llu\n",
> PA_ERR);
> +	PRT("Data Link Layer errors: %llu\n", DL_ERR);
> +	PRT("Network Layer errors: %llu\n", NL_ERR);
> +	PRT("Transport Layer errors: %llu\n", TL_ERR);
> +	PRT("Generic DME errors: %llu\n", DME_ERR);
> +	PRT("Auto-hibernate errors: %llu\n", AUTO_HIBERN8_ERR);
> +	PRT("IS Fatal errors (CEFES, SBFES, HCFES, DFES): %llu\n",
> FATAL_ERR);
> +	PRT("DME Link Startup errors: %llu\n", LINK_STARTUP_FAIL);
> +	PRT("PM Resume errors: %llu\n", RESUME_ERR);
> +	PRT("PM Suspend errors : %llu\n", SUSPEND_ERR);
> +	PRT("Logical Unit Resets: %llu\n", DEV_RESET);
> +	PRT("Host Resets: %llu\n", HOST_RESET);
> +	PRT("SCSI command aborts: %llu\n", ABORT);
> +#undef PRT
> +	return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(ufs_debugfs_stats);
> +
> +void ufs_debugfs_hba_init(struct ufs_hba *hba)
> +{

I prefer adding:
	if (!ufs_debugfs_root)
		return;

> +	hba->debugfs_root = debugfs_create_dir(dev_name(hba->dev),
> ufs_debugfs_root);

> +	debugfs_create_file("stats", 0400, hba->debugfs_root, hba,
> &ufs_debugfs_stats_fops);

	if (!debugfs_create_file("stats", 0400, hba->debugfs_root, hba,
		&ufs_debugfs_stats_fops)) {
		debugfs_remove(hba->debugfs_root);
		return -ENOMEM;
	}


Thanks,
Bean

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ