Skip to contentSkip to conversation

mpt2sas : Enable TLR for SSP TAPE drives

PATCH In review Kashyap, Desai 2 participants 3 messages Nov 13, 2009 – Nov 16, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpt2sas : Enable TLR for SSP TAPE drives

The driver is sending vpd page 0, to get a list of supported pages. Then it will traverse the list searching for page 0x90. when page 0x90 is present, the driver will enable the TLR logic for Tape devices only. The TLR logic will enable the TLR bits in the SCSI_IO for every request. If there is a response with MPI2_SCSITASKMGMT_RSP_INVALID_FRAME, the driver will turn off the TLR logic.

---

mpt2sas_scsih.c +48 -15
diff -Naurp mpt2sas_orig/mpt2sas_scsih.c mpt2sas/mpt2sas_scsih.c
@@ -1301,7 +1301,6 @@ _scsih_slave_alloc(struct scsi_device *s
 	struct MPT2SAS_DEVICE *sas_device_priv_data;
 	struct scsi_target *starget;
 	struct _raid_device *raid_device;
-	struct _sas_device *sas_device;
 	unsigned long flags;
 
 	sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
@@ -1328,21 +1327,8 @@ _scsih_slave_alloc(struct scsi_device *s
 		if (raid_device)
 			raid_device->sdev = sdev; /* raid is single lun */
 		spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
-	} else {
-		/* set TLR bit for SSP devices */
-		if (!(ioc->facts.IOCCapabilities &
-		     MPI2_IOCFACTS_CAPABILITY_TLR))
-			goto out;
-		spin_lock_irqsave(&ioc->sas_device_lock, flags);
-		sas_device = mpt2sas_scsih_sas_device_find_by_sas_address(ioc,
-		   sas_device_priv_data->sas_target->sas_address);
-		spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
-		if (sas_device && sas_device->device_info &
-		    MPI2_SAS_DEVICE_INFO_SSP_TARGET)
-			sas_device_priv_data->flags |= MPT_DEVICE_TLR_ON;
 	}
 
- out:
 	return 0;
 }
 
@@ -1475,6 +1461,51 @@ _scsih_get_volume_capabilities(struct MP
 }
 
 /**
+ * _scsih_enable_tlr - setting TLR flags
+ * @ioc: per adapter object
+ * @sdev: scsi device struct
+ *
+ * Enabling Transaction Layer Retries for tape devices when
+ * vpd page 0x90 is present
+ *
+ */
+static void
+_scsih_enable_tlr(struct MPT2SAS_ADAPTER *ioc, struct scsi_device *sdev)
+{
+	struct MPT2SAS_DEVICE *sas_device_priv_data;
+	struct MPT2SAS_TARGET *sas_target_priv_data;
+	char *buffer;
+
+	/* only for TAPE */
+	if (sdev->type != TYPE_TAPE)
+		return;
+
+	if (!(ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR))
+		return;
+
+	sas_device_priv_data = sdev->hostdata;
+	if (!sas_device_priv_data)
+		return;
+	sas_target_priv_data = sas_device_priv_data->sas_target;
+	if (!sas_target_priv_data)
+		return;
+
+	buffer = scsi_get_vpd_page(sdev, 0x90);
+	if (buffer == NULL) {
+		dprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: VPD page 0x90 is not"
+			"supported\n", ioc->name, __func__));
+                return;
+	}
+
+	dprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: VPD page 0x90 is "
+		"supported\n", ioc->name, __func__));
+	sas_device_priv_data->flags |= MPT_DEVICE_TLR_ON;
+	kfree(buffer);
+	return;
+
+}
+
+/**
  * _scsih_slave_configure - device configure routine.
  * @sdev: scsi device struct
  *
@@ -1617,8 +1648,10 @@ _scsih_slave_configure(struct scsi_devic
 
 	_scsih_change_queue_depth(sdev, qdepth);
 
-	if (ssp_target)
+	if (ssp_target) {
 		sas_read_port_mode_page(sdev);
+		_scsih_enable_tlr(ioc, sdev);
+	}
 	return 0;
 }
 
#1 lore raw
Quoted 6 lines · Desai

The driver is sending vpd page 0, to get a list of supported pages. Then it will traverse the list searching for page 0x90. when page 0x90 is present, the driver will enable the TLR logic for Tape devices only. The TLR logic will enable the TLR bits in the SCSI_IO for every request. If there is a response with MPI2_SCSITASKMGMT_RSP_INVALID_FRAME, the driver will turn off the TLR logic.

This is applicable to all SAS drivers, isn't it? So it should be in the sas transport class and we should be figuring out how to add it to all SAS drivers, shouldn't we?

James

#2 lore raw
Quoted 18 lines

-----Original Message-----
From: James Bottomley [mailto:[email protected]]
Sent: Friday, November 13, 2009 8:24 PM
To: Desai, Kashyap
Cc: [email protected]; Moore, Eric; Prakash, Sathya
Subject: Re: [PATCH] mpt2sas : Enable TLR for SSP TAPE drives

Quoted 1 line · Desai

The driver is sending vpd page 0, to get a list of supported pages. Then

it

Quoted 1 line

will traverse the list searching for page 0x90. when page 0x90 is

present,

Quoted 1 line

the driver will enable the TLR logic for Tape devices only. The TLR

logic

Quoted 2 lines

will enable the TLR bits in the SCSI_IO for every request. If there is a response with MPI2_SCSITASKMGMT_RSP_INVALID_FRAME, the driver will turn

Quoted 9 lines

off

Quoted 1 line

the TLR logic.

This is applicable to all SAS drivers, isn't it? So it should be in the sas transport class and we should be figuring out how to add it to all SAS drivers, shouldn't we?

James

Agree. Nice to have it in transport layer. In that case, we have to add *tlr_enabled* field in *struct scsi_device*. Currently we are using "sdev->hostdata" to store tlr flags.(this can be replaced by above proposed field in scs_device)

We can add functions like

/*Enable*/ Void sas_enable_tlr(struct scsi_device *sdev) /*Disable*/ Void sas_disable_tlr(struct scsi_device *sdev)
/*Check*/ int sas_check_tlr(struct scsi_device *sdev)

Caller can take care of checking IOC capabilities of supporting TLR at HBA level and they can call sas_enable_tlr to enable TLR for particular drive.

Suggestion?

Kashyap