]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: hisi_sas: Change common allocation mode of device id
authorXiang Chen <chenxiang66@hisilicon.com>
Mon, 21 May 2018 10:09:15 +0000 (18:09 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 29 May 2018 02:40:31 +0000 (22:40 -0400)
To reduce possibility of hitting unknown SoC bugs and aid debugging and
test, change allocation mode of device id from last used device id instead
of lowest available index.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c

index 3c8840089cd50e0fe10cf4d94944c0a9fbae953a..b4717bd8af3f06b6b578a1ae38641af41bd70d44 100644 (file)
@@ -275,6 +275,7 @@ struct hisi_hba {
 
        int slot_index_count;
        int last_slot_index;
+       int last_dev_id;
        unsigned long *slot_index_tags;
        unsigned long reject_stp_links_msk;
 
index 796fdfc73c758f299c228148ecdf941c86cc607e..a7e4c6e77068f0faa5dda2c8401a1e42522622d6 100644 (file)
@@ -596,10 +596,12 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device)
        struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
        struct hisi_sas_device *sas_dev = NULL;
        unsigned long flags;
+       int last = hisi_hba->last_dev_id;
+       int first = (hisi_hba->last_dev_id + 1) % HISI_SAS_MAX_DEVICES;
        int i;
 
        spin_lock_irqsave(&hisi_hba->lock, flags);
-       for (i = 0; i < HISI_SAS_MAX_DEVICES; i++) {
+       for (i = first; i != last; i %= HISI_SAS_MAX_DEVICES) {
                if (hisi_hba->devices[i].dev_type == SAS_PHY_UNUSED) {
                        int queue = i % hisi_hba->queue_count;
                        struct hisi_sas_dq *dq = &hisi_hba->dq[queue];
@@ -614,7 +616,9 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device)
                        INIT_LIST_HEAD(&hisi_hba->devices[i].list);
                        break;
                }
+               i++;
        }
+       hisi_hba->last_dev_id = i;
        spin_unlock_irqrestore(&hisi_hba->lock, flags);
 
        return sas_dev;