Skip to content

Commit 36ed2da

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Two patches, both in drivers. The iscsi one is fixing the cpumask issue you commented on and the ufs one is a late arriving fix for conditions that can occur in Host Performance Booster reads" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: ufs: core: Fix referencing invalid rsp field scsi: target: Fix incorrect use of cpumask_t
2 parents 6c3f5be + d5d92b6 commit 36ed2da

File tree

3 files changed

+43
-32
lines changed

3 files changed

+43
-32
lines changed

drivers/scsi/ufs/ufshpb.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,13 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
12541254
struct utp_hpb_rsp *rsp_field = &lrbp->ucd_rsp_ptr->hr;
12551255
int data_seg_len;
12561256

1257+
data_seg_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2)
1258+
& MASK_RSP_UPIU_DATA_SEG_LEN;
1259+
1260+
/* If data segment length is zero, rsp_field is not valid */
1261+
if (!data_seg_len)
1262+
return;
1263+
12571264
if (unlikely(lrbp->lun != rsp_field->lun)) {
12581265
struct scsi_device *sdev;
12591266
bool found = false;
@@ -1288,18 +1295,6 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
12881295
return;
12891296
}
12901297

1291-
data_seg_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2)
1292-
& MASK_RSP_UPIU_DATA_SEG_LEN;
1293-
1294-
/* To flush remained rsp_list, we queue the map_work task */
1295-
if (!data_seg_len) {
1296-
if (!ufshpb_is_general_lun(hpb->lun))
1297-
return;
1298-
1299-
ufshpb_kick_map_work(hpb);
1300-
return;
1301-
}
1302-
13031298
BUILD_BUG_ON(sizeof(struct utp_hpb_rsp) != UTP_HPB_RSP_SIZE);
13041299

13051300
if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))

drivers/target/iscsi/iscsi_target.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3596,10 +3596,7 @@ static int iscsit_send_reject(
35963596
void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
35973597
{
35983598
int ord, cpu;
3599-
cpumask_t conn_allowed_cpumask;
3600-
3601-
cpumask_and(&conn_allowed_cpumask, iscsit_global->allowed_cpumask,
3602-
cpu_online_mask);
3599+
cpumask_var_t conn_allowed_cpumask;
36033600

36043601
/*
36053602
* bitmap_id is assigned from iscsit_global->ts_bitmap from
@@ -3609,13 +3606,28 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
36093606
* iSCSI connection's RX/TX threads will be scheduled to
36103607
* execute upon.
36113608
*/
3612-
cpumask_clear(conn->conn_cpumask);
3613-
ord = conn->bitmap_id % cpumask_weight(&conn_allowed_cpumask);
3614-
for_each_cpu(cpu, &conn_allowed_cpumask) {
3615-
if (ord-- == 0) {
3616-
cpumask_set_cpu(cpu, conn->conn_cpumask);
3617-
return;
3609+
if (!zalloc_cpumask_var(&conn_allowed_cpumask, GFP_KERNEL)) {
3610+
ord = conn->bitmap_id % cpumask_weight(cpu_online_mask);
3611+
for_each_online_cpu(cpu) {
3612+
if (ord-- == 0) {
3613+
cpumask_set_cpu(cpu, conn->conn_cpumask);
3614+
return;
3615+
}
3616+
}
3617+
} else {
3618+
cpumask_and(conn_allowed_cpumask, iscsit_global->allowed_cpumask,
3619+
cpu_online_mask);
3620+
3621+
cpumask_clear(conn->conn_cpumask);
3622+
ord = conn->bitmap_id % cpumask_weight(conn_allowed_cpumask);
3623+
for_each_cpu(cpu, conn_allowed_cpumask) {
3624+
if (ord-- == 0) {
3625+
cpumask_set_cpu(cpu, conn->conn_cpumask);
3626+
free_cpumask_var(conn_allowed_cpumask);
3627+
return;
3628+
}
36183629
}
3630+
free_cpumask_var(conn_allowed_cpumask);
36193631
}
36203632
/*
36213633
* This should never be reached..

drivers/target/iscsi/iscsi_target_configfs.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,23 +1137,27 @@ static ssize_t lio_target_wwn_cpus_allowed_list_show(
11371137
static ssize_t lio_target_wwn_cpus_allowed_list_store(
11381138
struct config_item *item, const char *page, size_t count)
11391139
{
1140-
int ret;
1140+
int ret = -ENOMEM;
11411141
char *orig;
1142-
cpumask_t new_allowed_cpumask;
1142+
cpumask_var_t new_allowed_cpumask;
1143+
1144+
if (!zalloc_cpumask_var(&new_allowed_cpumask, GFP_KERNEL))
1145+
goto out;
11431146

11441147
orig = kstrdup(page, GFP_KERNEL);
11451148
if (!orig)
1146-
return -ENOMEM;
1149+
goto out_free_cpumask;
11471150

1148-
cpumask_clear(&new_allowed_cpumask);
1149-
ret = cpulist_parse(orig, &new_allowed_cpumask);
1151+
ret = cpulist_parse(orig, new_allowed_cpumask);
1152+
if (!ret)
1153+
cpumask_copy(iscsit_global->allowed_cpumask,
1154+
new_allowed_cpumask);
11501155

11511156
kfree(orig);
1152-
if (ret != 0)
1153-
return ret;
1154-
1155-
cpumask_copy(iscsit_global->allowed_cpumask, &new_allowed_cpumask);
1156-
return count;
1157+
out_free_cpumask:
1158+
free_cpumask_var(new_allowed_cpumask);
1159+
out:
1160+
return ret ? ret : count;
11571161
}
11581162

11591163
CONFIGFS_ATTR(lio_target_wwn_, cpus_allowed_list);

0 commit comments

Comments
 (0)