Skip to content

Commit e54f7b4

Browse files
Merge branch 6.18/scsi-fixes into 6.19/scsi-staging
Pull in fixes branch to resolve UFS merge conflict. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 parents 13b77ed + a2b32bc commit e54f7b4

14 files changed

Lines changed: 177 additions & 94 deletions

File tree

Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ properties:
2424
- enum:
2525
- qcom,qcs8300-qmp-ufs-phy
2626
- const: qcom,sa8775p-qmp-ufs-phy
27+
- items:
28+
- enum:
29+
- qcom,kaanapali-qmp-ufs-phy
30+
- const: qcom,sm8750-qmp-ufs-phy
2731
- enum:
2832
- qcom,msm8996-qmp-ufs-phy
2933
- qcom,msm8998-qmp-ufs-phy

Documentation/devicetree/bindings/ufs/qcom,sm8650-ufshc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ select:
1515
compatible:
1616
contains:
1717
enum:
18+
- qcom,kaanapali-ufshc
1819
- qcom,sm8650-ufshc
1920
- qcom,sm8750-ufshc
2021
required:
@@ -24,6 +25,7 @@ properties:
2425
compatible:
2526
items:
2627
- enum:
28+
- qcom,kaanapali-ufshc
2729
- qcom,sm8650-ufshc
2830
- qcom,sm8750-ufshc
2931
- const: qcom,ufshc

drivers/scsi/hosts.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,9 @@ int scsi_host_busy(struct Scsi_Host *shost)
626626
{
627627
int cnt = 0;
628628

629-
blk_mq_tagset_busy_iter(&shost->tag_set,
630-
scsi_host_check_in_flight, &cnt);
629+
if (shost->tag_set.ops)
630+
blk_mq_tagset_busy_iter(&shost->tag_set,
631+
scsi_host_check_in_flight, &cnt);
631632
return cnt;
632633
}
633634
EXPORT_SYMBOL(scsi_host_busy);

drivers/scsi/libfc/fc_fcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
503503
host_bcode = FC_ERROR;
504504
goto err;
505505
}
506-
if (offset + len > fsp->data_len) {
506+
if (size_add(offset, len) > fsp->data_len) {
507507
/* this should never happen */
508508
if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) &&
509509
fc_frame_crc_check(fp))

drivers/scsi/qla4xxx/ql4_os.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,7 +4104,7 @@ void qla4xxx_srb_compl(struct kref *ref)
41044104
* The mid-level driver tries to ensure that queuecommand never gets
41054105
* invoked concurrently with itself or the interrupt handler (although
41064106
* the interrupt handler may call this routine as part of request-
4107-
* completion handling). Unfortunely, it sometimes calls the scheduler
4107+
* completion handling). Unfortunately, it sometimes calls the scheduler
41084108
* in interrupt context which is a big NO! NO!.
41094109
**/
41104110
static int qla4xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
@@ -4647,7 +4647,7 @@ static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
46474647
cmd = scsi_host_find_tag(ha->host, index);
46484648
/*
46494649
* We cannot just check if the index is valid,
4650-
* becase if we are run from the scsi eh, then
4650+
* because if we are run from the scsi eh, then
46514651
* the scsi/block layer is going to prevent
46524652
* the tag from being released.
46534653
*/
@@ -4952,7 +4952,7 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha)
49524952
/* Upon successful firmware/chip reset, re-initialize the adapter */
49534953
if (status == QLA_SUCCESS) {
49544954
/* For ISP-4xxx, force function 1 to always initialize
4955-
* before function 3 to prevent both funcions from
4955+
* before function 3 to prevent both functions from
49564956
* stepping on top of the other */
49574957
if (is_qla40XX(ha) && (ha->mac_index == 3))
49584958
ssleep(6);
@@ -6914,7 +6914,7 @@ static int qla4xxx_sess_conn_setup(struct scsi_qla_host *ha,
69146914
struct ddb_entry *ddb_entry = NULL;
69156915

69166916
/* Create session object, with INVALID_ENTRY,
6917-
* the targer_id would get set when we issue the login
6917+
* the target_id would get set when we issue the login
69186918
*/
69196919
cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, ha->host,
69206920
cmds_max, sizeof(struct ddb_entry),

drivers/scsi/scsi_error.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,9 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
554554
* happened, even if someone else gets the sense data.
555555
*/
556556
if (sshdr.asc == 0x28)
557-
scmd->device->ua_new_media_ctr++;
557+
atomic_inc(&sdev->ua_new_media_ctr);
558558
else if (sshdr.asc == 0x29)
559-
scmd->device->ua_por_ctr++;
559+
atomic_inc(&sdev->ua_por_ctr);
560560
}
561561

562562
if (scsi_sense_is_deferred(&sshdr))

drivers/scsi/storvsc_drv.c

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,14 +1406,19 @@ static struct vmbus_channel *get_og_chn(struct storvsc_device *stor_device,
14061406
}
14071407

14081408
/*
1409-
* Our channel array is sparsley populated and we
1409+
* Our channel array could be sparsley populated and we
14101410
* initiated I/O on a processor/hw-q that does not
14111411
* currently have a designated channel. Fix this.
14121412
* The strategy is simple:
1413-
* I. Ensure NUMA locality
1414-
* II. Distribute evenly (best effort)
1413+
* I. Prefer the channel associated with the current CPU
1414+
* II. Ensure NUMA locality
1415+
* III. Distribute evenly (best effort)
14151416
*/
14161417

1418+
/* Prefer the channel on the I/O issuing processor/hw-q */
1419+
if (cpumask_test_cpu(q_num, &stor_device->alloced_cpus))
1420+
return stor_device->stor_chns[q_num];
1421+
14171422
node_mask = cpumask_of_node(cpu_to_node(q_num));
14181423

14191424
num_channels = 0;
@@ -1469,59 +1474,48 @@ static int storvsc_do_io(struct hv_device *device,
14691474
/* See storvsc_change_target_cpu(). */
14701475
outgoing_channel = READ_ONCE(stor_device->stor_chns[q_num]);
14711476
if (outgoing_channel != NULL) {
1472-
if (outgoing_channel->target_cpu == q_num) {
1473-
/*
1474-
* Ideally, we want to pick a different channel if
1475-
* available on the same NUMA node.
1476-
*/
1477-
node_mask = cpumask_of_node(cpu_to_node(q_num));
1478-
for_each_cpu_wrap(tgt_cpu,
1479-
&stor_device->alloced_cpus, q_num + 1) {
1480-
if (!cpumask_test_cpu(tgt_cpu, node_mask))
1481-
continue;
1482-
if (tgt_cpu == q_num)
1483-
continue;
1484-
channel = READ_ONCE(
1485-
stor_device->stor_chns[tgt_cpu]);
1486-
if (channel == NULL)
1487-
continue;
1488-
if (hv_get_avail_to_write_percent(
1489-
&channel->outbound)
1490-
> ring_avail_percent_lowater) {
1491-
outgoing_channel = channel;
1492-
goto found_channel;
1493-
}
1494-
}
1477+
if (hv_get_avail_to_write_percent(&outgoing_channel->outbound)
1478+
> ring_avail_percent_lowater)
1479+
goto found_channel;
14951480

1496-
/*
1497-
* All the other channels on the same NUMA node are
1498-
* busy. Try to use the channel on the current CPU
1499-
*/
1500-
if (hv_get_avail_to_write_percent(
1501-
&outgoing_channel->outbound)
1502-
> ring_avail_percent_lowater)
1481+
/*
1482+
* Channel is busy, try to find a channel on the same NUMA node
1483+
*/
1484+
node_mask = cpumask_of_node(cpu_to_node(q_num));
1485+
for_each_cpu_wrap(tgt_cpu, &stor_device->alloced_cpus,
1486+
q_num + 1) {
1487+
if (!cpumask_test_cpu(tgt_cpu, node_mask))
1488+
continue;
1489+
channel = READ_ONCE(stor_device->stor_chns[tgt_cpu]);
1490+
if (!channel)
1491+
continue;
1492+
if (hv_get_avail_to_write_percent(&channel->outbound)
1493+
> ring_avail_percent_lowater) {
1494+
outgoing_channel = channel;
15031495
goto found_channel;
1496+
}
1497+
}
15041498

1505-
/*
1506-
* If we reach here, all the channels on the current
1507-
* NUMA node are busy. Try to find a channel in
1508-
* other NUMA nodes
1509-
*/
1510-
for_each_cpu(tgt_cpu, &stor_device->alloced_cpus) {
1511-
if (cpumask_test_cpu(tgt_cpu, node_mask))
1512-
continue;
1513-
channel = READ_ONCE(
1514-
stor_device->stor_chns[tgt_cpu]);
1515-
if (channel == NULL)
1516-
continue;
1517-
if (hv_get_avail_to_write_percent(
1518-
&channel->outbound)
1519-
> ring_avail_percent_lowater) {
1520-
outgoing_channel = channel;
1521-
goto found_channel;
1522-
}
1499+
/*
1500+
* If we reach here, all the channels on the current
1501+
* NUMA node are busy. Try to find a channel in
1502+
* all NUMA nodes
1503+
*/
1504+
for_each_cpu_wrap(tgt_cpu, &stor_device->alloced_cpus,
1505+
q_num + 1) {
1506+
channel = READ_ONCE(stor_device->stor_chns[tgt_cpu]);
1507+
if (!channel)
1508+
continue;
1509+
if (hv_get_avail_to_write_percent(&channel->outbound)
1510+
> ring_avail_percent_lowater) {
1511+
outgoing_channel = channel;
1512+
goto found_channel;
15231513
}
15241514
}
1515+
/*
1516+
* If we reach here, all the channels are busy. Use the
1517+
* original channel found.
1518+
*/
15251519
} else {
15261520
spin_lock_irqsave(&stor_device->lock, flags);
15271521
outgoing_channel = stor_device->stor_chns[q_num];

drivers/ufs/core/ufs-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ static umode_t ufs_sysfs_hid_is_visible(struct kobject *kobj,
19501950
return hba->dev_info.hid_sup ? attr->mode : 0;
19511951
}
19521952

1953-
const struct attribute_group ufs_sysfs_hid_group = {
1953+
static const struct attribute_group ufs_sysfs_hid_group = {
19541954
.name = "hid",
19551955
.attrs = ufs_sysfs_hid,
19561956
.is_visible = ufs_sysfs_hid_is_visible,

drivers/ufs/core/ufs-sysfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ void ufs_sysfs_remove_nodes(struct device *dev);
1414

1515
extern const struct attribute_group ufs_sysfs_unit_descriptor_group;
1616
extern const struct attribute_group ufs_sysfs_lun_attributes_group;
17-
extern const struct attribute_group ufs_sysfs_hid_group;
1817

1918
#endif

drivers/ufs/core/ufshcd.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,8 +4269,8 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
42694269
get, UIC_GET_ATTR_ID(attr_sel),
42704270
UFS_UIC_COMMAND_RETRIES - retries);
42714271

4272-
if (mib_val && !ret)
4273-
*mib_val = uic_cmd.argument3;
4272+
if (mib_val)
4273+
*mib_val = ret == 0 ? uic_cmd.argument3 : 0;
42744274

42754275
if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)
42764276
&& pwr_mode_change)
@@ -4986,7 +4986,7 @@ EXPORT_SYMBOL_GPL(ufshcd_hba_enable);
49864986

49874987
static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
49884988
{
4989-
int tx_lanes = 0, i, err = 0;
4989+
int tx_lanes, i, err = 0;
49904990

49914991
if (!peer)
49924992
ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
@@ -5053,7 +5053,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
50535053
* If UFS device isn't active then we will have to issue link startup
50545054
* 2 times to make sure the device state move to active.
50555055
*/
5056-
if (!ufshcd_is_ufs_dev_active(hba))
5056+
if (!(hba->quirks & UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE) &&
5057+
!ufshcd_is_ufs_dev_active(hba))
50575058
link_startup_again = true;
50585059

50595060
link_startup:
@@ -5118,12 +5119,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
51185119
ufshcd_readl(hba, REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER);
51195120
ret = ufshcd_make_hba_operational(hba);
51205121
out:
5121-
if (ret) {
5122+
if (ret)
51225123
dev_err(hba->dev, "link startup failed %d\n", ret);
5123-
ufshcd_print_host_state(hba);
5124-
ufshcd_print_pwr_info(hba);
5125-
ufshcd_print_evt_hist(hba);
5126-
}
51275124
return ret;
51285125
}
51295126

@@ -6679,6 +6676,20 @@ static void ufshcd_err_handler(struct work_struct *work)
66796676
hba->saved_uic_err, hba->force_reset,
66806677
ufshcd_is_link_broken(hba) ? "; link is broken" : "");
66816678

6679+
/*
6680+
* Use ufshcd_rpm_get_noresume() here to safely perform link recovery
6681+
* even if an error occurs during runtime suspend or runtime resume.
6682+
* This avoids potential deadlocks that could happen if we tried to
6683+
* resume the device while a PM operation is already in progress.
6684+
*/
6685+
ufshcd_rpm_get_noresume(hba);
6686+
if (hba->pm_op_in_progress) {
6687+
ufshcd_link_recovery(hba);
6688+
ufshcd_rpm_put(hba);
6689+
return;
6690+
}
6691+
ufshcd_rpm_put(hba);
6692+
66826693
down(&hba->host_sem);
66836694
spin_lock_irqsave(hba->host->host_lock, flags);
66846695
if (ufshcd_err_handling_should_stop(hba)) {
@@ -6690,14 +6701,6 @@ static void ufshcd_err_handler(struct work_struct *work)
66906701
}
66916702
spin_unlock_irqrestore(hba->host->host_lock, flags);
66926703

6693-
ufshcd_rpm_get_noresume(hba);
6694-
if (hba->pm_op_in_progress) {
6695-
ufshcd_link_recovery(hba);
6696-
ufshcd_rpm_put(hba);
6697-
return;
6698-
}
6699-
ufshcd_rpm_put(hba);
6700-
67016704
ufshcd_err_handling_prepare(hba);
67026705

67036706
spin_lock_irqsave(hba->host->host_lock, flags);
@@ -8538,8 +8541,6 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
85388541
DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) &
85398542
UFS_DEV_HID_SUPPORT;
85408543

8541-
sysfs_update_group(&hba->dev->kobj, &ufs_sysfs_hid_group);
8542-
85438544
model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME];
85448545

85458546
err = ufshcd_read_string_desc(hba, model_index,
@@ -10700,7 +10701,7 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
1070010701
* @mmio_base: base register address
1070110702
* @irq: Interrupt line of device
1070210703
*
10703-
* Return: 0 on success, non-zero value on failure.
10704+
* Return: 0 on success; < 0 on failure.
1070410705
*/
1070510706
int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1070610707
{
@@ -10939,8 +10940,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1093910940
if (err)
1094010941
goto out_disable;
1094110942

10942-
async_schedule(ufshcd_async_scan, hba);
1094310943
ufs_sysfs_add_nodes(hba->dev);
10944+
async_schedule(ufshcd_async_scan, hba);
1094410945

1094510946
device_enable_async_suspend(dev);
1094610947
ufshcd_pm_qos_init(hba);
@@ -10950,7 +10951,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1095010951
hba->is_irq_enabled = false;
1095110952
ufshcd_hba_exit(hba);
1095210953
out_error:
10953-
return err;
10954+
return err > 0 ? -EIO : err;
1095410955
}
1095510956
EXPORT_SYMBOL_GPL(ufshcd_init);
1095610957

0 commit comments

Comments
 (0)