提交 82153b96 编写于 作者: L luojiaxing 提交者: Xie XiuQi

scsi: hisi_sas: Sync upstream version of DFX feature code

John modify some code for upstream, we need to sync those
to our ci code.

Feature or Bugfix:Feature
Signed-off-by: Nluojiaxing <luojiaxing@huawei.com>
Reviewed-by: Nchenxiang <chenxiang66@hisilicon.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 89ae26ec
...@@ -233,8 +233,7 @@ struct hisi_sas_debugfs_reg { ...@@ -233,8 +233,7 @@ struct hisi_sas_debugfs_reg {
int base_off; int base_off;
union { union {
u32 (*read_global_reg)(struct hisi_hba *hisi_hba, u32 off); u32 (*read_global_reg)(struct hisi_hba *hisi_hba, u32 off);
u32 (*read_port_reg)(struct hisi_hba *hisi_hba, u32 (*read_port_reg)(struct hisi_hba *hisi_hba, int port,
int port,
u32 off); u32 off);
}; };
}; };
...@@ -351,22 +350,22 @@ struct hisi_hba { ...@@ -351,22 +350,22 @@ struct hisi_hba {
const struct hisi_sas_hw *hw; /* Low level hw interface */ const struct hisi_sas_hw *hw; /* Low level hw interface */
unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)];
struct work_struct rst_work; struct work_struct rst_work;
struct work_struct dfx_work; struct work_struct debugfs_work;
u32 phy_state; u32 phy_state;
u32 intr_coal_ticks; /* time of interrupt coalesce, unit:1us */ u32 intr_coal_ticks; /* time of interrupt coalesce, unit:1us */
u32 intr_coal_count; /* count of interrupt coalesce */ u32 intr_coal_count; /* count of interrupt coalesce */
int enable_dix_dif; int enable_dix_dif;
/* debugfs memories */ /* debugfs memories */
void *global_reg_debugfs; void *debugfs_global_reg;
void *port_reg_debugfs[HISI_SAS_MAX_PHYS]; void *debugfs_port_reg[HISI_SAS_MAX_PHYS];
void *complete_hdr_debugfs[HISI_SAS_MAX_QUEUES]; void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES];
struct hisi_sas_cmd_hdr *cmd_hdr_debugfs[HISI_SAS_MAX_QUEUES]; struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES];
struct hisi_sas_iost *iost_debugfs; struct hisi_sas_iost *debugfs_iost;
struct hisi_sas_itct *itct_debugfs; struct hisi_sas_itct *debugfs_itct;
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
struct dentry *dump_dentry; struct dentry *debugfs_dump_dentry;
bool user_ctl_irq; bool user_ctl_irq;
unsigned int reply_map[NR_CPUS]; unsigned int reply_map[NR_CPUS];
...@@ -509,7 +508,7 @@ struct hisi_sas_slot_dif_buf_table { ...@@ -509,7 +508,7 @@ struct hisi_sas_slot_dif_buf_table {
}; };
extern bool hisi_sas_debugfs_enable; extern bool hisi_sas_debugfs_enable;
extern struct dentry *hisi_sas_dbg_dir; extern struct dentry *hisi_sas_debugfs_dir;
extern int skip_bus_flag; extern int skip_bus_flag;
extern struct scsi_transport_template *hisi_sas_stt; extern struct scsi_transport_template *hisi_sas_stt;
extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba);
...@@ -536,7 +535,6 @@ extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, ...@@ -536,7 +535,6 @@ extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot); struct hisi_sas_slot *slot);
extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba);
extern void hisi_sas_rst_work_handler(struct work_struct *work); extern void hisi_sas_rst_work_handler(struct work_struct *work);
extern void hisi_sas_dfx_work_handler(struct work_struct *work);
extern void hisi_sas_sync_rst_work_handler(struct work_struct *work); extern void hisi_sas_sync_rst_work_handler(struct work_struct *work);
extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba); extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba);
extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy,
...@@ -548,4 +546,5 @@ extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); ...@@ -548,4 +546,5 @@ extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba);
extern void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba); extern void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba);
extern void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba); extern void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba);
extern void hisi_sas_snapshot_regs(struct hisi_hba *hisi_hba); extern void hisi_sas_snapshot_regs(struct hisi_hba *hisi_hba);
extern void hisi_sas_debugfs_work_handler(struct work_struct *work);
#endif #endif
...@@ -1545,10 +1545,10 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba) ...@@ -1545,10 +1545,10 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
struct device *dev = hisi_hba->dev; struct device *dev = hisi_hba->dev;
struct Scsi_Host *shost = hisi_hba->shost; struct Scsi_Host *shost = hisi_hba->shost;
int rc; int rc;
if (hisi_sas_debugfs_enable &&
hisi_hba->itct_debugfs && if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct &&
!hisi_hba->dump_dentry) !hisi_hba->debugfs_dump_dentry)
queue_work(hisi_hba->wq, &hisi_hba->dfx_work); queue_work(hisi_hba->wq, &hisi_hba->debugfs_work);
if (!hisi_hba->hw->soft_reset) if (!hisi_hba->hw->soft_reset)
return -1; return -1;
...@@ -2417,15 +2417,6 @@ void hisi_sas_sync_rst_work_handler(struct work_struct *work) ...@@ -2417,15 +2417,6 @@ void hisi_sas_sync_rst_work_handler(struct work_struct *work)
} }
EXPORT_SYMBOL_GPL(hisi_sas_sync_rst_work_handler); EXPORT_SYMBOL_GPL(hisi_sas_sync_rst_work_handler);
void hisi_sas_dfx_work_handler(struct work_struct *work)
{
struct hisi_hba *hisi_hba =
container_of(work, struct hisi_hba, dfx_work);
hisi_sas_snapshot_regs(hisi_hba);
}
EXPORT_SYMBOL_GPL(hisi_sas_dfx_work_handler);
int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba) int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba)
{ {
struct device *dev = hisi_hba->dev; struct device *dev = hisi_hba->dev;
...@@ -2635,32 +2626,31 @@ int hisi_sas_probe(struct platform_device *pdev, ...@@ -2635,32 +2626,31 @@ int hisi_sas_probe(struct platform_device *pdev,
} }
EXPORT_SYMBOL_GPL(hisi_sas_probe); EXPORT_SYMBOL_GPL(hisi_sas_probe);
struct dentry *hisi_sas_dbg_dir; struct dentry *hisi_sas_debugfs_dir;
static void hisi_sas_snapshot_cq_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_cq_reg(struct hisi_hba *hisi_hba)
{ {
int queue_entry_size = hisi_hba->hw->complete_hdr_size; int queue_entry_size = hisi_hba->hw->complete_hdr_size;
int i; int i;
for (i = 0; i < hisi_hba->queue_count; i++) for (i = 0; i < hisi_hba->queue_count; i++)
memcpy(hisi_hba->complete_hdr_debugfs[i], memcpy(hisi_hba->debugfs_complete_hdr[i],
hisi_hba->complete_hdr[i], hisi_hba->complete_hdr[i],
HISI_SAS_QUEUE_SLOTS * queue_entry_size); HISI_SAS_QUEUE_SLOTS * queue_entry_size);
} }
static void hisi_sas_debugfs_snapshot_dq_reg(struct hisi_hba *hisi_hba)
static void hisi_sas_snapshot_dq_reg(struct hisi_hba *hisi_hba)
{ {
int queue_entry_size = hisi_hba->hw->complete_hdr_size; int queue_entry_size = hisi_hba->hw->complete_hdr_size;
int i; int i;
for (i = 0; i < hisi_hba->queue_count; i++) for (i = 0; i < hisi_hba->queue_count; i++)
memcpy(hisi_hba->cmd_hdr_debugfs[i], memcpy(hisi_hba->debugfs_cmd_hdr[i],
hisi_hba->cmd_hdr[i], hisi_hba->cmd_hdr[i],
HISI_SAS_QUEUE_SLOTS * queue_entry_size); HISI_SAS_QUEUE_SLOTS * queue_entry_size);
} }
static void hisi_sas_snapshot_port_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba)
{ {
const struct hisi_sas_debugfs_reg *port = const struct hisi_sas_debugfs_reg *port =
hisi_hba->hw->debugfs_reg_port; hisi_hba->hw->debugfs_reg_port;
...@@ -2669,31 +2659,29 @@ static void hisi_sas_snapshot_port_reg(struct hisi_hba *hisi_hba) ...@@ -2669,31 +2659,29 @@ static void hisi_sas_snapshot_port_reg(struct hisi_hba *hisi_hba)
u32 *databuf; u32 *databuf;
for (phy_cnt = 0; phy_cnt < hisi_hba->n_phy; phy_cnt++) { for (phy_cnt = 0; phy_cnt < hisi_hba->n_phy; phy_cnt++) {
databuf = (u32 *)hisi_hba->port_reg_debugfs[phy_cnt]; databuf = (u32 *)hisi_hba->debugfs_port_reg[phy_cnt];
for (i = 0; i < port->count; i++, databuf++) { for (i = 0; i < port->count; i++, databuf++) {
offset = port->base_off + 4 * i; offset = port->base_off + 4 * i;
*databuf = port->read_port_reg(hisi_hba, *databuf = port->read_port_reg(hisi_hba, phy_cnt,
phy_cnt,
offset); offset);
} }
} }
} }
static void hisi_sas_snapshot_global_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba)
{ {
u32 *databuf = (u32 *)hisi_hba->global_reg_debugfs; u32 *databuf = (u32 *)hisi_hba->debugfs_global_reg;
const struct hisi_sas_debugfs_reg *global = const struct hisi_sas_debugfs_reg *global =
hisi_hba->hw->debugfs_reg_global; hisi_hba->hw->debugfs_reg_global;
int i; int i;
for (i = 0; i < global->count; i++, databuf++) for (i = 0; i < global->count; i++, databuf++)
*databuf = global->read_global_reg(hisi_hba, *databuf = global->read_global_reg(hisi_hba, 4 * i);
4 * i);
} }
static void hisi_sas_snapshot_itct_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba)
{ {
void *databuf = hisi_hba->itct_debugfs; void *databuf = hisi_hba->debugfs_itct;
struct hisi_sas_itct *itct; struct hisi_sas_itct *itct;
int i; int i;
...@@ -2705,10 +2693,10 @@ static void hisi_sas_snapshot_itct_reg(struct hisi_hba *hisi_hba) ...@@ -2705,10 +2693,10 @@ static void hisi_sas_snapshot_itct_reg(struct hisi_hba *hisi_hba)
} }
} }
static void hisi_sas_snapshot_iost_reg(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba)
{ {
int max_command_entries = hisi_hba->hw->max_command_entries; int max_command_entries = hisi_hba->hw->max_command_entries;
void *databuf = hisi_hba->iost_debugfs; void *databuf = hisi_hba->debugfs_iost;
struct hisi_sas_iost *iost; struct hisi_sas_iost *iost;
int i; int i;
...@@ -2720,8 +2708,8 @@ static void hisi_sas_snapshot_iost_reg(struct hisi_hba *hisi_hba) ...@@ -2720,8 +2708,8 @@ static void hisi_sas_snapshot_iost_reg(struct hisi_hba *hisi_hba)
} }
} }
const char *hisi_sas_reg_name(int off, const char *
int base_off, hisi_sas_debugfs_to_reg_name(int off, int base_off,
const struct hisi_sas_debugfs_reg_lu *lu) const struct hisi_sas_debugfs_reg_lu *lu)
{ {
for (; lu->name; lu++) { for (; lu->name; lu++) {
...@@ -2732,8 +2720,7 @@ const char *hisi_sas_reg_name(int off, ...@@ -2732,8 +2720,7 @@ const char *hisi_sas_reg_name(int off,
return NULL; return NULL;
} }
static void hisi_sas_print_reg(u32 *regs_val, static void hisi_sas_debugfs_print_reg(u32 *regs_val, const void *ptr,
const void *ptr,
struct seq_file *s) struct seq_file *s)
{ {
const struct hisi_sas_debugfs_reg *reg = ptr; const struct hisi_sas_debugfs_reg *reg = ptr;
...@@ -2741,18 +2728,16 @@ static void hisi_sas_print_reg(u32 *regs_val, ...@@ -2741,18 +2728,16 @@ static void hisi_sas_print_reg(u32 *regs_val,
for (i = 0; i < reg->count; i++) { for (i = 0; i < reg->count; i++) {
int off = i * 4; int off = i * 4;
const char *name = hisi_sas_reg_name(off, const char *name;
reg->base_off,
name = hisi_sas_debugfs_to_reg_name(off, reg->base_off,
reg->lu); reg->lu);
if (name) if (name)
seq_printf(s, "0x%08x 0x%08x %s\n", seq_printf(s, "0x%08x 0x%08x %s\n", off,
off, le32_to_cpu(regs_val[i]), name);
le32_to_cpu(regs_val[i]),
name);
else else
seq_printf(s, "0x%08x 0x%08x\n", seq_printf(s, "0x%08x 0x%08x\n", off,
off,
le32_to_cpu(regs_val[i])); le32_to_cpu(regs_val[i]));
} }
} }
...@@ -2763,7 +2748,8 @@ static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p) ...@@ -2763,7 +2748,8 @@ static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p)
const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_hw *hw = hisi_hba->hw;
const struct hisi_sas_debugfs_reg *reg_global = hw->debugfs_reg_global; const struct hisi_sas_debugfs_reg *reg_global = hw->debugfs_reg_global;
hisi_sas_print_reg((u32 *)hisi_hba->global_reg_debugfs, reg_global, s); hisi_sas_debugfs_print_reg((u32 *)hisi_hba->debugfs_global_reg,
reg_global, s);
return 0; return 0;
} }
...@@ -2788,9 +2774,9 @@ static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p) ...@@ -2788,9 +2774,9 @@ static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p)
struct hisi_hba *hisi_hba = phy->hisi_hba; struct hisi_hba *hisi_hba = phy->hisi_hba;
const struct hisi_sas_hw *hw = hisi_hba->hw; const struct hisi_sas_hw *hw = hisi_hba->hw;
const struct hisi_sas_debugfs_reg *reg_port = hw->debugfs_reg_port; const struct hisi_sas_debugfs_reg *reg_port = hw->debugfs_reg_port;
u32 *databuf = hisi_hba->port_reg_debugfs[phy->sas_phy.id]; u32 *databuf = hisi_hba->debugfs_port_reg[phy->sas_phy.id];
hisi_sas_print_reg(databuf, reg_port, s); hisi_sas_debugfs_print_reg(databuf, reg_port, s);
return 0; return 0;
} }
...@@ -2808,10 +2794,26 @@ static const struct file_operations hisi_sas_debugfs_port_fops = { ...@@ -2808,10 +2794,26 @@ static const struct file_operations hisi_sas_debugfs_port_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int hisi_sas_show_row_32(struct seq_file *s, static int hisi_sas_show_row_64(struct seq_file *s, int index,
int index, int sz, u64 *ptr)
int sz, {
u32 *ptr) int i;
/* completion header size not fixed per HW version */
seq_printf(s, "index %04d:\n\t", index);
for (i = 1; i <= sz / 8; i++, ptr++) {
seq_printf(s, " 0x%016llx", le64_to_cpu(*ptr));
if (!(i % 2))
seq_puts(s, "\n\t");
}
seq_puts(s, "\n");
return 0;
}
static int hisi_sas_show_row_32(struct seq_file *s, int index,
int sz, u32 *ptr)
{ {
int i; int i;
...@@ -2819,8 +2821,7 @@ static int hisi_sas_show_row_32(struct seq_file *s, ...@@ -2819,8 +2821,7 @@ static int hisi_sas_show_row_32(struct seq_file *s,
seq_printf(s, "index %04d:\n\t", index); seq_printf(s, "index %04d:\n\t", index);
for (i = 1; i <= sz / 4; i++, ptr++) { for (i = 1; i <= sz / 4; i++, ptr++) {
seq_printf(s, " 0x%08x", le32_to_cpu(*ptr)); seq_printf(s, " 0x%08x", le32_to_cpu(*ptr));
/* when print 8 character , new a line */ if (!(i % 4))
if (!(i % 8))
seq_puts(s, "\n\t"); seq_puts(s, "\n\t");
} }
seq_puts(s, "\n"); seq_puts(s, "\n");
...@@ -2828,13 +2829,11 @@ static int hisi_sas_show_row_32(struct seq_file *s, ...@@ -2828,13 +2829,11 @@ static int hisi_sas_show_row_32(struct seq_file *s,
return 0; return 0;
} }
static int hisi_sas_cq_show_slot(struct seq_file *s, static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr)
int slot,
void *cq_ptr)
{ {
struct hisi_sas_cq *cq = cq_ptr; struct hisi_sas_cq *cq = cq_ptr;
struct hisi_hba *hisi_hba = cq->hisi_hba; struct hisi_hba *hisi_hba = cq->hisi_hba;
void *complete_queue = hisi_hba->complete_hdr_debugfs[cq->id]; void *complete_queue = hisi_hba->debugfs_complete_hdr[cq->id];
u64 offset = hisi_hba->hw->complete_hdr_size * slot; u64 offset = hisi_hba->hw->complete_hdr_size * slot;
void *complete_hdr = complete_queue + offset; void *complete_hdr = complete_queue + offset;
...@@ -2869,18 +2868,15 @@ static const struct file_operations hisi_sas_debugfs_cq_fops = { ...@@ -2869,18 +2868,15 @@ static const struct file_operations hisi_sas_debugfs_cq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int hisi_sas_dq_show_slot(struct seq_file *s, static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr)
int slot,
void *dq_ptr)
{ {
struct hisi_sas_dq *dq = dq_ptr; struct hisi_sas_dq *dq = dq_ptr;
struct hisi_hba *hisi_hba = dq->hisi_hba; struct hisi_hba *hisi_hba = dq->hisi_hba;
void *cmd_queue = hisi_hba->cmd_hdr_debugfs[dq->id]; void *cmd_queue = hisi_hba->debugfs_cmd_hdr[dq->id];
u64 offset = hisi_hba->hw->complete_hdr_size * slot; u64 offset = sizeof(struct hisi_sas_cmd_hdr) * slot;
void *cmd_hdr = cmd_queue + offset; void *cmd_hdr = cmd_queue + offset;
return hisi_sas_show_row_32(s, slot, return hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr),
sizeof(struct hisi_sas_cmd_hdr),
cmd_hdr); cmd_hdr);
} }
...@@ -2889,8 +2885,7 @@ static int hisi_sas_debugfs_dq_show(struct seq_file *s, void *p) ...@@ -2889,8 +2885,7 @@ static int hisi_sas_debugfs_dq_show(struct seq_file *s, void *p)
int slot, ret; int slot, ret;
for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) {
ret = hisi_sas_dq_show_slot(s, slot, ret = hisi_sas_dq_show_slot(s, slot, s->private);
s->private);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -2910,37 +2905,15 @@ static const struct file_operations hisi_sas_debugfs_dq_fops = { ...@@ -2910,37 +2905,15 @@ static const struct file_operations hisi_sas_debugfs_dq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int hisi_sas_show_row_64(struct seq_file *s,
int index,
int sz,
u64 *ptr)
{
int i;
/* completion header size not fixed per HW version */
seq_printf(s, "index %04d:\n\t", index);
for (i = 1; i <= sz / 8; i++, ptr++) {
seq_printf(s, " 0x%016llx", le64_to_cpu(*ptr));
/* when print 4 character , new a line */
if (!(i % 4))
seq_puts(s, "\n\t");
}
seq_puts(s, "\n");
return 0;
}
static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p)
{ {
struct hisi_hba *hisi_hba = s->private; struct hisi_hba *hisi_hba = s->private;
struct hisi_sas_iost *iost_debugfs = hisi_hba->iost_debugfs; struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost;
int i, ret, max_command_entries = hisi_hba->hw->max_command_entries; int i, ret, max_command_entries = hisi_hba->hw->max_command_entries;
for (i = 0; i < max_command_entries; i++, iost_debugfs++) { for (i = 0; i < max_command_entries; i++, debugfs_iost++) {
ret = hisi_sas_show_row_64(s, i, ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost),
sizeof(*iost_debugfs), (u64 *)debugfs_iost);
(u64 *)iost_debugfs);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -2965,12 +2938,11 @@ static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p) ...@@ -2965,12 +2938,11 @@ static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p)
{ {
int i, ret; int i, ret;
struct hisi_hba *hisi_hba = s->private; struct hisi_hba *hisi_hba = s->private;
struct hisi_sas_itct *itct_debugfs = hisi_hba->itct_debugfs; struct hisi_sas_itct *debugfs_itct = hisi_hba->debugfs_itct;
for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, itct_debugfs++) { for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, debugfs_itct++) {
ret = hisi_sas_show_row_64(s, i, ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct),
sizeof(*itct_debugfs), (u64 *)debugfs_itct);
(u64 *)itct_debugfs);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -2991,7 +2963,7 @@ static const struct file_operations hisi_sas_debugfs_itct_fops = { ...@@ -2991,7 +2963,7 @@ static const struct file_operations hisi_sas_debugfs_itct_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba)
{ {
struct dentry *dump_dentry; struct dentry *dump_dentry;
struct dentry *dentry; struct dentry *dentry;
...@@ -3005,13 +2977,9 @@ static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba) ...@@ -3005,13 +2977,9 @@ static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba)
if (!dump_dentry) if (!dump_dentry)
goto fail; goto fail;
/* Create global dir and files */ hisi_hba->debugfs_dump_dentry = dump_dentry;
dentry = debugfs_create_dir("global", dump_dentry);
if (!dentry)
goto fail;
if (!debugfs_create_file("global", 0400, dentry, if (!debugfs_create_file("global", 0400, dump_dentry, hisi_hba,
hisi_hba,
&hisi_sas_debugfs_global_fops)) &hisi_sas_debugfs_global_fops))
goto fail; goto fail;
...@@ -3056,48 +3024,43 @@ static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba) ...@@ -3056,48 +3024,43 @@ static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba)
goto fail; goto fail;
} }
/* Create iost dir and files */ if (!debugfs_create_file("iost", 0400, dump_dentry, hisi_hba,
dentry = debugfs_create_dir("iost", dump_dentry);
if (!dentry)
goto fail;
if (!debugfs_create_file("iost", 0400, dentry,
hisi_hba,
&hisi_sas_debugfs_iost_fops)) &hisi_sas_debugfs_iost_fops))
goto fail; goto fail;
/* Create itct dir and files */ if (!debugfs_create_file("itct", 0400, dump_dentry, hisi_hba,
dentry = debugfs_create_dir("itct", dump_dentry);
if (!dentry)
goto fail;
if (!debugfs_create_file("itct", 0400, dentry,
hisi_hba,
&hisi_sas_debugfs_itct_fops)) &hisi_sas_debugfs_itct_fops))
goto fail; goto fail;
hisi_hba->dump_dentry = dump_dentry;
return; return;
fail: fail:
debugfs_remove_recursive(hisi_hba->debugfs_dir); debugfs_remove_recursive(hisi_hba->debugfs_dir);
} }
void hisi_sas_snapshot_regs(struct hisi_hba *hisi_hba) static void hisi_sas_debugfs_snapshot_regs(struct hisi_hba *hisi_hba)
{ {
hisi_hba->hw->snapshot_prepare(hisi_hba); hisi_hba->hw->snapshot_prepare(hisi_hba);
hisi_sas_snapshot_global_reg(hisi_hba); hisi_sas_debugfs_snapshot_global_reg(hisi_hba);
hisi_sas_snapshot_port_reg(hisi_hba); hisi_sas_debugfs_snapshot_port_reg(hisi_hba);
hisi_sas_snapshot_cq_reg(hisi_hba); hisi_sas_debugfs_snapshot_cq_reg(hisi_hba);
hisi_sas_snapshot_dq_reg(hisi_hba); hisi_sas_debugfs_snapshot_dq_reg(hisi_hba);
hisi_sas_snapshot_itct_reg(hisi_hba); hisi_sas_debugfs_snapshot_itct_reg(hisi_hba);
hisi_sas_snapshot_iost_reg(hisi_hba); hisi_sas_debugfs_snapshot_iost_reg(hisi_hba);
hisi_sas_create_folder_structure(hisi_hba); hisi_sas_debugfs_create_files(hisi_hba);
hisi_hba->hw->snapshot_restore(hisi_hba); hisi_hba->hw->snapshot_restore(hisi_hba);
} }
EXPORT_SYMBOL_GPL(hisi_sas_snapshot_regs);
void hisi_sas_debugfs_work_handler(struct work_struct *work)
{
struct hisi_hba *hisi_hba =
container_of(work, struct hisi_hba, debugfs_work);
hisi_sas_debugfs_snapshot_regs(hisi_hba);
}
EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler);
void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba)
{ {
...@@ -3107,79 +3070,80 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) ...@@ -3107,79 +3070,80 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba)
size_t sz; size_t sz;
hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev), hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev),
hisi_sas_dbg_dir); hisi_sas_debugfs_dir);
if (!hisi_hba->debugfs_dir) if (!hisi_hba->debugfs_dir)
return; return;
/* Alloc buffer for global */ /* Alloc buffer for global */
sz = hisi_hba->hw->debugfs_reg_global->count * 4; sz = hisi_hba->hw->debugfs_reg_global->count * 4;
hisi_hba->global_reg_debugfs = hisi_hba->debugfs_global_reg =
devm_kmalloc(dev, sz, GFP_KERNEL); devm_kmalloc(dev, sz, GFP_KERNEL);
if (!hisi_hba->global_reg_debugfs) if (!hisi_hba->debugfs_global_reg)
goto fail_global; goto fail_global;
/* Alloc buffer for port */ /* Alloc buffer for port */
sz = hisi_hba->hw->debugfs_reg_port->count * 4; sz = hisi_hba->hw->debugfs_reg_port->count * 4;
for (p = 0; p < hisi_hba->n_phy; p++) { for (p = 0; p < hisi_hba->n_phy; p++) {
hisi_hba->port_reg_debugfs[p] = hisi_hba->debugfs_port_reg[p] =
devm_kmalloc(dev, sz, GFP_KERNEL); devm_kmalloc(dev, sz, GFP_KERNEL);
if (!hisi_hba->port_reg_debugfs[p]) if (!hisi_hba->debugfs_port_reg[p])
goto fail_port; goto fail_port;
} }
/* Alloc buffer for cq */ /* Alloc buffer for cq */
sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS;
for (c = 0; c < hisi_hba->queue_count; c++) { for (c = 0; c < hisi_hba->queue_count; c++) {
hisi_hba->complete_hdr_debugfs[c] = hisi_hba->debugfs_complete_hdr[c] =
devm_kmalloc(dev, sz, GFP_KERNEL); devm_kmalloc(dev, sz, GFP_KERNEL);
if (!hisi_hba->complete_hdr_debugfs[c]) if (!hisi_hba->debugfs_complete_hdr[c])
goto fail_cq; goto fail_cq;
} }
/* Alloc buffer for dq */ /* Alloc buffer for dq */
sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS;
for (d = 0; d < hisi_hba->queue_count; d++) { for (d = 0; d < hisi_hba->queue_count; d++) {
hisi_hba->cmd_hdr_debugfs[d] = hisi_hba->debugfs_cmd_hdr[d] =
devm_kmalloc(dev, sz, GFP_KERNEL); devm_kmalloc(dev, sz, GFP_KERNEL);
if (!hisi_hba->cmd_hdr_debugfs[d]) if (!hisi_hba->debugfs_cmd_hdr[d])
goto fail_iost_dq; goto fail_iost_dq;
} }
/* Alloc buffer for iost */ /* Alloc buffer for iost */
sz = max_command_entries * sizeof(struct hisi_sas_iost); sz = max_command_entries * sizeof(struct hisi_sas_iost);
hisi_hba->iost_debugfs = devm_kmalloc(dev, sz, GFP_KERNEL); hisi_hba->debugfs_iost = devm_kmalloc(dev, sz, GFP_KERNEL);
if (!hisi_hba->iost_debugfs) if (!hisi_hba->debugfs_iost)
goto fail_iost_dq; goto fail_iost_dq;
/* Alloc buffer for itct */ /* Alloc buffer for itct */
/* New memory allocation must be locate before itct */ /* New memory allocation must be locate before itct */
sz = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct); sz = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct);
hisi_hba->itct_debugfs = devm_kmalloc(dev, sz, GFP_KERNEL); hisi_hba->debugfs_itct = devm_kmalloc(dev, sz, GFP_KERNEL);
if (!hisi_hba->itct_debugfs) if (!hisi_hba->debugfs_itct)
goto fail_itct; goto fail_itct;
return; return;
fail_itct: fail_itct:
devm_kfree(dev, hisi_hba->iost_debugfs); devm_kfree(dev, hisi_hba->debugfs_iost);
fail_iost_dq: fail_iost_dq:
for (i = 0; i < d; i++) for (i = 0; i < d; i++)
devm_kfree(dev, hisi_hba->cmd_hdr_debugfs[i]); devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]);
fail_cq: fail_cq:
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
devm_kfree(dev, hisi_hba->complete_hdr_debugfs[i]); devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]);
fail_port: fail_port:
for (i = 0; i < p; i++) for (i = 0; i < p; i++)
devm_kfree(dev, hisi_hba->port_reg_debugfs[i]); devm_kfree(dev, hisi_hba->debugfs_port_reg[i]);
devm_kfree(dev, hisi_hba->global_reg_debugfs); devm_kfree(dev, hisi_hba->debugfs_global_reg);
fail_global: fail_global:
debugfs_remove_recursive(hisi_hba->debugfs_dir); debugfs_remove_recursive(hisi_hba->debugfs_dir);
dev_err(dev, "Dev: %s fail to init Debugfs!", dev_name(dev)); dev_dbg(dev, "failed to init debugfs!\n");
} }
EXPORT_SYMBOL_GPL(hisi_sas_debugfs_init); EXPORT_SYMBOL_GPL(hisi_sas_debugfs_init);
...@@ -3210,7 +3174,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_remove); ...@@ -3210,7 +3174,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_remove);
bool hisi_sas_debugfs_enable; bool hisi_sas_debugfs_enable;
EXPORT_SYMBOL_GPL(hisi_sas_debugfs_enable); EXPORT_SYMBOL_GPL(hisi_sas_debugfs_enable);
module_param_named(debugfs_enable, hisi_sas_debugfs_enable, bool, 0444); module_param_named(debugfs_enable, hisi_sas_debugfs_enable, bool, 0444);
MODULE_PARM_DESC(hisi_sas_debugfs_enable, "Enable debugfs services"); MODULE_PARM_DESC(hisi_sas_debugfs_enable, "Enable driver debugfs (default disabled)");
static __init int hisi_sas_init(void) static __init int hisi_sas_init(void)
{ {
...@@ -3219,7 +3183,7 @@ static __init int hisi_sas_init(void) ...@@ -3219,7 +3183,7 @@ static __init int hisi_sas_init(void)
return -ENOMEM; return -ENOMEM;
if (hisi_sas_debugfs_enable) if (hisi_sas_debugfs_enable)
hisi_sas_dbg_dir = debugfs_create_dir("hisi_sas", NULL); hisi_sas_debugfs_dir = debugfs_create_dir("hisi_sas", NULL);
return 0; return 0;
} }
...@@ -3228,8 +3192,7 @@ static __exit void hisi_sas_exit(void) ...@@ -3228,8 +3192,7 @@ static __exit void hisi_sas_exit(void)
{ {
sas_release_transport(hisi_sas_stt); sas_release_transport(hisi_sas_stt);
if (hisi_sas_debugfs_enable) debugfs_remove(hisi_sas_debugfs_dir);
debugfs_remove(hisi_sas_dbg_dir);
} }
module_init(hisi_sas_init); module_init(hisi_sas_init);
......
...@@ -2673,6 +2673,8 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) ...@@ -2673,6 +2673,8 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
if (is_sata_phy_v2_hw(hisi_hba, phy_no)) if (is_sata_phy_v2_hw(hisi_hba, phy_no))
goto end; goto end;
del_timer(&phy->timer);
if (phy_no == 8) { if (phy_no == 8) {
u32 port_state = hisi_sas_read32(hisi_hba, PORT_STATE); u32 port_state = hisi_sas_read32(hisi_hba, PORT_STATE);
......
...@@ -2781,7 +2781,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev) ...@@ -2781,7 +2781,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)
hisi_hba = shost_priv(shost); hisi_hba = shost_priv(shost);
INIT_WORK(&hisi_hba->rst_work, hisi_sas_rst_work_handler); INIT_WORK(&hisi_hba->rst_work, hisi_sas_rst_work_handler);
INIT_WORK(&hisi_hba->dfx_work, hisi_sas_dfx_work_handler); INIT_WORK(&hisi_hba->debugfs_work, hisi_sas_debugfs_work_handler);
hisi_hba->hw = &hisi_sas_v3_hw; hisi_hba->hw = &hisi_sas_v3_hw;
hisi_hba->pci_dev = pdev; hisi_hba->pci_dev = pdev;
hisi_hba->dev = dev; hisi_hba->dev = dev;
...@@ -2953,7 +2953,6 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev) ...@@ -2953,7 +2953,6 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev)
struct hisi_hba *hisi_hba = sha->lldd_ha; struct hisi_hba *hisi_hba = sha->lldd_ha;
struct Scsi_Host *shost = sha->core.shost; struct Scsi_Host *shost = sha->core.shost;
if (hisi_sas_debugfs_enable)
hisi_sas_debugfs_exit(hisi_hba); hisi_sas_debugfs_exit(hisi_hba);
if (timer_pending(&hisi_hba->timer)) if (timer_pending(&hisi_hba->timer))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册