Unverified Commit 377b75d3 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1107 scsi: hisi_sas: A group of SAS-related bugfixes

Merge Pull Request from: @xia-bing1 
 
This series contain some fixes including:
-Add slave_destroy interface for v3 hw
-Try more retries of START_STOP when resuming scsi device
-Block requests before take debugfs snapshot
-Check usage count only when the runtime PM status is RPM_SUSPENDING 
 
Link:https://gitee.com/openeuler/kernel/pulls/1107

 

Reviewed-by: default avatarYihang Li <liyihang9@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 2c572019 b819b23d
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -2870,7 +2870,8 @@ static int slave_configure_v3_hw(struct scsi_device *sdev)
		return 0;

	if (!device_link_add(&sdev->sdev_gendev, dev,
			     DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)) {
			     DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
			     DL_FLAG_RPM_ACTIVE)) {
		if (pm_runtime_enabled(dev)) {
			dev_info(dev, "add device link failed, disable runtime PM for the host\n");
			pm_runtime_disable(dev);
@@ -2880,6 +2881,15 @@ static int slave_configure_v3_hw(struct scsi_device *sdev)
	return 0;
}

static void slave_destroy_v3_hw(struct scsi_device *sdev)
{
	struct Scsi_Host *shost = dev_to_shost(&sdev->sdev_gendev);
	struct hisi_hba *hisi_hba = shost_priv(shost);
	struct device *dev = hisi_hba->dev;

	device_link_remove(&sdev->sdev_gendev, dev);
}

static struct device_attribute *host_attrs_v3_hw[] = {
	&dev_attr_phy_event_threshold,
	&dev_attr_intr_conv_v3_hw,
@@ -3064,21 +3074,24 @@ static const struct hisi_sas_debugfs_reg debugfs_ras_reg = {

static void debugfs_snapshot_prepare_v3_hw(struct hisi_hba *hisi_hba)
{
	set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);

	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
	struct Scsi_Host *shost = hisi_hba->shost;

	scsi_block_requests(shost);
	wait_cmds_complete_timeout_v3_hw(hisi_hba, 100, 5000);

	set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
	hisi_sas_sync_irqs(hisi_hba);
	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
}

static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba)
{
	struct Scsi_Host *shost = hisi_hba->shost;

	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE,
			 (u32)((1ULL << hisi_hba->queue_count) - 1));

	clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
	scsi_unblock_requests(shost);
}

static void read_iost_itct_cache_v3_hw(struct hisi_hba *hisi_hba,
@@ -3268,6 +3281,7 @@ static struct scsi_host_template sht_v3_hw = {
	.eh_device_reset_handler = sas_eh_device_reset_handler,
	.eh_target_reset_handler = sas_eh_target_reset_handler,
	.slave_alloc		= hisi_sas_slave_alloc,
	.slave_destroy		= slave_destroy_v3_hw,
	.target_destroy		= sas_target_destroy,
	.ioctl			= sas_ioctl,
#ifdef CONFIG_COMPAT
@@ -5087,11 +5101,14 @@ static int _suspend_v3_hw(struct device *device)
	flush_workqueue(hisi_hba->wq);
	interrupt_disable_v3_hw(hisi_hba);

	if (atomic_read(&device->power.usage_count)) {
#ifdef CONFIG_PM
	if ((device->power.runtime_status == RPM_SUSPENDING) &&
	    atomic_read(&device->power.usage_count)) {
		dev_err(dev, "PM suspend: host status cannot be suspended\n");
		rc = -EBUSY;
		goto err_out;
	}
#endif

	rc = disable_host_v3_hw(hisi_hba);
	if (rc) {
@@ -5110,7 +5127,9 @@ static int _suspend_v3_hw(struct device *device)

err_out_recover_host:
	enable_host_v3_hw(hisi_hba);
#ifdef CONFIG_PM
err_out:
#endif
	interrupt_enable_v3_hw(hisi_hba);
	clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
	clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags);
+18 −6
Original line number Diff line number Diff line
@@ -3663,6 +3663,7 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
{
	struct scsi_disk *sdkp = dev_get_drvdata(dev);
	struct scsi_sense_hdr sshdr;
	int retries;
	int ret = 0;

	if (!sdkp)	/* E.g.: runtime suspend following sd_remove() */
@@ -3693,9 +3694,15 @@ 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");
		/* an error is not worth aborting a system sleep */
		for (retries = 3; retries > 0; --retries) {
			ret = sd_start_stop_device(sdkp, 0);
		if (ignore_stop_errors)
			if (!ret)
				break;
			if (ignore_stop_errors) {
				ret = 0;
				break;
			}
		}
	}

	return ret;
@@ -3714,6 +3721,7 @@ static int sd_suspend_runtime(struct device *dev)
static int sd_resume(struct device *dev)
{
	struct scsi_disk *sdkp = dev_get_drvdata(dev);
	int retries;
	int ret;

	if (!sdkp)	/* E.g.: runtime resume at the start of sd_probe() */
@@ -3723,9 +3731,13 @@ static int sd_resume(struct device *dev)
		return 0;

	sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
	for (retries = 3; retries > 0; --retries) {
		ret = sd_start_stop_device(sdkp, 1);
	if (!ret)
		if (!ret) {
			opal_unlock_from_suspend(sdkp->opal_dev);
			break;
		}
	}
	return ret;
}