driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7BNF8 CVE: NA
----------------------------------------------------------------------
In the current discovery process, the device_id of the first found device increases from 1. The log is as follows:
[ 18.781940] hisi_sas_v3_hw 0000:74:02.0: Adding to iommu group 29 [ 18.865780] scsi host5: hisi_sas_v3_hw [ 20.455325] hisi_sas_v3_hw 0000:74:02.0: phyup: phy4 link_rate=11 [ 20.461802] hisi_sas_v3_hw 0000:74:02.0: phyup: phy0 link_rate=11 [ 20.461840] sas: phy-5:4 added to port-5:0, phy_mask:0x10 (500e004aaaaaaa1f) [ 20.462080] hisi_sas_v3_hw 0000:74:02.0: phyup: phy1 link_rate=11 [ 20.468171] sas: DOING DISCOVERY on port 0, pid:1450 [ 20.468402] hisi_sas_v3_hw 0000:74:02.0: phyup: phy2 link_rate=11 [ 20.474769] hisi_sas_v3_hw 0000:74:02.0: dev[1:2] found [ 20.474974] hisi_sas_v3_hw 0000:74:02.0: phyup: phy3 link_rate=11 [ 20.474980] hisi_sas_v3_hw 0000:74:02.0: phyup: phy5 link_rate=11 [ 20.475984] sas: ex 500e004aaaaaaa1f phy00:U:0 attached: 0000000000000000 (no device) [ 20.481972] hisi_sas_v3_hw 0000:74:02.0: phyup: phy6 link_rate=11 [ 20.481976] hisi_sas_v3_hw 0000:74:02.0: phyup: phy7 link_rate=11 [ 20.535895] hisi_sas_v3_hw 0000:74:02.0: dev[2:1] found [ 20.541422] hisi_sas_v3_hw 0000:74:02.0: dev[3:1] found [ 20.546944] hisi_sas_v3_hw 0000:74:02.0: dev[4:1] found [ 20.621392] sas: DONE DISCOVERY on port 0, pid:1450, result:0
This has caused a lot of interference in our use, so we think that the device_id should be incremented from 0 by default.
Signed-off-by: Yihang Li liyihang9@huawei.com Signed-off-by: xiabing xiabing12@h-partners.com --- drivers/scsi/hisi_sas/hisi_sas_main.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 2a1b08244d1f..d93df5839b3d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -658,30 +658,32 @@ 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; - int last = hisi_hba->last_dev_id; - int first = (hisi_hba->last_dev_id + 1) % HISI_SAS_MAX_DEVICES; + int first = hisi_hba->last_dev_id % HISI_SAS_MAX_DEVICES; + int dev_id; int i;
spin_lock(&hisi_hba->lock); - 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; + for (i = first; i < first + HISI_SAS_MAX_DEVICES; i++) { + dev_id = i % HISI_SAS_MAX_DEVICES; + if (hisi_hba->devices[dev_id].dev_type == SAS_PHY_UNUSED) { + int queue = dev_id % hisi_hba->queue_count; struct hisi_sas_dq *dq = &hisi_hba->dq[queue];
- hisi_hba->devices[i].device_id = i; - sas_dev = &hisi_hba->devices[i]; + hisi_hba->devices[dev_id].device_id = dev_id; + sas_dev = &hisi_hba->devices[dev_id]; sas_dev->dev_status = HISI_SAS_DEV_INIT; sas_dev->dev_type = device->dev_type; sas_dev->hisi_hba = hisi_hba; sas_dev->sas_device = device; sas_dev->dq = dq; spin_lock_init(&sas_dev->lock); - INIT_LIST_HEAD(&hisi_hba->devices[i].list); + INIT_LIST_HEAD(&hisi_hba->devices[dev_id].list); + dev_id++; break; } - i++; } - hisi_hba->last_dev_id = i; + if (sas_dev) + hisi_hba->last_dev_id = dev_id; spin_unlock(&hisi_hba->lock);
return sas_dev;