From d794ce3e07e0f5a90716754d5d9e2393c5ff6df1 Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Tue, 15 Oct 2002 04:51:27 -0700 Subject: [PATCH] [PATCH] another TCQ update More scsi TCQ updates, tweak to ServeRAID, tweak scsi_scan, make BusLogic use new method --- drivers/scsi/BusLogic.c | 66 ++++++++++++++++++++++++++++++++++------ drivers/scsi/BusLogic.h | 2 ++ drivers/scsi/ips.c | 10 +++--- drivers/scsi/scsi_scan.c | 7 +++++ 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index d32420b99220..b4ee7032b7d7 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -2604,21 +2604,21 @@ static boolean BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T through Host Adapter. */ -static void BusLogic_ReportTargetDeviceInfo(BusLogic_HostAdapter_T +/*static void BusLogic_ReportTargetDeviceInfo(BusLogic_HostAdapter_T *HostAdapter) { int TargetID; - /* +*/ /* Inhibit the Target Device Inquiry and Reporting if requested. */ - if (BusLogic_MultiMasterHostAdapterP(HostAdapter) && +/* if (BusLogic_MultiMasterHostAdapterP(HostAdapter) && HostAdapter->DriverOptions != NULL && HostAdapter->DriverOptions->LocalOptions.InhibitTargetInquiry) return; - /* +*/ /* Report on the Target Devices found. */ - for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) +/* for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { BusLogic_TargetFlags_T *TargetFlags = &HostAdapter->TargetFlags[TargetID]; if (TargetFlags->TargetExists && !TargetFlags->TargetInfoReported) @@ -2674,7 +2674,7 @@ static void BusLogic_ReportTargetDeviceInfo(BusLogic_HostAdapter_T } } } - +*/ /* BusLogic_InitializeHostStructure initializes the fields in the SCSI Host @@ -2700,6 +2700,49 @@ static void BusLogic_InitializeHostStructure(BusLogic_HostAdapter_T Host->cmd_per_lun = HostAdapter->UntaggedQueueDepth; } +/* + BusLogic_SlaveAttach will actually set the queue depth on individual + scsi devices as they are permanently added to the device chain. We + shamelessly rip off the SelectQueueDepths code to make this work mostly + like it used to. Since we don't get called once at the end of the scan + but instead get called for each device, we have to do things a bit + differently. +*/ +int BusLogic_SlaveAttach(SCSI_Device_T *Device) +{ + BusLogic_HostAdapter_T *HostAdapter = + (BusLogic_HostAdapter_T *) Device->host->hostdata; + int TargetID = Device->id; + int QueueDepth = HostAdapter->QueueDepth[TargetID]; + + if (HostAdapter->TargetFlags[TargetID].TaggedQueuingSupported && + (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) + { + if (QueueDepth == 0) + QueueDepth = BusLogic_MaxAutomaticTaggedQueueDepth; + HostAdapter->QueueDepth[TargetID] = QueueDepth; + scsi_adjust_queue_depth(Device, MSG_SIMPLE_TAG, QueueDepth); + } + else + { + HostAdapter->TaggedQueuingPermitted &= ~(1 << TargetID); + QueueDepth = HostAdapter->UntaggedQueueDepth; + HostAdapter->QueueDepth[TargetID] = QueueDepth; + scsi_adjust_queue_depth(Device, 0, QueueDepth); + } + QueueDepth = 0; + for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) + if (HostAdapter->TargetFlags[TargetID].TargetExists) + { + QueueDepth += HostAdapter->QueueDepth[TargetID]; + } + if (QueueDepth > HostAdapter->AllocatedCCBs) + BusLogic_CreateAdditionalCCBs(HostAdapter, + QueueDepth + - HostAdapter->AllocatedCCBs, + false); + return 0; +} /* BusLogic_SelectQueueDepths selects Queue Depths for each Target Device based @@ -2709,7 +2752,7 @@ static void BusLogic_InitializeHostStructure(BusLogic_HostAdapter_T since all the Target Devices have now been probed. */ -static void BusLogic_SelectQueueDepths(SCSI_Host_T *Host, +/* static void BusLogic_SelectQueueDepths(SCSI_Host_T *Host, SCSI_Device_T *DeviceList) { BusLogic_HostAdapter_T *HostAdapter = @@ -2764,8 +2807,8 @@ static void BusLogic_SelectQueueDepths(SCSI_Host_T *Host, for (Device = DeviceList; Device != NULL; Device = Device->next) if (Device->host == Host) Device->queue_depth = HostAdapter->QueueDepth[Device->id]; - /* Allocate an extra CCB for each Target Device for a Bus Device Reset. */ - AllocatedQueueDepth += HostAdapter->TargetDeviceCount; +*/ /* Allocate an extra CCB for each Target Device for a Bus Device Reset. */ +/* AllocatedQueueDepth += HostAdapter->TargetDeviceCount; if (AllocatedQueueDepth > HostAdapter->DriverQueueDepth) AllocatedQueueDepth = HostAdapter->DriverQueueDepth; BusLogic_CreateAdditionalCCBs(HostAdapter, @@ -2778,7 +2821,7 @@ static void BusLogic_SelectQueueDepths(SCSI_Host_T *Host, HostAdapter = HostAdapter->Next) BusLogic_ReportTargetDeviceInfo(HostAdapter); } - +*/ /* BusLogic_DetectHostAdapter probes for BusLogic Host Adapters at the standard @@ -2881,7 +2924,10 @@ int BusLogic_DetectHostAdapter(SCSI_Host_Template_T *HostTemplate) memcpy(HostAdapter, PrototypeHostAdapter, sizeof(BusLogic_HostAdapter_T)); HostAdapter->SCSI_Host = Host; HostAdapter->HostNumber = Host->host_no; + /* + * This function is deprecated Host->select_queue_depths = BusLogic_SelectQueueDepths; + */ /* Add Host Adapter to the end of the list of registered BusLogic Host Adapters. diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h index 00fb8207a3a8..4f064b12903e 100644 --- a/drivers/scsi/BusLogic.h +++ b/drivers/scsi/BusLogic.h @@ -60,6 +60,7 @@ extern int BusLogic_ResetCommand(SCSI_Command_T *, unsigned int); extern int BusLogic_BIOSDiskParameters(SCSI_Disk_T *, struct block_device *, int *); extern int BusLogic_ProcDirectoryInfo(char *, char **, off_t, int, int, int); +extern int BusLogic_SlaveAttach(SCSI_Device_T *); /* @@ -76,6 +77,7 @@ extern int BusLogic_ProcDirectoryInfo(char *, char **, off_t, int, int, int); queuecommand: BusLogic_QueueCommand, /* Queue Command Function */ \ abort: BusLogic_AbortCommand, /* Abort Command Function */ \ reset: BusLogic_ResetCommand, /* Reset Command Function */ \ + slave_attach: BusLogic_SlaveAttach, /* Configure a SCSI_Device*/ \ bios_param: BusLogic_BIOSDiskParameters, /* BIOS Disk Parameters */ \ unchecked_isa_dma: 1, /* Default Initial Value */ \ max_sectors: 128, /* I/O queue len limit */ \ diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 6963127669ce..fa060c14118c 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -1879,10 +1879,12 @@ ips_slave_attach(Scsi_Device *SDptr) int min; ha = IPS_HA(SDptr->host); - min = ha->max_cmds / 4; - if (min < 8) - min = ha->max_cmds - 1; - scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, min); + if (SDptr->tagged_supported) { + min = ha->max_cmds / 2; + if (min <= 16) + min = ha->max_cmds - 1; + scsi_adjust_queue_depth(SDptr, MSG_ORDERED_TAG, min); + } return 0; } diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 0f52ed55b210..fd2eadc20f1e 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1482,6 +1482,13 @@ static int scsi_add_lun(Scsi_Device *sdevscan, Scsi_Device **sdevnew, printk(KERN_INFO "%s: scsi_add_lun: failed low level driver attach, setting device offline", devname); sdev->online = FALSE; } + /* + * For untagged devices, did the lldd set the untagged queue + * depth? + */ + if(sdev->tagged_supported == 0 && + sdev->new_queue_depth != sdev->host->cmd_per_lun) + scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); } else if(sdev->host->cmd_per_lun) { scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); } -- 2.39.5