提交 2115ea94 编写于 作者: T Tejun Heo

[PATCH] libata-ncq: pass ata_scsi_translate() return value to SCSI midlayer

ata_scsi_translate() will need to return SCSI_ML_QUEUE_DEVICE_BUSY to
achieve exlusion between NCQ and non-NCQ commands or among non-NCQ
commands.  Pass its return value upward to SCSI midlayer.
Signed-off-by: NTejun Heo <htejun@gmail.com>
上级 88e49034
...@@ -1248,11 +1248,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) ...@@ -1248,11 +1248,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
* *
* LOCKING: * LOCKING:
* spin_lock_irqsave(host_set lock) * spin_lock_irqsave(host_set lock)
*
* RETURNS:
* 0 on success, SCSI_ML_QUEUE_DEVICE_BUSY if the command
* needs to be deferred.
*/ */
static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
void (*done)(struct scsi_cmnd *), ata_xlat_func_t xlat_func)
ata_xlat_func_t xlat_func)
{ {
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
u8 *scsicmd = cmd->cmnd; u8 *scsicmd = cmd->cmnd;
...@@ -1290,13 +1293,13 @@ static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, ...@@ -1290,13 +1293,13 @@ static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
ata_qc_issue(qc); ata_qc_issue(qc);
VPRINTK("EXIT\n"); VPRINTK("EXIT\n");
return; return 0;
early_finish: early_finish:
ata_qc_free(qc); ata_qc_free(qc);
done(cmd); done(cmd);
DPRINTK("EXIT - early finish (good or error)\n"); DPRINTK("EXIT - early finish (good or error)\n");
return; return 0;
err_did: err_did:
ata_qc_free(qc); ata_qc_free(qc);
...@@ -1304,7 +1307,7 @@ static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, ...@@ -1304,7 +1307,7 @@ static void ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
cmd->result = (DID_ERROR << 16); cmd->result = (DID_ERROR << 16);
done(cmd); done(cmd);
DPRINTK("EXIT - internal\n"); DPRINTK("EXIT - internal\n");
return; return 0;
} }
/** /**
...@@ -2456,20 +2459,24 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, ...@@ -2456,20 +2459,24 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap,
#endif #endif
} }
static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd,
void (*done)(struct scsi_cmnd *), void (*done)(struct scsi_cmnd *),
struct ata_device *dev) struct ata_device *dev)
{ {
int rc = 0;
if (dev->class == ATA_DEV_ATA) { if (dev->class == ATA_DEV_ATA) {
ata_xlat_func_t xlat_func = ata_get_xlat_func(dev, ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
cmd->cmnd[0]); cmd->cmnd[0]);
if (xlat_func) if (xlat_func)
ata_scsi_translate(dev, cmd, done, xlat_func); rc = ata_scsi_translate(dev, cmd, done, xlat_func);
else else
ata_scsi_simulate(dev, cmd, done); ata_scsi_simulate(dev, cmd, done);
} else } else
ata_scsi_translate(dev, cmd, done, atapi_xlat); rc = ata_scsi_translate(dev, cmd, done, atapi_xlat);
return rc;
} }
/** /**
...@@ -2488,15 +2495,16 @@ static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, ...@@ -2488,15 +2495,16 @@ static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd,
* Releases scsi-layer-held lock, and obtains host_set lock. * Releases scsi-layer-held lock, and obtains host_set lock.
* *
* RETURNS: * RETURNS:
* Zero. * Return value from __ata_scsi_queuecmd() if @cmd can be queued,
* 0 otherwise.
*/ */
int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
{ {
struct ata_port *ap; struct ata_port *ap;
struct ata_device *dev; struct ata_device *dev;
struct scsi_device *scsidev = cmd->device; struct scsi_device *scsidev = cmd->device;
struct Scsi_Host *shost = scsidev->host; struct Scsi_Host *shost = scsidev->host;
int rc = 0;
ap = ata_shost_to_port(shost); ap = ata_shost_to_port(shost);
...@@ -2507,7 +2515,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) ...@@ -2507,7 +2515,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
dev = ata_scsi_find_dev(ap, scsidev); dev = ata_scsi_find_dev(ap, scsidev);
if (likely(dev)) if (likely(dev))
__ata_scsi_queuecmd(cmd, done, dev); rc = __ata_scsi_queuecmd(cmd, done, dev);
else { else {
cmd->result = (DID_BAD_TARGET << 16); cmd->result = (DID_BAD_TARGET << 16);
done(cmd); done(cmd);
...@@ -2515,7 +2523,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) ...@@ -2515,7 +2523,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
spin_unlock(&ap->host_set->lock); spin_unlock(&ap->host_set->lock);
spin_lock(shost->host_lock); spin_lock(shost->host_lock);
return 0; return rc;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册