Skip to content

Commit e78276c

Browse files
Lencerfmartinkpetersen
authored andcommitted
scsi: pm80xx: Fix 'Unknown' max/min linkrate
Currently, the data flow of the max/min linkrate in the driver is * in pm8001_get_lrate_mode(): hardcoded value ==> struct sas_phy * in pm8001_bytes_dmaed(): struct pm8001_phy ==> struct sas_phy * in pm8001_phy_control(): libsas data ==> struct pm8001_phy Since pm8001_bytes_dmaed() follows pm8001_get_lrate_mode(), and the fields in struct pm8001_phy are not initialized, sysfs `/sys/class/sas_phy/phy-*/maximum_linkrate` always shows `Unknown`. To fix the issue, change the dataflow to the following: * in pm8001_phy_init(): initial value ==> struct pm8001_phy * in pm8001_get_lrate_mode(): struct pm8001_phy ==> struct sas_phy * in pm8001_phy_control(): libsas data ==> struct pm8001_phy For negotiated linkrate, the current dataflow is: * in pm8001_get_lrate_mode(): iomb data ==> struct asd_sas_phy ==> struct sas_phy * in pm8001_bytes_dmaed(): struct asd_sas_phy ==> struct sas_phy Since pm8001_bytes_dmaed() follows pm8001_get_lrate_mode(), the assignment statements in pm8001_bytes_dmaed() are unnecessary and cleaned up. Link: https://lore.kernel.org/r/20220707175210.528858-1-changyuanl@google.com Reviewed-by: Igor Pylypiv <ipylypiv@google.com> Acked-by: Jack Wang <jinpu.wang@ionos.com> Signed-off-by: Changyuan Lyu <changyuanl@google.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 52a5180 commit e78276c

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,15 +3145,6 @@ void pm8001_bytes_dmaed(struct pm8001_hba_info *pm8001_ha, int i)
31453145
if (!phy->phy_attached)
31463146
return;
31473147

3148-
if (sas_phy->phy) {
3149-
struct sas_phy *sphy = sas_phy->phy;
3150-
sphy->negotiated_linkrate = sas_phy->linkrate;
3151-
sphy->minimum_linkrate = phy->minimum_linkrate;
3152-
sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
3153-
sphy->maximum_linkrate = phy->maximum_linkrate;
3154-
sphy->maximum_linkrate_hw = phy->maximum_linkrate;
3155-
}
3156-
31573148
if (phy->phy_type & PORT_TYPE_SAS) {
31583149
struct sas_identify_frame *id;
31593150
id = (struct sas_identify_frame *)phy->frame_rcvd;
@@ -3177,26 +3168,22 @@ void pm8001_get_lrate_mode(struct pm8001_phy *phy, u8 link_rate)
31773168
switch (link_rate) {
31783169
case PHY_SPEED_120:
31793170
phy->sas_phy.linkrate = SAS_LINK_RATE_12_0_GBPS;
3180-
phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_12_0_GBPS;
31813171
break;
31823172
case PHY_SPEED_60:
31833173
phy->sas_phy.linkrate = SAS_LINK_RATE_6_0_GBPS;
3184-
phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_6_0_GBPS;
31853174
break;
31863175
case PHY_SPEED_30:
31873176
phy->sas_phy.linkrate = SAS_LINK_RATE_3_0_GBPS;
3188-
phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS;
31893177
break;
31903178
case PHY_SPEED_15:
31913179
phy->sas_phy.linkrate = SAS_LINK_RATE_1_5_GBPS;
3192-
phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS;
31933180
break;
31943181
}
31953182
sas_phy->negotiated_linkrate = phy->sas_phy.linkrate;
3196-
sas_phy->maximum_linkrate_hw = SAS_LINK_RATE_6_0_GBPS;
3183+
sas_phy->maximum_linkrate_hw = phy->maximum_linkrate;
31973184
sas_phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
3198-
sas_phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS;
3199-
sas_phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
3185+
sas_phy->maximum_linkrate = phy->maximum_linkrate;
3186+
sas_phy->minimum_linkrate = phy->minimum_linkrate;
32003187
}
32013188

32023189
/**

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id)
143143
struct asd_sas_phy *sas_phy = &phy->sas_phy;
144144
phy->phy_state = PHY_LINK_DISABLE;
145145
phy->pm8001_ha = pm8001_ha;
146+
phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
147+
phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS;
146148
sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0;
147149
sas_phy->class = SAS;
148150
sas_phy->iproto = SAS_PROTOCOL_ALL;

0 commit comments

Comments
 (0)