Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9708d4a8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "scsi: ufs-qcom: add print suppressing debugfs mechanism"

parents b9514ed9 b0dba762
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -5,4 +5,4 @@ obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o ufs_quirks.o
obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
obj-$(CONFIG_SCSI_UFS_TEST) += ufs_test.o
obj-$(CONFIG_SCSI_UFS_TEST) += ufs_test.o
obj-$(CONFIG_DEBUG_FS) += debugfs.o
obj-$(CONFIG_DEBUG_FS) += debugfs.o qcom-debugfs.o
+6 −1
Original line number Original line Diff line number Diff line
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -1065,6 +1065,9 @@ void ufsdbg_add_debugfs(struct ufs_hba *hba)


	ufsdbg_setup_fault_injection(hba);
	ufsdbg_setup_fault_injection(hba);


	if (hba->vops && hba->vops->add_debugfs)
		hba->vops->add_debugfs(hba, hba->debugfs_files.debugfs_root);

	return;
	return;


err:
err:
@@ -1076,6 +1079,8 @@ err_no_root:


void ufsdbg_remove_debugfs(struct ufs_hba *hba)
void ufsdbg_remove_debugfs(struct ufs_hba *hba)
{
{
	if (hba->vops && hba->vops->remove_debugfs)
		hba->vops->remove_debugfs(hba);
	debugfs_remove_recursive(hba->debugfs_files.debugfs_root);
	debugfs_remove_recursive(hba->debugfs_files.debugfs_root);
	kfree(hba->ufs_stats.tag_stats);
	kfree(hba->ufs_stats.tag_stats);


+98 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (c) 2015, Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/debugfs.h>
#include <linux/scsi/ufs/ufs-qcom.h>
#include "qcom-debugfs.h"

static void ufs_qcom_dbg_remove_debugfs(struct ufs_qcom_host *host);

static int ufs_qcom_dbg_print_en_read(void *data, u64 *attr_val)
{
	struct ufs_qcom_host *host = data;

	if (!host)
		return -EINVAL;

	*attr_val = (u64)host->dbg_print_en;
	return 0;
}

static int ufs_qcom_dbg_print_en_set(void *data, u64 attr_id)
{
	struct ufs_qcom_host *host = data;

	if (!host)
		return -EINVAL;

	if (attr_id & ~UFS_QCOM_DBG_PRINT_ALL)
		return -EINVAL;

	host->dbg_print_en = (u32)attr_id;
	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(ufs_qcom_dbg_print_en_ops,
			ufs_qcom_dbg_print_en_read,
			ufs_qcom_dbg_print_en_set,
			"%llu\n");


void ufs_qcom_dbg_add_debugfs(struct ufs_hba *hba, struct dentry *root)
{
	struct ufs_qcom_host *host;

	if (!hba || !hba->priv) {
		pr_err("%s: NULL host, exiting\n", __func__);
		return;
	}

	host = hba->priv;
	host->debugfs_files.debugfs_root = debugfs_create_dir("qcom", root);
	if (IS_ERR(host->debugfs_files.debugfs_root))
		/* Don't complain -- debugfs just isn't enabled */
		goto err_no_root;
	if (!host->debugfs_files.debugfs_root) {
		/*
		 * Complain -- debugfs is enabled, but it failed to
		 * create the directory
		 */
		dev_err(host->hba->dev,
			"%s: NULL debugfs root directory, exiting", __func__);
		goto err_no_root;
	}

	host->debugfs_files.dbg_print_en =
		debugfs_create_file("dbg_print_en", S_IRUSR | S_IWUSR,
				    host->debugfs_files.debugfs_root, host,
				    &ufs_qcom_dbg_print_en_ops);
	if (!host->debugfs_files.dbg_print_en) {
		dev_err(host->hba->dev,
			"%s: failed to create dbg_print_en debugfs entry\n",
			__func__);
		goto err;
	}
	return;

err:
	ufs_qcom_dbg_remove_debugfs(host);
err_no_root:
	dev_err(host->hba->dev, "%s: failed to initialize debugfs\n", __func__);
}

static void ufs_qcom_dbg_remove_debugfs(struct ufs_qcom_host *host)
{
	debugfs_remove_recursive(host->debugfs_files.debugfs_root);
	host->debugfs_files.debugfs_root = NULL;
}
+24 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (c) 2015, Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#ifndef QCOM_DEBUGFS_H_
#define QCOM_DEBUGFS_H_

#include <linux/scsi/ufs/ufshcd.h>

#ifdef CONFIG_DEBUG_FS
void ufs_qcom_dbg_add_debugfs(struct ufs_hba *hba, struct dentry *root);
#endif

#endif /* End of Header */
+15 −3
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (c) 2013-2014, Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2015, Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -30,6 +30,9 @@
#include <linux/phy/phy-qcom-ufs.h>
#include <linux/phy/phy-qcom-ufs.h>
#include "ufshci.h"
#include "ufshci.h"
#include "ufs-qcom-ice.h"
#include "ufs-qcom-ice.h"
#include "qcom-debugfs.h"

#define DEFAULT_UFS_QCOM_DBG_PRINT_EN	UFS_QCOM_DBG_PRINT_REGS_EN


static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];
static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];


@@ -1259,6 +1262,8 @@ static int ufs_qcom_init(struct ufs_hba *hba)
	if (hba->dev->id < MAX_UFS_QCOM_HOSTS)
	if (hba->dev->id < MAX_UFS_QCOM_HOSTS)
		ufs_qcom_hosts[hba->dev->id] = host;
		ufs_qcom_hosts[hba->dev->id] = host;


	host->dbg_print_en |= DEFAULT_UFS_QCOM_DBG_PRINT_EN;

	goto out;
	goto out;


out_disable_phy:
out_disable_phy:
@@ -1362,6 +1367,10 @@ out:
static void ufs_qcom_print_hw_debug_reg_all(struct ufs_hba *hba)
static void ufs_qcom_print_hw_debug_reg_all(struct ufs_hba *hba)
{
{
	u32 reg;
	u32 reg;
	struct ufs_qcom_host *host = hba->priv;

	if (!(host->dbg_print_en & UFS_QCOM_DBG_PRINT_REGS_EN))
		return;


	ufs_qcom_dump_regs(hba, UFS_UFS_DBG_RD_REG_OCSC, 44,
	ufs_qcom_dump_regs(hba, UFS_UFS_DBG_RD_REG_OCSC, 44,
			"UFS_UFS_DBG_RD_REG_OCSC ");
			"UFS_UFS_DBG_RD_REG_OCSC ");
@@ -1397,8 +1406,8 @@ static void ufs_qcom_print_hw_debug_reg_all(struct ufs_hba *hba)


static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
{
{
	ufs_qcom_dump_regs(hba, REG_UFS_SYS1CLK_1US, 5,
	ufs_qcom_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16,
			"REG_UFS_SYS1CLK_1US ");
			"HCI Vendor Specific Registers ");


	ufs_qcom_print_hw_debug_reg_all(hba);
	ufs_qcom_print_hw_debug_reg_all(hba);
}
}
@@ -1427,5 +1436,8 @@ const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
	.crypto_engine_get_err	= ufs_qcom_crypto_engine_get_err,
	.crypto_engine_get_err	= ufs_qcom_crypto_engine_get_err,
	.crypto_engine_reset_err = ufs_qcom_crypto_engine_reset_err,
	.crypto_engine_reset_err = ufs_qcom_crypto_engine_reset_err,
	.dbg_register_dump	= ufs_qcom_dump_dbg_regs,
	.dbg_register_dump	= ufs_qcom_dump_dbg_regs,
#ifdef CONFIG_DEBUG_FS
	.add_debugfs		= ufs_qcom_dbg_add_debugfs,
#endif
};
};
EXPORT_SYMBOL(ufs_hba_qcom_vops);
EXPORT_SYMBOL(ufs_hba_qcom_vops);
Loading