Commit a9c9a6f7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull SCSI updates from James Bottomley:
 "This series consists of the usual driver updates (ufs, qla2xxx,
  target, smartpqi, lpfc, mpt3sas).

  The core change causing the most churn was replacing the command
  request field request with a macro, allowing us to offset map to it
  and remove the redundant field; the same was also done for the tag
  field.

  The most impactful change is the final removal of scsi_ioctl, which
  has been deprecated for over a decade"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (293 commits)
  scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
  scsi: ufs: ufs-exynos: Fix static checker warning
  scsi: mpt3sas: Use the proper SCSI midlayer interfaces for PI
  scsi: lpfc: Use the proper SCSI midlayer interfaces for PI
  scsi: lpfc: Copyright updates for 14.0.0.1 patches
  scsi: lpfc: Update lpfc version to 14.0.0.1
  scsi: lpfc: Add bsg support for retrieving adapter cmf data
  scsi: lpfc: Add cmf_info sysfs entry
  scsi: lpfc: Add debugfs support for cm framework buffers
  scsi: lpfc: Add support for maintaining the cm statistics buffer
  scsi: lpfc: Add rx monitoring statistics
  scsi: lpfc: Add support for the CM framework
  scsi: lpfc: Add cmfsync WQE support
  scsi: lpfc: Add support for cm enablement buffer
  scsi: lpfc: Add cm statistics buffer support
  scsi: lpfc: Add EDC ELS support
  scsi: lpfc: Expand FPIN and RDF receive logging
  scsi: lpfc: Add MIB feature enablement support
  scsi: lpfc: Add SET_HOST_DATA mbox cmd to pass date/time info to firmware
  scsi: fc: Add EDC ELS definition
  ...
parents 23852bec 9b5ac8ab
Loading
Loading
Loading
Loading
+236 −0
Original line number Diff line number Diff line
@@ -1298,3 +1298,239 @@ Description: This node is used to set or display whether UFS WriteBooster is
		(if the platform supports UFSHCD_CAP_CLK_SCALING). For a
		platform that doesn't support UFSHCD_CAP_CLK_SCALING, we can
		disable/enable WriteBooster through this sysfs node.

What:		/sys/bus/platform/drivers/ufshcd/*/device_descriptor/hpb_version
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the HPB specification version.
		The full information about the descriptor can be found in the UFS
		HPB (Host Performance Booster) Extension specifications.
		Example: version 1.2.3 = 0123h

		The file is read only.

What:		/sys/bus/platform/drivers/ufshcd/*/device_descriptor/hpb_control
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows an indication of the HPB control mode.
		00h: Host control mode
		01h: Device control mode

		The file is read only.

What:		/sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/hpb_region_size
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the bHPBRegionSize which can be calculated
		as in the following (in bytes):
		HPB Region size = 512B * 2^bHPBRegionSize

		The file is read only.

What:		/sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/hpb_number_lu
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the maximum number of HPB LU supported	by
		the device.
		00h: HPB is not supported by the device.
		01h ~ 20h: Maximum number of HPB LU supported by the device

		The file is read only.

What:		/sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/hpb_subregion_size
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the bHPBSubRegionSize, which can be
		calculated as in the following (in bytes) and shall be a multiple of
		logical block size:
		HPB Sub-Region size = 512B x 2^bHPBSubRegionSize
		bHPBSubRegionSize shall not exceed bHPBRegionSize.

		The file is read only.

What:		/sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/hpb_max_active_regions
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the maximum number of active HPB regions that
		is supported by the device.

		The file is read only.

What:		/sys/class/scsi_device/*/device/unit_descriptor/hpb_lu_max_active_regions
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the maximum number of HPB regions assigned to
		the HPB logical unit.

		The file is read only.

What:		/sys/class/scsi_device/*/device/unit_descriptor/hpb_pinned_region_start_offset
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the start offset of HPB pinned region.

		The file is read only.

What:		/sys/class/scsi_device/*/device/unit_descriptor/hpb_number_pinned_regions
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of HPB pinned regions assigned to
		the HPB logical unit.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_stats/hit_cnt
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of reads that changed to HPB read.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_stats/miss_cnt
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of reads that cannot be changed to
		HPB read.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_stats/rb_noti_cnt
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of response UPIUs that has
		recommendations for activating sub-regions and/or inactivating region.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_stats/rb_active_cnt
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of active sub-regions recommended by
		response UPIUs.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_stats/rb_inactive_cnt
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of inactive regions recommended by
		response UPIUs.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_stats/map_req_cnt
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the number of read buffer commands for
		activating sub-regions recommended by response UPIUs.

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_params/requeue_timeout_ms
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the requeue timeout threshold for write buffer
		command in ms. The value can be changed by writing an integer to
		this entry.

What:		/sys/bus/platform/drivers/ufshcd/*/attributes/max_data_size_hpb_single_cmd
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the maximum HPB data size for using a single HPB
		command.

		===  ========
		00h  4KB
		01h  8KB
		02h  12KB
		...
		FFh  1024KB
		===  ========

		The file is read only.

What:		/sys/bus/platform/drivers/ufshcd/*/flags/hpb_enable
Date:		June 2021
Contact:	Daejun Park <daejun7.park@samsung.com>
Description:	This entry shows the status of HPB.

		== ============================
		0  HPB is not enabled.
		1  HPB is enabled
		== ============================

		The file is read only.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/activation_thld
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	In host control mode, reads are the major source of activation
		trials.  Once this threshold hs met, the region is added to the
		"to-be-activated" list.  Since we reset the read counter upon
		write, this include sending a rb command updating the region
		ppn as well.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/normalization_factor
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	In host control mode, we think of the regions as "buckets".
		Those buckets are being filled with reads, and emptied on write.
		We use entries_per_srgn - the amount of blocks in a subregion as
		our bucket size.  This applies because HPB1.0 only handles
		single-block reads.  Once the bucket size is crossed, we trigger
		a normalization work - not only to avoid overflow, but mainly
		because we want to keep those counters normalized, as we are
		using those reads as a comparative score, to make various decisions.
		The normalization is dividing (shift right) the read counter by
		the normalization_factor. If during consecutive normalizations
		an active region has exhausted its reads - inactivate it.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/eviction_thld_enter
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	Region deactivation is often due to the fact that eviction took
		place: A region becomes active at the expense of another. This is
		happening when the max-active-regions limit has been crossed.
		In host mode, eviction is considered an extreme measure. We
		want to verify that the entering region has enough reads, and
		the exiting region has much fewer reads.  eviction_thld_enter is
		the min reads that a region must have in order to be considered
		a candidate for evicting another region.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/eviction_thld_exit
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	Same as above for the exiting region. A region is considered to
		be a candidate for eviction only if it has fewer reads than
		eviction_thld_exit.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/read_timeout_ms
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	In order not to hang on to "cold" regions, we inactivate
		a region that has no READ access for a predefined amount of
		time - read_timeout_ms. If read_timeout_ms has expired, and the
		region is dirty, it is less likely that we can make any use of
		HPB reading it so we inactivate it.  Still, deactivation has
		its overhead, and we may still benefit from HPB reading this
		region if it is clean - see read_timeout_expiries.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/read_timeout_expiries
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	If the region read timeout has expired, but the region is clean,
		just re-wind its timer for another spin.  Do that as long as it
		is clean and did not exhaust its read_timeout_expiries threshold.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/timeout_polling_interval_ms
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	The frequency with which the delayed worker that checks the
		read_timeouts is awakened.

What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/inflight_map_req
Date:		February 2021
Contact:	Avri Altman <avri.altman@wdc.com>
Description:	In host control mode the host is the originator of map requests.
		To avoid flooding the device with map requests, use a simple throttling
		mechanism that limits the number of inflight map requests.
+3 −23
Original line number Diff line number Diff line
@@ -29,35 +29,15 @@ if BLOCK
config BLK_RQ_ALLOC_TIME
	bool

config BLK_SCSI_REQUEST
	bool

config BLK_CGROUP_RWSTAT
	bool

config BLK_DEV_BSG
	bool "Block layer SG support v4"
	default y
	select BLK_SCSI_REQUEST
	help
	  Saying Y here will enable generic SG (SCSI generic) v4 support
	  for any block device.

	  Unlike SG v3 (aka block/scsi_ioctl.c drivers/scsi/sg.c), SG v4
	  can handle complicated SCSI commands: tagged variable length cdbs
	  with bidirectional data transfers and generic request/response
	  protocols (e.g. Task Management Functions and SMP in Serial
	  Attached SCSI).

	  This option is required by recent UDEV versions to properly
	  access device serial numbers, etc.

	  If unsure, say Y.
config BLK_DEV_BSG_COMMON
	tristate

config BLK_DEV_BSGLIB
	bool "Block layer SG support v4 helper lib"
	select BLK_DEV_BSG
	select BLK_SCSI_REQUEST
	select BLK_DEV_BSG_COMMON
	help
	  Subsystems will normally enable this if needed. Users will not
	  normally need to manually enable this.
+1 −2
Original line number Diff line number Diff line
@@ -12,8 +12,7 @@ obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \
			disk-events.o

obj-$(CONFIG_BOUNCE)		+= bounce.o
obj-$(CONFIG_BLK_SCSI_REQUEST)	+= scsi_ioctl.o
obj-$(CONFIG_BLK_DEV_BSG)	+= bsg.o
obj-$(CONFIG_BLK_DEV_BSG_COMMON) += bsg.o
obj-$(CONFIG_BLK_DEV_BSGLIB)	+= bsg-lib.o
obj-$(CONFIG_BLK_CGROUP)	+= blk-cgroup.o
obj-$(CONFIG_BLK_CGROUP_RWSTAT)	+= blk-cgroup-rwstat.o
+0 −2
Original line number Diff line number Diff line
@@ -3280,8 +3280,6 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
	    set->map[HCTX_TYPE_POLL].nr_queues)
		blk_queue_flag_set(QUEUE_FLAG_POLL, q);

	q->sg_reserved_size = INT_MAX;

	INIT_DELAYED_WORK(&q->requeue_work, blk_mq_requeue_work);
	INIT_LIST_HEAD(&q->requeue_list);
	spin_lock_init(&q->requeue_lock);
+45 −45
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
 *  Copyright (C) 2011   Red Hat, Inc.  All rights reserved.
 *  Copyright (C) 2011   Mike Christie
 */
#include <linux/bsg.h>
#include <linux/slab.h>
#include <linux/blk-mq.h>
#include <linux/delay.h>
@@ -19,36 +20,44 @@

struct bsg_set {
	struct blk_mq_tag_set	tag_set;
	struct bsg_device	*bd;
	bsg_job_fn		*job_fn;
	bsg_timeout_fn		*timeout_fn;
};

static int bsg_transport_check_proto(struct sg_io_v4 *hdr)
static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
		fmode_t mode, unsigned int timeout)
{
	struct bsg_job *job;
	struct request *rq;
	struct bio *bio;
	int ret;

	if (hdr->protocol != BSG_PROTOCOL_SCSI  ||
	    hdr->subprotocol != BSG_SUB_PROTOCOL_SCSI_TRANSPORT)
		return -EINVAL;
	if (!capable(CAP_SYS_RAWIO))
		return -EPERM;
	return 0;
}

static int bsg_transport_fill_hdr(struct request *rq, struct sg_io_v4 *hdr,
		fmode_t mode)
{
	struct bsg_job *job = blk_mq_rq_to_pdu(rq);
	int ret;
	rq = blk_get_request(q, hdr->dout_xfer_len ?
			     REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
	if (IS_ERR(rq))
		return PTR_ERR(rq);
	rq->timeout = timeout;

	job = blk_mq_rq_to_pdu(rq);
	job->request_len = hdr->request_len;
	job->request = memdup_user(uptr64(hdr->request), hdr->request_len);
	if (IS_ERR(job->request))
		return PTR_ERR(job->request);
	if (IS_ERR(job->request)) {
		ret = PTR_ERR(job->request);
		goto out_put_request;
	}

	if (hdr->dout_xfer_len && hdr->din_xfer_len) {
		job->bidi_rq = blk_get_request(rq->q, REQ_OP_DRV_IN, 0);
		if (IS_ERR(job->bidi_rq)) {
			ret = PTR_ERR(job->bidi_rq);
			goto out;
			goto out_free_job_request;
		}

		ret = blk_rq_map_user(rq->q, job->bidi_rq, NULL,
@@ -63,20 +72,20 @@ static int bsg_transport_fill_hdr(struct request *rq, struct sg_io_v4 *hdr,
		job->bidi_bio = NULL;
	}

	return 0;

out_free_bidi_rq:
	if (job->bidi_rq)
		blk_put_request(job->bidi_rq);
out:
	kfree(job->request);
	return ret;
	ret = 0;
	if (hdr->dout_xfer_len) {
		ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->dout_xferp),
				hdr->dout_xfer_len, GFP_KERNEL);
	} else if (hdr->din_xfer_len) {
		ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->din_xferp),
				hdr->din_xfer_len, GFP_KERNEL);
	}

static int bsg_transport_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
{
	struct bsg_job *job = blk_mq_rq_to_pdu(rq);
	int ret = 0;
	if (ret)
		goto out_unmap_bidi_rq;

	bio = rq->bio;
	blk_execute_rq(NULL, rq, !(hdr->flags & BSG_FLAG_Q_AT_TAIL));

	/*
	 * The assignments below don't make much sense, but are kept for
@@ -119,28 +128,20 @@ static int bsg_transport_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
		hdr->din_resid = 0;
	}

	return ret;
}

static void bsg_transport_free_rq(struct request *rq)
{
	struct bsg_job *job = blk_mq_rq_to_pdu(rq);

	if (job->bidi_rq) {
	blk_rq_unmap_user(bio);
out_unmap_bidi_rq:
	if (job->bidi_rq)
		blk_rq_unmap_user(job->bidi_bio);
out_free_bidi_rq:
	if (job->bidi_rq)
		blk_put_request(job->bidi_rq);
	}

out_free_job_request:
	kfree(job->request);
out_put_request:
	blk_put_request(rq);
	return ret;
}

static const struct bsg_ops bsg_transport_ops = {
	.check_proto		= bsg_transport_check_proto,
	.fill_hdr		= bsg_transport_fill_hdr,
	.complete_rq		= bsg_transport_complete_rq,
	.free_rq		= bsg_transport_free_rq,
};

/**
 * bsg_teardown_job - routine to teardown a bsg job
 * @kref: kref inside bsg_job that is to be torn down
@@ -327,7 +328,7 @@ void bsg_remove_queue(struct request_queue *q)
		struct bsg_set *bset =
			container_of(q->tag_set, struct bsg_set, tag_set);

		bsg_unregister_queue(q);
		bsg_unregister_queue(bset->bd);
		blk_cleanup_queue(q);
		blk_mq_free_tag_set(&bset->tag_set);
		kfree(bset);
@@ -396,10 +397,9 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
	q->queuedata = dev;
	blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT);

	ret = bsg_register_queue(q, dev, name, &bsg_transport_ops);
	if (ret) {
		printk(KERN_ERR "%s: bsg interface failed to "
		       "initialize - register queue\n", dev->kobj.name);
	bset->bd = bsg_register_queue(q, dev, name, bsg_transport_sg_io_fn);
	if (IS_ERR(bset->bd)) {
		ret = PTR_ERR(bset->bd);
		goto out_cleanup_queue;
	}

Loading