Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d758ed5 authored by Subhash Jadavani's avatar Subhash Jadavani Committed by Can Guo
Browse files

scsi: squash of multiple fixes for msm-4.4 kernel



This change is the squash of following commits from msm-4.4 kernel:

<36c183b7> ("scsi: Adjust DBD setting in mode sense for caching mode page per LLD")
<d2e7a77a> ("scsi: sd: reduce log level for suspend/resume log messages")
<c6b82e8b> ("scsi: Allow auto suspend override by low-level driver")
<edf4a84a> ("scsi: pm: fix null pointer access during sg_open")
<d8a84438> ("scsi: pm: fix deadlock condition")
<2b80aee4> ("scsi: pm: keep request queue and scsi device runtime status in sync")
<628aaf1b> ("scsi: reduce the informational log messages during initial probe")
<fe64842c> ("scsi: sd: remove check_events callback")
<2f82ca7b> ("scsi: pm: Remove use of CONFIG_PM_RUNTIME")

Change-Id: Ia8430f5c42dd66dbb044733eaa30d0ccd097b3c9
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
[cang@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
parent 2151255d
Loading
Loading
Loading
Loading
+40 −2
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

#include "scsi_priv.h"

static int do_scsi_runtime_resume(struct device *dev,
				   const struct dev_pm_ops *pm);

#ifdef CONFIG_PM_SLEEP

static int do_scsi_suspend(struct device *dev, const struct dev_pm_ops *pm)
@@ -77,10 +80,22 @@ static int scsi_dev_type_resume(struct device *dev,
	scsi_device_resume(to_scsi_device(dev));
	dev_dbg(dev, "scsi resume: %d\n", err);

	if (err == 0) {
	if (err == 0 && (cb != do_scsi_runtime_resume)) {
		pm_runtime_disable(dev);
		pm_runtime_set_active(dev);
		err = pm_runtime_set_active(dev);
		pm_runtime_enable(dev);

		if (!err && scsi_is_sdev_device(dev)) {
			struct scsi_device *sdev = to_scsi_device(dev);

			/*
			 * If scsi device runtime PM is managed by block layer
			 * then we should update request queue's runtime status
			 * as well.
			 */
			if (sdev->request_queue->dev)
				blk_post_runtime_resume(sdev->request_queue, 0);
		}
	}

	return err;
@@ -223,12 +238,32 @@ static int scsi_bus_restore(struct device *dev)

#endif /* CONFIG_PM_SLEEP */

static int do_scsi_runtime_suspend(struct device *dev,
				   const struct dev_pm_ops *pm)
{
	return pm && pm->runtime_suspend ? pm->runtime_suspend(dev) : 0;
}

static int do_scsi_runtime_resume(struct device *dev,
				   const struct dev_pm_ops *pm)
{
	return pm && pm->runtime_resume ? pm->runtime_resume(dev) : 0;
}

static int sdev_runtime_suspend(struct device *dev)
{
	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
	struct scsi_device *sdev = to_scsi_device(dev);
	int err = 0;

	if (!sdev->request_queue->dev) {
		err = scsi_dev_type_suspend(dev, do_scsi_runtime_suspend);
		if (err == -EAGAIN)
			pm_schedule_suspend(dev, jiffies_to_msecs(
					round_jiffies_up_relative(HZ/10)));
		return err;
	}

	err = blk_pre_runtime_suspend(sdev->request_queue);
	if (err)
		return err;
@@ -258,6 +293,9 @@ static int sdev_runtime_resume(struct device *dev)
	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
	int err = 0;

	if (!sdev->request_queue->dev)
		return scsi_dev_type_resume(dev, do_scsi_runtime_resume);

	blk_pre_runtime_resume(sdev->request_queue);
	if (pm && pm->runtime_resume)
		err = pm->runtime_resume(dev);
+5 −6
Original line number Diff line number Diff line
@@ -825,15 +825,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
		 * well-known logical units. Force well-known type
		 * to enumerate them correctly.
		 */
		if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN) {
			sdev_printk(KERN_WARNING, sdev,
				"%s: correcting incorrect peripheral device type 0x%x for W-LUN 0x%16xhN\n",
				__func__, sdev->type, (unsigned int)sdev->lun);
		if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN)
			sdev->type = TYPE_WLUN;
	}

	}

	if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
		/* RBC and MMC devices can return SCSI-3 compliance and yet
		 * still not support REPORT LUNS, so make them act as
@@ -965,6 +960,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,

	transport_configure_device(&sdev->sdev_gendev);

	/* The LLD can override auto suspend tunables in ->slave_configure() */
	sdev->use_rpm_auto = 0;
	sdev->autosuspend_delay = SCSI_DEFAULT_AUTOSUSPEND_DELAY;

	if (sdev->host->hostt->slave_configure) {
		ret = sdev->host->hostt->slave_configure(sdev);
		if (ret) {
+2 −1
Original line number Diff line number Diff line
@@ -1215,6 +1215,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
	device_enable_async_suspend(&sdev->sdev_gendev);
	scsi_autopm_get_target(starget);
	pm_runtime_set_active(&sdev->sdev_gendev);
	if (!sdev->use_rpm_auto)
		pm_runtime_forbid(&sdev->sdev_gendev);
	pm_runtime_enable(&sdev->sdev_gendev);
	scsi_autopm_put_target(starget);
+10 −108
Original line number Diff line number Diff line
@@ -1516,83 +1516,6 @@ static int media_not_present(struct scsi_disk *sdkp,
	return 0;
}

/**
 *	sd_check_events - check media events
 *	@disk: kernel device descriptor
 *	@clearing: disk events currently being cleared
 *
 *	Returns mask of DISK_EVENT_*.
 *
 *	Note: this function is invoked from the block subsystem.
 **/
static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
{
	struct scsi_disk *sdkp = scsi_disk_get(disk);
	struct scsi_device *sdp;
	int retval;

	if (!sdkp)
		return 0;

	sdp = sdkp->device;
	SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n"));

	/*
	 * If the device is offline, don't send any commands - just pretend as
	 * if the command failed.  If the device ever comes back online, we
	 * can deal with it then.  It is only because of unrecoverable errors
	 * that we would ever take a device offline in the first place.
	 */
	if (!scsi_device_online(sdp)) {
		set_media_not_present(sdkp);
		goto out;
	}

	/*
	 * Using TEST_UNIT_READY enables differentiation between drive with
	 * no cartridge loaded - NOT READY, drive with changed cartridge -
	 * UNIT ATTENTION, or with same cartridge - GOOD STATUS.
	 *
	 * Drives that auto spin down. eg iomega jaz 1G, will be started
	 * by sd_spinup_disk() from sd_revalidate_disk(), which happens whenever
	 * sd_revalidate() is called.
	 */
	if (scsi_block_when_processing_errors(sdp)) {
		struct scsi_sense_hdr sshdr = { 0, };

		retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES,
					      &sshdr);

		/* failed to execute TUR, assume media not present */
		if (host_byte(retval)) {
			set_media_not_present(sdkp);
			goto out;
		}

		if (media_not_present(sdkp, &sshdr))
			goto out;
	}

	/*
	 * For removable scsi disk we have to recognise the presence
	 * of a disk in the drive.
	 */
	if (!sdkp->media_present)
		sdp->changed = 1;
	sdkp->media_present = 1;
out:
	/*
	 * sdp->changed is set under the following conditions:
	 *
	 *	Medium present state has changed in either direction.
	 *	Device has indicated UNIT_ATTENTION.
	 */
	retval = sdp->changed ? DISK_EVENT_MEDIA_CHANGE : 0;
	sdp->changed = 0;
	scsi_disk_put(sdkp);
	return retval;
}

static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
{
	int retries, res;
@@ -1788,7 +1711,6 @@ static const struct block_device_operations sd_fops = {
#ifdef CONFIG_COMPAT
	.compat_ioctl		= sd_compat_ioctl,
#endif
	.check_events		= sd_check_events,
	.revalidate_disk	= sd_revalidate_disk,
	.unlock_native_capacity	= sd_unlock_native_capacity,
	.pr_ops			= &sd_pr_ops,
@@ -2550,11 +2472,6 @@ sd_print_capacity(struct scsi_disk *sdkp,
			sizeof(cap_str_10));

	if (sdkp->first_scan || old_capacity != sdkp->capacity) {
		sd_printk(KERN_NOTICE, sdkp,
			  "%llu %d-byte logical blocks: (%s/%s)\n",
			  (unsigned long long)sdkp->capacity,
			  sector_size, cap_str_10, cap_str_2);

		if (sdkp->physical_block_size != sector_size)
			sd_printk(KERN_NOTICE, sdkp,
				  "%u-byte physical blocks\n",
@@ -2585,7 +2502,6 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
	int res;
	struct scsi_device *sdp = sdkp->device;
	struct scsi_mode_data data;
	int old_wp = sdkp->write_prot;

	set_disk_ro(sdkp->disk, 0);
	if (sdp->skip_ms_page_3f) {
@@ -2626,11 +2542,6 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
	} else {
		sdkp->write_prot = ((data.device_specific & 0x80) != 0);
		set_disk_ro(sdkp->disk, sdkp->write_prot);
		if (sdkp->first_scan || old_wp != sdkp->write_prot) {
			sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
				  sdkp->write_prot ? "on" : "off");
			sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", buffer);
		}
	}
}

@@ -2643,16 +2554,13 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
{
	int len = 0, res;
	struct scsi_device *sdp = sdkp->device;
	struct Scsi_Host *host = sdp->host;

	int dbd;
	int modepage;
	int first_len;
	struct scsi_mode_data data;
	struct scsi_sense_hdr sshdr;
	int old_wce = sdkp->WCE;
	int old_rcd = sdkp->RCD;
	int old_dpofua = sdkp->DPOFUA;


	if (sdkp->cache_override)
		return;
@@ -2674,6 +2582,9 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
		dbd = 8;
	} else {
		modepage = 8;
		if (host->set_dbd_for_caching)
			dbd = 8;
		else
			dbd = 0;
	}

@@ -2775,15 +2686,6 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
		if (sdkp->WCE && sdkp->write_prot)
			sdkp->WCE = 0;

		if (sdkp->first_scan || old_wce != sdkp->WCE ||
		    old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA)
			sd_printk(KERN_NOTICE, sdkp,
				  "Write cache: %s, read cache: %s, %s\n",
				  sdkp->WCE ? "enabled" : "disabled",
				  sdkp->RCD ? "disabled" : "enabled",
				  sdkp->DPOFUA ? "supports DPO and FUA"
				  : "doesn't support DPO or FUA");

		return;
	}

@@ -3250,6 +3152,9 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
	}

	blk_pm_runtime_init(sdp->request_queue, dev);
	if (sdp->autosuspend_delay >= 0)
		pm_runtime_set_autosuspend_delay(dev, sdp->autosuspend_delay);

	device_add_disk(dev, gd);
	if (sdkp->capacity)
		sd_dif_config_host(sdkp);
@@ -3262,8 +3167,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
			sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
	}

	sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
		  sdp->removable ? "removable " : "");
	scsi_autopm_put_device(sdp);
	put_device(&sdkp->dev);
}
@@ -3520,7 +3423,6 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
		return 0;

	if (sdkp->WCE && sdkp->media_present) {
		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
		ret = sd_sync_cache(sdkp, &sshdr);

		if (ret) {
@@ -3542,7 +3444,7 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
	}

	if (sdkp->device->manage_start_stop) {
		sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
		sd_printk(KERN_DEBUG, sdkp, "Stopping disk\n");
		/* an error is not worth aborting a system sleep */
		ret = sd_start_stop_device(sdkp, 0);
		if (ignore_stop_errors)
@@ -3573,7 +3475,7 @@ static int sd_resume(struct device *dev)
	if (!sdkp->device->manage_start_stop)
		return 0;

	sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
	sd_printk(KERN_DEBUG, sdkp, "Starting disk\n");
	ret = sd_start_stop_device(sdkp, 1);
	if (!ret)
		opal_unlock_from_suspend(sdkp->opal_dev);
+0 −3
Original line number Diff line number Diff line
@@ -1540,9 +1540,6 @@ sg_add_device(struct device *cl_dev, struct class_interface *cl_intf)
	} else
		pr_warn("%s: sg_sys Invalid\n", __func__);

	sdev_printk(KERN_NOTICE, scsidp, "Attached scsi generic sg%d "
		    "type %d\n", sdp->index, scsidp->type);

	dev_set_drvdata(cl_dev, sdp);

	return 0;
Loading