summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2021-10-07 13:28:11 -0700
committerMartin K. Petersen <martin.petersen@oracle.com>2021-10-16 21:28:45 -0400
commit7afdb8637997497c8cfd0369f2b7bece477f47c0 (patch)
treed381c8f0fbacdca343123ffad80b2482d85c7b38
parent1dec65e32fb512dde098c1aa06ed35f0eed5d90f (diff)
downloadlinux-7afdb8637997497c8cfd0369f2b7bece477f47c0.tar.bz2
scsi: aacraid: Call scsi_done() directly
The aacraid driver invokes scmd->scsi_done(scmd) for two types of SCSI commands: - SCSI commands initialized by the SCSI mid-layer. - SCSI commands initialized by aac_probe_container(). The processing sequence for SCSI commands allocated by aac_probe_container() is as follows: aac_probe_container() -> _aac_probe_container(scmd, aac_probe_container_callback1) -> scmd->SCp.ptr = aac_probe_container_callback1 -> aac_fib_send(..., _aac_probe_container1, scmd) -> fibptr->callback = _aac_probe_container1 -> fibptr->callback_data = scmd fibptr->callback(scmd) -> _aac_probe_container1(scmd, fibptr) [ ... ] -> _aac_probe_container2(scmd, fibptr) -> Call scmd->SCp.ptr == aac_probe_container_callback1 -> scmd->device = NULL; The processing sequence for SCSI commands allocated by the SCSI mid-layer if _aac_probe_container() is called is as follows: aac_queuecommand() -> aac_scsi_cmd() -> _aac_probe_container(scmd, aac_probe_container_callback2) -> scmd->SCp.ptr = aac_probe_container_callback2 -> aac_fib_send(..., _aac_probe_container1, scmd) fibptr->callback(scmd) -> _aac_probe_container1(scmd, fibptr) [ ... ] -> _aac_probe_container2(scmd, fibptr) -> Call scmd->SCp.ptr == aac_probe_container_callback2 Preserve the existing call sequences by calling scsi_done() for commands submitted by the mid-layer or aac_probe_container_scsi_done() for commands submitted by aac_probe_container(). Link: https://lore.kernel.org/r/20211007202923.2174984-17-bvanassche@acm.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/aacraid/aachba.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 40b86acac17b..59f6b7b2a70a 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -223,6 +223,7 @@ static long aac_build_sghba(struct scsi_cmnd *scsicmd,
int sg_max, u64 sg_address);
static int aac_convert_sgraw2(struct aac_raw_io2 *rio2,
int pages, int nseg, int nseg_new);
+static void aac_probe_container_scsi_done(struct scsi_cmnd *scsi_cmnd);
static int aac_send_srb_fib(struct scsi_cmnd* scsicmd);
static int aac_send_hba_fib(struct scsi_cmnd *scsicmd);
#ifdef AAC_DETAILED_STATUS_INFO
@@ -332,7 +333,7 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd,
struct fib *fibptr) {
struct scsi_device *device;
- if (unlikely(!scsicmd || !scsicmd->scsi_done)) {
+ if (unlikely(!scsicmd)) {
dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));
aac_fib_complete(fibptr);
return 0;
@@ -519,7 +520,13 @@ int aac_get_containers(struct aac_dev *dev)
static void aac_scsi_done(struct scsi_cmnd *scmd)
{
- scmd->scsi_done(scmd);
+ if (scmd->device->request_queue) {
+ /* SCSI command has been submitted by the SCSI mid-layer. */
+ scsi_done(scmd);
+ } else {
+ /* SCSI command has been submitted by aac_probe_container(). */
+ aac_probe_container_scsi_done(scmd);
+ }
}
static void get_container_name_callback(void *context, struct fib * fibptr)
@@ -809,8 +816,8 @@ static void aac_probe_container_scsi_done(struct scsi_cmnd *scsi_cmnd)
int aac_probe_container(struct aac_dev *dev, int cid)
{
- struct scsi_cmnd *scsicmd = kmalloc(sizeof(*scsicmd), GFP_KERNEL);
- struct scsi_device *scsidev = kmalloc(sizeof(*scsidev), GFP_KERNEL);
+ struct scsi_cmnd *scsicmd = kzalloc(sizeof(*scsicmd), GFP_KERNEL);
+ struct scsi_device *scsidev = kzalloc(sizeof(*scsidev), GFP_KERNEL);
int status;
if (!scsicmd || !scsidev) {
@@ -818,7 +825,6 @@ int aac_probe_container(struct aac_dev *dev, int cid)
kfree(scsidev);
return -ENOMEM;
}
- scsicmd->scsi_done = aac_probe_container_scsi_done;
scsicmd->device = scsidev;
scsidev->sdev_state = 0;