Commit 35ea630b authored by Luo Jiaxing's avatar Luo Jiaxing Committed by Martin K. Petersen

scsi: hisi_sas: Add debugfs file structure for CQ

Create a file structure which was used to save the memory address and CQ
pointer for CQ 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-7-git-send-email-john.garry@huawei.comSigned-off-by: default avatarLuo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d28ed83b
...@@ -323,6 +323,11 @@ struct hisi_sas_hw { ...@@ -323,6 +323,11 @@ struct hisi_sas_hw {
const struct hisi_sas_debugfs_reg *debugfs_reg_port; const struct hisi_sas_debugfs_reg *debugfs_reg_port;
}; };
struct hisi_sas_debugfs_cq {
struct hisi_sas_cq *cq;
void *complete_hdr;
};
struct hisi_hba { struct hisi_hba {
/* This must be the first element, used by SHOST_TO_SAS_HA */ /* This must be the first element, used by SHOST_TO_SAS_HA */
struct sas_ha_struct *p; struct sas_ha_struct *p;
...@@ -406,7 +411,7 @@ struct hisi_hba { ...@@ -406,7 +411,7 @@ struct hisi_hba {
/* Put Global AXI and RAS Register into register array */ /* Put Global AXI and RAS Register into register array */
u32 *debugfs_regs[DEBUGFS_REGS_NUM]; u32 *debugfs_regs[DEBUGFS_REGS_NUM];
u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS];
void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES]; struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_QUEUES];
struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES]; struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES];
struct hisi_sas_iost *debugfs_iost; struct hisi_sas_iost *debugfs_iost;
struct hisi_sas_itct *debugfs_itct; struct hisi_sas_itct *debugfs_itct;
......
...@@ -2700,7 +2700,7 @@ static void hisi_sas_debugfs_snapshot_cq_reg(struct hisi_hba *hisi_hba) ...@@ -2700,7 +2700,7 @@ static void hisi_sas_debugfs_snapshot_cq_reg(struct hisi_hba *hisi_hba)
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->debugfs_complete_hdr[i], memcpy(hisi_hba->debugfs_cq[i].complete_hdr,
hisi_hba->complete_hdr[i], hisi_hba->complete_hdr[i],
HISI_SAS_QUEUE_SLOTS * queue_entry_size); HISI_SAS_QUEUE_SLOTS * queue_entry_size);
} }
...@@ -2985,13 +2985,13 @@ static void hisi_sas_show_row_32(struct seq_file *s, int index, ...@@ -2985,13 +2985,13 @@ static void hisi_sas_show_row_32(struct seq_file *s, int index,
seq_puts(s, "\n"); seq_puts(s, "\n");
} }
static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) static void hisi_sas_cq_show_slot(struct seq_file *s, int slot,
struct hisi_sas_debugfs_cq *debugfs_cq)
{ {
struct hisi_sas_cq *cq = cq_ptr; struct hisi_sas_cq *cq = debugfs_cq->cq;
struct hisi_hba *hisi_hba = cq->hisi_hba; struct hisi_hba *hisi_hba = cq->hisi_hba;
void *complete_queue = hisi_hba->debugfs_complete_hdr[cq->id]; __le32 *complete_hdr = debugfs_cq->complete_hdr +
__le32 *complete_hdr = complete_queue + (hisi_hba->hw->complete_hdr_size * slot);
(hisi_hba->hw->complete_hdr_size * slot);
hisi_sas_show_row_32(s, slot, hisi_sas_show_row_32(s, slot,
hisi_hba->hw->complete_hdr_size, hisi_hba->hw->complete_hdr_size,
...@@ -3000,11 +3000,11 @@ static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) ...@@ -3000,11 +3000,11 @@ static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr)
static int hisi_sas_debugfs_cq_show(struct seq_file *s, void *p) static int hisi_sas_debugfs_cq_show(struct seq_file *s, void *p)
{ {
struct hisi_sas_cq *cq = s->private; struct hisi_sas_debugfs_cq *debugfs_cq = s->private;
int slot; int slot;
for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) { for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) {
hisi_sas_cq_show_slot(s, slot, cq); hisi_sas_cq_show_slot(s, slot, debugfs_cq);
} }
return 0; return 0;
} }
...@@ -3227,7 +3227,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) ...@@ -3227,7 +3227,8 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba)
for (c = 0; c < hisi_hba->queue_count; c++) { for (c = 0; c < hisi_hba->queue_count; c++) {
snprintf(name, 256, "%d", c); snprintf(name, 256, "%d", c);
debugfs_create_file(name, 0400, dentry, &hisi_hba->cq[c], debugfs_create_file(name, 0400, dentry,
&hisi_hba->debugfs_cq[c],
&hisi_sas_debugfs_cq_fops); &hisi_sas_debugfs_cq_fops);
} }
...@@ -3714,7 +3715,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) ...@@ -3714,7 +3715,7 @@ static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba)
devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]); devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]);
for (i = 0; i < hisi_hba->queue_count; i++) for (i = 0; i < hisi_hba->queue_count; i++)
devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]); devm_kfree(dev, hisi_hba->debugfs_cq[i].complete_hdr);
for (i = 0; i < DEBUGFS_REGS_NUM; i++) for (i = 0; i < DEBUGFS_REGS_NUM; i++)
devm_kfree(dev, hisi_hba->debugfs_regs[i]); devm_kfree(dev, hisi_hba->debugfs_regs[i]);
...@@ -3762,11 +3763,13 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) ...@@ -3762,11 +3763,13 @@ static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba)
sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS; sz = 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->debugfs_complete_hdr[c] = struct hisi_sas_debugfs_cq *cq =
devm_kmalloc(dev, sz, GFP_KERNEL); &hisi_hba->debugfs_cq[c];
if (!hisi_hba->debugfs_complete_hdr[c]) cq->complete_hdr = devm_kmalloc(dev, sz, GFP_KERNEL);
if (!cq->complete_hdr)
goto fail; goto fail;
cq->cq = &hisi_hba->cq[c];
} }
sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS; sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment