Commit 257efd1f authored by John Garry's avatar John Garry Committed by Martin K. Petersen

hisi_sas: Add slot init code

Add functionality to init slot indexing.

Slot indexing is for the host to track which slots (or tags) are free
and which are used.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 89d53322
...@@ -66,6 +66,10 @@ struct hisi_hba { ...@@ -66,6 +66,10 @@ struct hisi_hba {
int n_phy; int n_phy;
int slot_index_count;
unsigned long *slot_index_tags;
/* SCSI/SAS glue */ /* SCSI/SAS glue */
struct sas_ha_struct sha; struct sas_ha_struct sha;
struct Scsi_Host *shost; struct Scsi_Host *shost;
......
...@@ -12,6 +12,21 @@ ...@@ -12,6 +12,21 @@
#include "hisi_sas.h" #include "hisi_sas.h"
#define DRV_NAME "hisi_sas" #define DRV_NAME "hisi_sas"
static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
{
void *bitmap = hisi_hba->slot_index_tags;
clear_bit(slot_idx, bitmap);
}
static void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
{
int i;
for (i = 0; i < hisi_hba->slot_index_count; ++i)
hisi_sas_slot_index_clear(hisi_hba, i);
}
static struct scsi_transport_template *hisi_sas_stt; static struct scsi_transport_template *hisi_sas_stt;
static struct scsi_host_template hisi_sas_sht = { static struct scsi_host_template hisi_sas_sht = {
...@@ -102,6 +117,12 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) ...@@ -102,6 +117,12 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
memset(hisi_hba->breakpoint, 0, s); memset(hisi_hba->breakpoint, 0, s);
hisi_hba->slot_index_count = HISI_SAS_COMMAND_ENTRIES;
s = hisi_hba->slot_index_count / sizeof(unsigned long);
hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL);
if (!hisi_hba->slot_index_tags)
goto err_out;
hisi_hba->sge_page_pool = dma_pool_create("status_sge", dev, hisi_hba->sge_page_pool = dma_pool_create("status_sge", dev,
sizeof(struct hisi_sas_sge_page), 16, 0); sizeof(struct hisi_sas_sge_page), 16, 0);
if (!hisi_hba->sge_page_pool) if (!hisi_hba->sge_page_pool)
...@@ -121,6 +142,8 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost) ...@@ -121,6 +142,8 @@ static int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost)
goto err_out; goto err_out;
memset(hisi_hba->sata_breakpoint, 0, s); memset(hisi_hba->sata_breakpoint, 0, s);
hisi_sas_slot_index_init(hisi_hba);
return 0; return 0;
err_out: err_out:
return -ENOMEM; return -ENOMEM;
......
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