From patchwork Wed May 9 15:10:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 135293 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5760755lji; Wed, 9 May 2018 08:12:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr4ixnWrhws70k6dM4Pe1fcg4qRjQMnt7k0AEev8f5nnLU14N4NBK3P7asaOS5Y+r84atHZ X-Received: by 10.98.36.23 with SMTP id r23mr44075338pfj.108.1525878766938; Wed, 09 May 2018 08:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525878766; cv=none; d=google.com; s=arc-20160816; b=LAC/Uixf65MXF2OmK3z8tGswB48jdMHqYySmtm+VBLymZRro8mfsw1jdw3v5lleV0/ UWBMTk2+MgX7gNuNOMych0HD3f6DGQMLjw5WneheS3gsT0A1H6jJL1KLKbzF2/6km5Ng MPA32PnDFEnYjXOzYw2o9GU/tJpgZQDDuhAVhBkgNOlL15j0run+XnSlC24UctXakG1b Am6QjqsHpX4eVZZtfEoY2Qbi58dC/diVhD8g08mod07TwZSF+p0+ohTcDZtuhEFIG6ID ZtnrIfVUCCqMYyltwo5hRXklvVxjfKK9vXcjAatVGir7I4lX2Lb3LWkrReBmlHSdWhj7 zxJg== 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:arc-authentication-results; bh=KQ8Nla/zOST5LSr/y63tMIFf/PBskIvWnQp27X10ioc=; b=bP5PIkMjLpaFgdbMK6aawYaWHprjxxBM1kmhOyoGX4nxYPAI5T0Xh0mud58oxkZnsD MxLOxd9mwmCi7NGD+IHlOfCTja79+UPYq5ciESnRUHFICX6ufz4ZmmTqVtqeNk1cGD6O SrPXktKIpB4jjes+G60cvCOE7Qu6LlzwndRKuYiUvRCWD9yVTybOerCkNL8L5qAgO2vS 3L2Vqa4CZCJHL8KqGiBi8Eh3f8+ZaXOLoJCuhAnsdVDjjfaTMCZtHCX1fzxvEYySWC5z mRHypxDV7agHAqsk7G+Mp/eZnAxIPcI6O7dH2DlRDjxcgSi+doEovSZvVvvzW55McTyg Ywxw== 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 a21-v6si6833756pgv.668.2018.05.09.08.12.46; Wed, 09 May 2018 08:12:46 -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 S964873AbeEIPMQ (ORCPT + 29 others); Wed, 9 May 2018 11:12:16 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:47091 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S964821AbeEIPMN (ORCPT ); Wed, 9 May 2018 11:12:13 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3E3FE5BD29D76; Wed, 9 May 2018 23:12:08 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.361.1; Wed, 9 May 2018 23:12:00 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 3/6] scsi: hisi_sas: allocate slot buffer earlier Date: Wed, 9 May 2018 23:10:47 +0800 Message-ID: <1525878650-213087-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525878650-213087-1-git-send-email-john.garry@huawei.com> References: <1525878650-213087-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen Currently we allocate the slot's memory buffer after allocating the DQ slot. To aid DQ lockout reduction, and allow slots to be built in parallel, move this step (which can fail) prior to allocating the slot. Also a stray spin_unlock_irqrestore() is removed from internal task exec function. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 55 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 24 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 2772e920..58cbe1f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -412,14 +412,22 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq if (rc) goto err_out_dma_unmap; + slot = &hisi_hba->slot_info[slot_idx]; + memset(slot, 0, sizeof(struct hisi_sas_slot)); + + slot->buf = dma_pool_alloc(hisi_hba->buffer_pool, + GFP_ATOMIC, &slot->buf_dma); + if (!slot->buf) { + rc = -ENOMEM; + goto err_out_tag; + } + rc = hisi_hba->hw->get_free_slot(hisi_hba, dq); if (rc) - goto err_out_tag; + goto err_out_buf; dlvry_queue = dq->id; dlvry_queue_slot = dq->wr_point; - slot = &hisi_hba->slot_info[slot_idx]; - memset(slot, 0, sizeof(struct hisi_sas_slot)); slot->idx = slot_idx; slot->n_elem = n_elem; @@ -434,12 +442,6 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq task->lldd_task = slot; INIT_WORK(&slot->abort_slot, hisi_sas_slot_abort); - slot->buf = dma_pool_alloc(hisi_hba->buffer_pool, - GFP_ATOMIC, &slot->buf_dma); - if (!slot->buf) { - rc = -ENOMEM; - goto err_out_slot_buf; - } memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ); @@ -474,8 +476,9 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq return 0; -err_out_slot_buf: - /* Nothing to be done */ +err_out_buf: + dma_pool_free(hisi_hba->buffer_pool, slot->buf, + slot->buf_dma); err_out_tag: spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_index_free(hisi_hba, slot_idx); @@ -1519,17 +1522,26 @@ static int hisi_sas_query_task(struct sas_task *task) } spin_unlock_irqrestore(&hisi_hba->lock, flags); + slot = &hisi_hba->slot_info[slot_idx]; + memset(slot, 0, sizeof(struct hisi_sas_slot)); + + slot->buf = dma_pool_alloc(hisi_hba->buffer_pool, + GFP_ATOMIC, &slot->buf_dma); + if (!slot->buf) { + rc = -ENOMEM; + goto err_out_tag; + } spin_lock_irqsave(&dq->lock, flags_dq); rc = hisi_hba->hw->get_free_slot(hisi_hba, dq); - if (rc) - goto err_out_tag; + if (rc) { + rc = -ENOMEM; + spin_unlock_irqrestore(&dq->lock, flags_dq); + goto err_out_buf; + } dlvry_queue = dq->id; dlvry_queue_slot = dq->wr_point; - slot = &hisi_hba->slot_info[slot_idx]; - memset(slot, 0, sizeof(struct hisi_sas_slot)); - slot->idx = slot_idx; slot->n_elem = n_elem; slot->dlvry_queue = dlvry_queue; @@ -1541,13 +1553,6 @@ static int hisi_sas_query_task(struct sas_task *task) slot->is_internal = true; task->lldd_task = slot; - slot->buf = dma_pool_alloc(hisi_hba->buffer_pool, - GFP_ATOMIC, &slot->buf_dma); - if (!slot->buf) { - rc = -ENOMEM; - goto err_out_tag; - } - memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ); @@ -1570,11 +1575,13 @@ static int hisi_sas_query_task(struct sas_task *task) return 0; +err_out_buf: + dma_pool_free(hisi_hba->buffer_pool, slot->buf, + slot->buf_dma); err_out_tag: spin_lock_irqsave(&hisi_hba->lock, flags); hisi_sas_slot_index_free(hisi_hba, slot_idx); spin_unlock_irqrestore(&hisi_hba->lock, flags); - spin_unlock_irqrestore(&dq->lock, flags_dq); err_out: dev_err(dev, "internal abort task prep: failed[%d]!\n", rc);