Commit e0b2e597 authored by Ed Lin's avatar Ed Lin Committed by James Bottomley

[SCSI] stex: fix id mapping issue

The correct internal mapping of stex controllers should be:
id:0~15, lun:0~7 (st_shasta)
id:0, lun:0~127 (st_yosemite)
id:0~127, lun:0 (st_vsc and st_vsc1)

This patch reports the internal mapping to scsi mid layer,  eliminating
the translation between scsi mid layer and firmware. To achieve this
goal, we also need to:
-- fail the REPORT_LUNS command for st_shasta because the
   firmware is known to not report all actual luns
-- add an entry in scsi_devindo.c to force sequential lun scan
   (for st_shasta controllers)
-- fail the REPORT_LUNS command for console device
-- remove special handling of REPORT_LUNS command for
   st_yosemite, as there is no translation mapping now
Signed-off-by: default avatarEd Lin <ed.lin@promise.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 5af23d26
...@@ -209,6 +209,7 @@ static struct { ...@@ -209,6 +209,7 @@ static struct {
{"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
{"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
{"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
{"Promise", "", NULL, BLIST_SPARSELUN},
{"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN}, {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
{"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN}, {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
{"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */ {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */
......
...@@ -113,10 +113,6 @@ enum { ...@@ -113,10 +113,6 @@ enum {
SG_CF_64B = 0x40, /* 64 bit item */ SG_CF_64B = 0x40, /* 64 bit item */
SG_CF_HOST = 0x20, /* sg in host memory */ SG_CF_HOST = 0x20, /* sg in host memory */
ST_MAX_ARRAY_SUPPORTED = 16,
ST_MAX_TARGET_NUM = (ST_MAX_ARRAY_SUPPORTED+1),
ST_MAX_LUN_PER_TARGET = 16,
st_shasta = 0, st_shasta = 0,
st_vsc = 1, st_vsc = 1,
st_vsc1 = 2, st_vsc1 = 2,
...@@ -586,7 +582,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) ...@@ -586,7 +582,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
u16 tag; u16 tag;
host = cmd->device->host; host = cmd->device->host;
id = cmd->device->id; id = cmd->device->id;
lun = cmd->device->channel; /* firmware lun issue work around */ lun = cmd->device->lun;
hba = (struct st_hba *) &host->hostdata[0]; hba = (struct st_hba *) &host->hostdata[0];
switch (cmd->cmnd[0]) { switch (cmd->cmnd[0]) {
...@@ -605,8 +601,19 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) ...@@ -605,8 +601,19 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
stex_invalid_field(cmd, done); stex_invalid_field(cmd, done);
return 0; return 0;
} }
case REPORT_LUNS:
/*
* The shasta firmware does not report actual luns in the
* target, so fail the command to force sequential lun scan.
* Also, the console device does not support this command.
*/
if (hba->cardtype == st_shasta || id == host->max_id - 1) {
stex_invalid_field(cmd, done);
return 0;
}
break;
case INQUIRY: case INQUIRY:
if (id != ST_MAX_ARRAY_SUPPORTED) if (id != host->max_id - 1)
break; break;
if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) { if (lun == 0 && (cmd->cmnd[1] & INQUIRY_EVPD) == 0) {
stex_direct_copy(cmd, console_inq_page, stex_direct_copy(cmd, console_inq_page,
...@@ -624,7 +631,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) ...@@ -624,7 +631,7 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
ver.oem = ST_OEM; ver.oem = ST_OEM;
ver.build = ST_BUILD_VER; ver.build = ST_BUILD_VER;
ver.signature[0] = PASSTHRU_SIGNATURE; ver.signature[0] = PASSTHRU_SIGNATURE;
ver.console_id = ST_MAX_ARRAY_SUPPORTED; ver.console_id = host->max_id - 1;
ver.host_no = hba->host->host_no; ver.host_no = hba->host->host_no;
cmd->result = stex_direct_copy(cmd, &ver, sizeof(ver)) ? cmd->result = stex_direct_copy(cmd, &ver, sizeof(ver)) ?
DID_OK << 16 | COMMAND_COMPLETE << 8 : DID_OK << 16 | COMMAND_COMPLETE << 8 :
...@@ -645,13 +652,8 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) ...@@ -645,13 +652,8 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
req = stex_alloc_req(hba); req = stex_alloc_req(hba);
if (hba->cardtype == st_yosemite) { req->lun = lun;
req->lun = lun * (ST_MAX_TARGET_NUM - 1) + id; req->target = id;
req->target = 0;
} else {
req->lun = lun;
req->target = id;
}
/* cdb */ /* cdb */
memcpy(req->cdb, cmd->cmnd, STEX_CDB_LENGTH); memcpy(req->cdb, cmd->cmnd, STEX_CDB_LENGTH);
...@@ -767,18 +769,6 @@ static void stex_ys_commands(struct st_hba *hba, ...@@ -767,18 +769,6 @@ static void stex_ys_commands(struct st_hba *hba,
ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT; ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT;
else else
ccb->srb_status = SRB_STATUS_SUCCESS; ccb->srb_status = SRB_STATUS_SUCCESS;
} else if (ccb->cmd->cmnd[0] == REPORT_LUNS) {
u8 *report_lun_data = (u8 *)hba->copy_buffer;
count = STEX_EXTRA_SIZE;
stex_internal_copy(ccb->cmd, report_lun_data,
&count, ccb->sg_count, ST_FROM_CMD);
if (report_lun_data[2] || report_lun_data[3]) {
report_lun_data[2] = 0x00;
report_lun_data[3] = 0x08;
stex_internal_copy(ccb->cmd, report_lun_data,
&count, ccb->sg_count, ST_TO_CMD);
}
} }
} }
...@@ -1229,12 +1219,18 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1229,12 +1219,18 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE; hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE;
hba->mu_status = MU_STATE_STARTING; hba->mu_status = MU_STATE_STARTING;
/* firmware uses id/lun pair for a logical drive, but lun would be if (hba->cardtype == st_shasta) {
always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use host->max_lun = 8;
channel to map lun here */ host->max_id = 16 + 1;
host->max_channel = ST_MAX_LUN_PER_TARGET - 1; } else if (hba->cardtype == st_yosemite) {
host->max_id = ST_MAX_TARGET_NUM; host->max_lun = 128;
host->max_lun = 1; host->max_id = 1 + 1;
} else {
/* st_vsc and st_vsc1 */
host->max_lun = 1;
host->max_id = 128 + 1;
}
host->max_channel = 0;
host->unique_id = host->host_no; host->unique_id = host->host_no;
host->max_cmd_len = STEX_CDB_LENGTH; host->max_cmd_len = STEX_CDB_LENGTH;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment