Commit 36ed2da7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 6c3f5bec d5d92b64
Loading
Loading
Loading
Loading
+7 −12
Original line number Original line Diff line number Diff line
@@ -1254,6 +1254,13 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
	struct utp_hpb_rsp *rsp_field = &lrbp->ucd_rsp_ptr->hr;
	struct utp_hpb_rsp *rsp_field = &lrbp->ucd_rsp_ptr->hr;
	int data_seg_len;
	int data_seg_len;


	data_seg_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2)
		& MASK_RSP_UPIU_DATA_SEG_LEN;

	/* If data segment length is zero, rsp_field is not valid */
	if (!data_seg_len)
		return;

	if (unlikely(lrbp->lun != rsp_field->lun)) {
	if (unlikely(lrbp->lun != rsp_field->lun)) {
		struct scsi_device *sdev;
		struct scsi_device *sdev;
		bool found = false;
		bool found = false;
@@ -1288,18 +1295,6 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
		return;
		return;
	}
	}


	data_seg_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2)
		& MASK_RSP_UPIU_DATA_SEG_LEN;

	/* To flush remained rsp_list, we queue the map_work task */
	if (!data_seg_len) {
		if (!ufshpb_is_general_lun(hpb->lun))
			return;

		ufshpb_kick_map_work(hpb);
		return;
	}

	BUILD_BUG_ON(sizeof(struct utp_hpb_rsp) != UTP_HPB_RSP_SIZE);
	BUILD_BUG_ON(sizeof(struct utp_hpb_rsp) != UTP_HPB_RSP_SIZE);


	if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))
	if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))
+22 −10
Original line number Original line Diff line number Diff line
@@ -3596,10 +3596,7 @@ static int iscsit_send_reject(
void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
{
{
	int ord, cpu;
	int ord, cpu;
	cpumask_t conn_allowed_cpumask;
	cpumask_var_t conn_allowed_cpumask;

	cpumask_and(&conn_allowed_cpumask, iscsit_global->allowed_cpumask,
		    cpu_online_mask);


	/*
	/*
	 * bitmap_id is assigned from iscsit_global->ts_bitmap from
	 * bitmap_id is assigned from iscsit_global->ts_bitmap from
@@ -3609,14 +3606,29 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
	 * iSCSI connection's RX/TX threads will be scheduled to
	 * iSCSI connection's RX/TX threads will be scheduled to
	 * execute upon.
	 * execute upon.
	 */
	 */
	if (!zalloc_cpumask_var(&conn_allowed_cpumask, GFP_KERNEL)) {
		ord = conn->bitmap_id % cpumask_weight(cpu_online_mask);
		for_each_online_cpu(cpu) {
			if (ord-- == 0) {
				cpumask_set_cpu(cpu, conn->conn_cpumask);
				return;
			}
		}
	} else {
		cpumask_and(conn_allowed_cpumask, iscsit_global->allowed_cpumask,
			cpu_online_mask);

		cpumask_clear(conn->conn_cpumask);
		cpumask_clear(conn->conn_cpumask);
	ord = conn->bitmap_id % cpumask_weight(&conn_allowed_cpumask);
		ord = conn->bitmap_id % cpumask_weight(conn_allowed_cpumask);
	for_each_cpu(cpu, &conn_allowed_cpumask) {
		for_each_cpu(cpu, conn_allowed_cpumask) {
			if (ord-- == 0) {
			if (ord-- == 0) {
				cpumask_set_cpu(cpu, conn->conn_cpumask);
				cpumask_set_cpu(cpu, conn->conn_cpumask);
				free_cpumask_var(conn_allowed_cpumask);
				return;
				return;
			}
			}
		}
		}
		free_cpumask_var(conn_allowed_cpumask);
	}
	/*
	/*
	 * This should never be reached..
	 * This should never be reached..
	 */
	 */
+14 −10
Original line number Original line Diff line number Diff line
@@ -1137,23 +1137,27 @@ static ssize_t lio_target_wwn_cpus_allowed_list_show(
static ssize_t lio_target_wwn_cpus_allowed_list_store(
static ssize_t lio_target_wwn_cpus_allowed_list_store(
		struct config_item *item, const char *page, size_t count)
		struct config_item *item, const char *page, size_t count)
{
{
	int ret;
	int ret = -ENOMEM;
	char *orig;
	char *orig;
	cpumask_t new_allowed_cpumask;
	cpumask_var_t new_allowed_cpumask;

	if (!zalloc_cpumask_var(&new_allowed_cpumask, GFP_KERNEL))
		goto out;


	orig = kstrdup(page, GFP_KERNEL);
	orig = kstrdup(page, GFP_KERNEL);
	if (!orig)
	if (!orig)
		return -ENOMEM;
		goto out_free_cpumask;


	cpumask_clear(&new_allowed_cpumask);
	ret = cpulist_parse(orig, new_allowed_cpumask);
	ret = cpulist_parse(orig, &new_allowed_cpumask);
	if (!ret)
		cpumask_copy(iscsit_global->allowed_cpumask,
			     new_allowed_cpumask);


	kfree(orig);
	kfree(orig);
	if (ret != 0)
out_free_cpumask:
		return ret;
	free_cpumask_var(new_allowed_cpumask);

out:
	cpumask_copy(iscsit_global->allowed_cpumask, &new_allowed_cpumask);
	return ret ? ret : count;
	return count;
}
}


CONFIGFS_ATTR(lio_target_wwn_, cpus_allowed_list);
CONFIGFS_ATTR(lio_target_wwn_, cpus_allowed_list);