Commit 2d51cb17 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull SCSI fixes from James Bottomley:
 "ufs driver plus two core fixes.

  One core fix makes the unit attention counters atomic (just in case
  multiple commands detect them) and the other is fixing a merge window
  regression caused by changes in the block tree"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: core: Fix the unit attention counter implementation
  scsi: ufs: core: Declare tx_lanes witout initialization
  scsi: ufs: core: Initialize value of an attribute returned by uic cmd
  scsi: ufs: core: Fix error handler host_sem issue
  scsi: core: Fix a regression triggered by scsi_host_busy()
parents d1271768 d54c676d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -611,6 +611,7 @@ int scsi_host_busy(struct Scsi_Host *shost)
{
	int cnt = 0;

	if (shost->tag_set.ops)
		blk_mq_tagset_busy_iter(&shost->tag_set,
					scsi_host_check_in_flight, &cnt);
	return cnt;
+2 −2
Original line number Diff line number Diff line
@@ -554,9 +554,9 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
		 * happened, even if someone else gets the sense data.
		 */
		if (sshdr.asc == 0x28)
			scmd->device->ua_new_media_ctr++;
			atomic_inc(&sdev->ua_new_media_ctr);
		else if (sshdr.asc == 0x29)
			scmd->device->ua_por_ctr++;
			atomic_inc(&sdev->ua_por_ctr);
	}

	if (scsi_sense_is_deferred(&sshdr))
+17 −11
Original line number Diff line number Diff line
@@ -4282,8 +4282,8 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
			get, UIC_GET_ATTR_ID(attr_sel),
			UFS_UIC_COMMAND_RETRIES - retries);

	if (mib_val && !ret)
		*mib_val = uic_cmd.argument3;
	if (mib_val)
		*mib_val = ret == 0 ? uic_cmd.argument3 : 0;

	if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)
	    && pwr_mode_change)
@@ -4999,7 +4999,7 @@ EXPORT_SYMBOL_GPL(ufshcd_hba_enable);

static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
{
	int tx_lanes = 0, i, err = 0;
	int tx_lanes, i, err = 0;

	if (!peer)
		ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
@@ -6673,6 +6673,20 @@ static void ufshcd_err_handler(struct work_struct *work)
		 hba->saved_uic_err, hba->force_reset,
		 ufshcd_is_link_broken(hba) ? "; link is broken" : "");

	/*
	 * Use ufshcd_rpm_get_noresume() here to safely perform link recovery
	 * even if an error occurs during runtime suspend or runtime resume.
	 * This avoids potential deadlocks that could happen if we tried to
	 * resume the device while a PM operation is already in progress.
	 */
	ufshcd_rpm_get_noresume(hba);
	if (hba->pm_op_in_progress) {
		ufshcd_link_recovery(hba);
		ufshcd_rpm_put(hba);
		return;
	}
	ufshcd_rpm_put(hba);

	down(&hba->host_sem);
	spin_lock_irqsave(hba->host->host_lock, flags);
	if (ufshcd_err_handling_should_stop(hba)) {
@@ -6684,14 +6698,6 @@ static void ufshcd_err_handler(struct work_struct *work)
	}
	spin_unlock_irqrestore(hba->host->host_lock, flags);

	ufshcd_rpm_get_noresume(hba);
	if (hba->pm_op_in_progress) {
		ufshcd_link_recovery(hba);
		ufshcd_rpm_put(hba);
		return;
	}
	ufshcd_rpm_put(hba);

	ufshcd_err_handling_prepare(hba);

	spin_lock_irqsave(hba->host->host_lock, flags);
+4 −6
Original line number Diff line number Diff line
@@ -252,8 +252,8 @@ struct scsi_device {
	unsigned int queue_stopped;	/* request queue is quiesced */
	bool offline_already;		/* Device offline message logged */

	unsigned int ua_new_media_ctr;	/* Counter for New Media UNIT ATTENTIONs */
	unsigned int ua_por_ctr;	/* Counter for Power On / Reset UAs */
	atomic_t ua_new_media_ctr;	/* Counter for New Media UNIT ATTENTIONs */
	atomic_t ua_por_ctr;		/* Counter for Power On / Reset UAs */

	atomic_t disk_events_disable_depth; /* disable depth for disk events */

@@ -693,10 +693,8 @@ static inline int scsi_device_busy(struct scsi_device *sdev)
}

/* Macros to access the UNIT ATTENTION counters */
#define scsi_get_ua_new_media_ctr(sdev) \
	((const unsigned int)(sdev->ua_new_media_ctr))
#define scsi_get_ua_por_ctr(sdev) \
	((const unsigned int)(sdev->ua_por_ctr))
#define scsi_get_ua_new_media_ctr(sdev)	atomic_read(&sdev->ua_new_media_ctr)
#define scsi_get_ua_por_ctr(sdev)	atomic_read(&sdev->ua_por_ctr)

#define MODULE_ALIAS_SCSI_DEVICE(type) \
	MODULE_ALIAS("scsi:t-" __stringify(type) "*")