225 lines
8.2 KiB
Diff
225 lines
8.2 KiB
Diff
From 693b66a39d5a6bbb82d9dab8475fbd9e42581cc1 Mon Sep 17 00:00:00 2001
|
|
From: Luo Jiaxing <luojiaxing@huawei.com>
|
|
Date: Thu, 24 Oct 2019 22:08:15 +0800
|
|
Subject: [PATCH 028/108] scsi: hisi_sas: Add debugfs file structure for
|
|
registers
|
|
|
|
mainline inclusion
|
|
from mainline-v5.5-rc1
|
|
commit c61163981076476e0bcf2d453dcddf8db605f115
|
|
category: feature
|
|
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F81L
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c61163981076476e0bcf2d453dcddf8db605f115
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Create a file structure which was used to save the memory address and
|
|
hisi_hba pointer for REGS at debugfs. This structure is bound to the
|
|
corresponding debugfs file, it can help callback function of debugfs file
|
|
to get what it need.
|
|
|
|
Link: https://lore.kernel.org/r/1571926105-74636-9-git-send-email-john.garry@huawei.com
|
|
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
|
|
Signed-off-by: John Garry <john.garry@huawei.com>
|
|
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
Signed-off-by: YunYi Yang <yangyunyi2@huawei.com>
|
|
|
|
Conflicts:
|
|
drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
---
|
|
drivers/scsi/hisi_sas/hisi_sas.h | 7 ++-
|
|
drivers/scsi/hisi_sas/hisi_sas_main.c | 62 +++++++++++++--------------
|
|
2 files changed, 35 insertions(+), 34 deletions(-)
|
|
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
|
|
index 95a29c345c30..fd8a128cf4d3 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas.h
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
|
|
@@ -377,6 +377,11 @@ struct hisi_sas_debugfs_dq {
|
|
struct hisi_sas_cmd_hdr *hdr;
|
|
};
|
|
|
|
+struct hisi_sas_debugfs_regs {
|
|
+ struct hisi_hba *hisi_hba;
|
|
+ u32 *data;
|
|
+};
|
|
+
|
|
struct hisi_hba {
|
|
/* This must be the first element, used by SHOST_TO_SAS_HA */
|
|
struct sas_ha_struct *p;
|
|
@@ -456,7 +461,7 @@ struct hisi_hba {
|
|
|
|
/* debugfs memories */
|
|
/* Put Global AXI and RAS Register into register array */
|
|
- u32 *debugfs_regs[DEBUGFS_REGS_NUM];
|
|
+ struct hisi_sas_debugfs_regs debugfs_regs[DEBUGFS_REGS_NUM];
|
|
u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS];
|
|
struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_QUEUES];
|
|
struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_QUEUES];
|
|
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
index fe8c998e3e9f..504c83e4f620 100644
|
|
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
|
|
@@ -2811,7 +2811,7 @@ static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba)
|
|
|
|
static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba)
|
|
{
|
|
- u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_GLOBAL];
|
|
+ u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_GLOBAL].data;
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
const struct hisi_sas_debugfs_reg *global =
|
|
hw->debugfs_reg_array[DEBUGFS_GLOBAL];
|
|
@@ -2823,7 +2823,7 @@ static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba)
|
|
|
|
static void hisi_sas_debugfs_snapshot_axi_reg(struct hisi_hba *hisi_hba)
|
|
{
|
|
- u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_AXI];
|
|
+ u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_AXI].data;
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
const struct hisi_sas_debugfs_reg *axi =
|
|
hw->debugfs_reg_array[DEBUGFS_AXI];
|
|
@@ -2836,7 +2836,7 @@ static void hisi_sas_debugfs_snapshot_axi_reg(struct hisi_hba *hisi_hba)
|
|
|
|
static void hisi_sas_debugfs_snapshot_ras_reg(struct hisi_hba *hisi_hba)
|
|
{
|
|
- u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_RAS];
|
|
+ u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_RAS].data;
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
const struct hisi_sas_debugfs_reg *ras =
|
|
hw->debugfs_reg_array[DEBUGFS_RAS];
|
|
@@ -2920,11 +2920,12 @@ static void hisi_sas_debugfs_print_reg(u32 *regs_val, const void *ptr,
|
|
|
|
static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p)
|
|
{
|
|
- struct hisi_hba *hisi_hba = s->private;
|
|
+ struct hisi_sas_debugfs_regs *global = s->private;
|
|
+ struct hisi_hba *hisi_hba = global->hisi_hba;
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
const void *reg_global = hw->debugfs_reg_array[DEBUGFS_GLOBAL];
|
|
|
|
- hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_GLOBAL],
|
|
+ hisi_sas_debugfs_print_reg(global->data,
|
|
reg_global, s);
|
|
|
|
return 0;
|
|
@@ -3328,11 +3329,12 @@ static const struct file_operations hisi_sas_debugfs_bist_enable_ops = {
|
|
|
|
static int hisi_sas_debugfs_axi_show(struct seq_file *s, void *p)
|
|
{
|
|
- struct hisi_hba *hisi_hba = s->private;
|
|
+ struct hisi_sas_debugfs_regs *ras = s->private;
|
|
+ struct hisi_hba *hisi_hba = ras->hisi_hba;
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
const void *reg_axi = hw->debugfs_reg_array[DEBUGFS_AXI];
|
|
|
|
- hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_AXI],
|
|
+ hisi_sas_debugfs_print_reg(ras->data,
|
|
reg_axi, s);
|
|
|
|
return 0;
|
|
@@ -3354,11 +3356,12 @@ static const struct file_operations hisi_sas_debugfs_axi_fops = {
|
|
|
|
static int hisi_sas_debugfs_ras_show(struct seq_file *s, void *p)
|
|
{
|
|
- struct hisi_hba *hisi_hba = s->private;
|
|
+ struct hisi_sas_debugfs_regs *ras = s->private;
|
|
+ struct hisi_hba *hisi_hba = ras->hisi_hba;
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
const void *reg_ras = hw->debugfs_reg_array[DEBUGFS_RAS];
|
|
|
|
- hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_RAS],
|
|
+ hisi_sas_debugfs_print_reg(ras->data,
|
|
reg_ras, s);
|
|
|
|
return 0;
|
|
@@ -3663,7 +3666,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba)
|
|
debugfs_create_u64("timestamp", 0400, dump_dentry,
|
|
debugfs_timestamp);
|
|
|
|
- debugfs_create_file("global", 0400, dump_dentry, hisi_hba,
|
|
+ debugfs_create_file("global", 0400, dump_dentry,
|
|
+ &hisi_hba->debugfs_regs[DEBUGFS_GLOBAL],
|
|
&hisi_sas_debugfs_global_fops);
|
|
|
|
/* Create port dir and files */
|
|
@@ -3710,10 +3714,12 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba)
|
|
debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba,
|
|
&hisi_sas_debugfs_itct_cache_fops);
|
|
|
|
- debugfs_create_file("axi", 0400, dump_dentry, hisi_hba,
|
|
+ debugfs_create_file("axi", 0400, dump_dentry,
|
|
+ &hisi_hba->debugfs_regs[DEBUGFS_AXI],
|
|
&hisi_sas_debugfs_axi_fops);
|
|
|
|
- debugfs_create_file("ras", 0400, dump_dentry, hisi_hba,
|
|
+ debugfs_create_file("ras", 0400, dump_dentry,
|
|
+ &hisi_hba->debugfs_regs[DEBUGFS_RAS],
|
|
&hisi_sas_debugfs_ras_fops);
|
|
|
|
return;
|
|
@@ -3806,7 +3812,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba)
|
|
devm_kfree(dev, hisi_hba->debugfs_cq[i].complete_hdr);
|
|
|
|
for (i = 0; i < DEBUGFS_REGS_NUM; i++)
|
|
- devm_kfree(dev, hisi_hba->debugfs_regs[i]);
|
|
+ devm_kfree(dev, hisi_hba->debugfs_regs[i].data);
|
|
|
|
for (i = 0; i < hisi_hba->n_phy; i++)
|
|
devm_kfree(dev, hisi_hba->debugfs_port_reg[i]);
|
|
@@ -3816,7 +3822,7 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba)
|
|
{
|
|
const struct hisi_sas_hw *hw = hisi_hba->hw;
|
|
struct device *dev = hisi_hba->dev;
|
|
- int p, c, d;
|
|
+ int p, c, d, r;
|
|
size_t sz;
|
|
|
|
/* create bist structures */
|
|
@@ -3852,12 +3858,16 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba)
|
|
hisi_hba, &hisi_sas_debugfs_bist_enable_ops))
|
|
goto fail;
|
|
|
|
- sz = hw->debugfs_reg_array[DEBUGFS_GLOBAL]->count * 4;
|
|
- hisi_hba->debugfs_regs[DEBUGFS_GLOBAL] =
|
|
- devm_kmalloc(dev, sz, GFP_KERNEL);
|
|
+ for (r = 0; r < DEBUGFS_REGS_NUM; r++) {
|
|
+ struct hisi_sas_debugfs_regs *regs =
|
|
+ &hisi_hba->debugfs_regs[r];
|
|
|
|
- if (!hisi_hba->debugfs_regs[DEBUGFS_GLOBAL])
|
|
- goto fail;
|
|
+ sz = hw->debugfs_reg_array[r]->count * 4;
|
|
+ regs->data = devm_kmalloc(dev, sz, GFP_KERNEL);
|
|
+ if (!regs->data)
|
|
+ goto fail;
|
|
+ regs->hisi_hba = hisi_hba;
|
|
+ }
|
|
|
|
sz = hw->debugfs_reg_port->count * 4;
|
|
for (p = 0; p < hisi_hba->n_phy; p++) {
|
|
@@ -3868,20 +3878,6 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba)
|
|
goto fail;
|
|
}
|
|
|
|
- sz = hw->debugfs_reg_array[DEBUGFS_AXI]->count * 4;
|
|
- hisi_hba->debugfs_regs[DEBUGFS_AXI] =
|
|
- devm_kmalloc(dev, sz, GFP_KERNEL);
|
|
-
|
|
- if (!hisi_hba->debugfs_regs[DEBUGFS_AXI])
|
|
- goto fail;
|
|
-
|
|
- sz = hw->debugfs_reg_array[DEBUGFS_RAS]->count * 4;
|
|
- hisi_hba->debugfs_regs[DEBUGFS_RAS] =
|
|
- devm_kmalloc(dev, sz, GFP_KERNEL);
|
|
-
|
|
- if (!hisi_hba->debugfs_regs[DEBUGFS_RAS])
|
|
- goto fail;
|
|
-
|
|
sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS;
|
|
for (c = 0; c < hisi_hba->queue_count; c++) {
|
|
struct hisi_sas_debugfs_cq *cq =
|
|
--
|
|
2.27.0
|
|
|