Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp858499ybh; Tue, 10 Mar 2020 09:33:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuYCumevOLUVTGzDKNp35BoNJhrByOcJJhu6JLqaBZ9d8gF5idqSoo6llXs2e1nFAAqeu8t X-Received: by 2002:a9d:39f4:: with SMTP id y107mr17623586otb.347.1583857981244; Tue, 10 Mar 2020 09:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583857981; cv=none; d=google.com; s=arc-20160816; b=YmBbxI4PObXnvoWVEusGuY10blMvpF6UdzUuy/a6s/4rPyMcxnKhKWak2vwlNdxzzz sKIH+Z5TBL02wN4h6KTK2fVQQboe/sTZG7yet7gfbGsswIdLJuMqtY63JdbTpIZJupv9 F1ibmxMCmHkdoF1we7n+Glsgk+hwx805Oa/ijvMUtzdKxoAlVJNjqqM5AbS2+/1CYIPP 5hvIwqGv91SUOgaZYnycBxIo6odZGWuHEF51+ZbfO/jP0SsSg1049ZhjBX0OnZXcaptJ oO+cgIYqlSaXtAafXHFcgnVw4HGGLZomr/rbB8PLrigZaz3HYLjYjpZFnTlSGAUNiuYI 1f5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=f6aDOqCr3BVTulo27Ih4TToMGb1uQseXHUxmOYfdEYU=; b=StFX2iFtTu1bhxdvtgJr7uEEjEUS0FYCrUXmVUVlg0UUl29gbzklliq+J36TqcLBG/ n+8Wpar26YkYjONEBt9TJ4/PM2P6f0BdQSMkyxYTT6iZwY5cKMdsoCSb2ua/epR80u7Y mOnah9+yllMdCMFWvc0IpsDhHs73rwft04jvQBI4aUma8J84jbw6ewfVsT2vdF0JgSJ3 x/kkguFEbT8yEtfCJLTOIyaGM3fcBbg4WeQ2taWEp+zzTaiuRiVRfdJLV++FeFvldSwH tvBsnCEI6XTL+YvSdZCVtEQRmgbElMIiaXhokMFe1JXPfDfdRL2swOGdlPy2oIHACjFa OG1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si5791555oia.219.2020.03.10.09.32.48; Tue, 10 Mar 2020 09:33:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727558AbgCJQb2 (ORCPT + 99 others); Tue, 10 Mar 2020 12:31:28 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11215 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727304AbgCJQbZ (ORCPT ); Tue, 10 Mar 2020 12:31:25 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id AB63745C71A16916A0E1; Wed, 11 Mar 2020 00:30:38 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 11 Mar 2020 00:30:30 +0800 From: John Garry To: , , , , , , CC: , , , , , , Hannes Reinecke Subject: [PATCH RFC v2 18/24] aacraid: use private commands Date: Wed, 11 Mar 2020 00:25:44 +0800 Message-ID: <1583857550-12049-19-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1583857550-12049-1-git-send-email-john.garry@huawei.com> References: <1583857550-12049-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hannes Reinecke Use private commands to allocate internal commands. Signed-off-by: Hannes Reinecke --- drivers/scsi/aacraid/aacraid.h | 6 +++-- drivers/scsi/aacraid/commsup.c | 47 ++++++++++++---------------------- drivers/scsi/aacraid/linit.c | 1 + 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index e3e4ecbea726..0bef32a62e41 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1291,13 +1291,16 @@ struct fsa_dev_info { }; struct fib { - void *next; /* this is used by the allocator */ s16 type; s16 size; /* * The Adapter that this I/O is destined for. */ struct aac_dev *dev; + /* + * The associated scsi command + */ + struct scsi_cmnd *scmd; /* * This is the event the sendfib routine will wait on if the * caller did not pass one and this is synch io. @@ -1552,7 +1555,6 @@ struct aac_dev */ struct fib *fibs; - struct fib *free_fib; spinlock_t fib_lock; struct mutex ioctl_mutex; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 5a8a999606ea..225d67b3177a 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "aacraid.h" @@ -173,7 +174,6 @@ int aac_fib_setup(struct aac_dev * dev) fibptr->dev = dev; fibptr->hw_fib_va = hw_fib; fibptr->data = (void *) fibptr->hw_fib_va->data; - fibptr->next = fibptr+1; /* Forward chain the fibs */ init_completion(&fibptr->event_wait); spin_lock_init(&fibptr->event_lock); hw_fib->header.XferState = cpu_to_le32(0xffffffff); @@ -200,14 +200,6 @@ int aac_fib_setup(struct aac_dev * dev) */ aac_fib_vector_assign(dev); - /* - * Add the fib chain to the free list - */ - dev->fibs[dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB - 1].next = NULL; - /* - * Set 8 fibs aside for management tools - */ - dev->free_fib = &dev->fibs[dev->scsi_host_ptr->can_queue]; return 0; } @@ -233,6 +225,7 @@ struct fib *aac_fib_alloc_tag(struct aac_dev *dev, struct scsi_cmnd *scmd) fibptr->callback_data = NULL; fibptr->callback = NULL; fibptr->flags = 0; + fibptr->scmd = scmd; return fibptr; } @@ -247,29 +240,19 @@ struct fib *aac_fib_alloc_tag(struct aac_dev *dev, struct scsi_cmnd *scmd) struct fib *aac_fib_alloc(struct aac_dev *dev) { - struct fib * fibptr; + struct scsi_cmnd *scmd; + struct fib * fibptr = NULL; unsigned long flags; + spin_lock_irqsave(&dev->fib_lock, flags); - fibptr = dev->free_fib; - if(!fibptr){ - spin_unlock_irqrestore(&dev->fib_lock, flags); - return fibptr; - } - dev->free_fib = fibptr->next; + scmd = scsi_get_reserved_cmd(dev->scsi_host_ptr); + if (scmd) + fibptr = aac_fib_alloc_tag(dev, scmd); spin_unlock_irqrestore(&dev->fib_lock, flags); - /* - * Set the proper node type code and node byte size - */ - fibptr->type = FSAFS_NTC_FIB_CONTEXT; + if (!fibptr) + return NULL; + fibptr->size = sizeof(struct fib); - /* - * Null out fields that depend on being zero at the start of - * each I/O - */ - fibptr->hw_fib_va->header.XferState = 0; - fibptr->flags = 0; - fibptr->callback = NULL; - fibptr->callback_data = NULL; return fibptr; } @@ -297,8 +280,12 @@ void aac_fib_free(struct fib *fibptr) (void*)fibptr, le32_to_cpu(fibptr->hw_fib_va->header.XferState)); } - fibptr->next = fibptr->dev->free_fib; - fibptr->dev->free_fib = fibptr; + if (fibptr->scmd) { + struct scsi_cmnd *scmd = fibptr->scmd; + + fibptr->scmd = NULL; + scsi_put_reserved_cmd(scmd); + } spin_unlock_irqrestore(&fibptr->dev->fib_lock, flags); } diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 0e084b09615d..f027e91656c9 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1678,6 +1678,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) shost->use_cmd_list = 1; shost->max_id = MAXIMUM_NUM_CONTAINERS; shost->max_lun = AAC_MAX_LUN; + shost->nr_reserved_cmds = AAC_NUM_MGT_FIB; shost->sg_tablesize = HBA_MAX_SG_SEPARATE; if (aac_cfg_major == AAC_CHARDEV_NEEDS_REINIT) -- 2.17.1