Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp300448ybh; Wed, 11 Mar 2020 01:12:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu55f6UtU/eDS1kmO+sYN0dTqixXU03swCoD8iIn8YiA6nwOeVB1IZL/J6Ekd5g03yGXFeg X-Received: by 2002:a9d:2215:: with SMTP id o21mr1327060ota.113.1583914362154; Wed, 11 Mar 2020 01:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583914362; cv=none; d=google.com; s=arc-20160816; b=XdryRfg4d0R4HIdlXTE98xW4lcQRsM4SvsfqS6aWF+eVHKuw3b9DvECb0ERygfX7Fq 7rGg7fiPkFF0poggvJFv0U1BLUGeoVXNfRlviMyCoCMcRT+Kp42zTzGHwGxO9D4VoEHZ lV8ochA9HB81ozCbRtAlPXj76cH47cBXRjvzNH/j8ArT4D4C3yUX3116Qem2rB0LDC0T 8WBp6Pj6A6jQwBWbgyvDh50BuTMEVAywqU4BZuvxPNnI79hZwjA+8MKnwQLUopsWE9gl MNPP6QZsIc3vq3tUC7iQZRLbU3PZJFdShpFXhzyE9qtTarsRcvtVXzw5DEM89rEzjzsB t8Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mclFMWusgTyOtMcXNsfUg9sVqxkjUF7Bq9avEjcdG/I=; b=FBxc4sait+NioVicX06/GibwXSiumCVAa4jqAhZpKFiulYjpGz1PLMCTflfSIqZIV3 ZMDK/S9Bi+SOMhSdMO2hVICCHe80oRWDz2m29CdKgiUQWD0GJhNI8Hq2aNmk+UfpgpMo IocyxZppdsgsibZUaDrheBUShHF1NnZyCtsVi0CtT/XWE+lNckgFTsdv5LunfcD1Sz6e InR6FlZkCiG0IMVnae8Kc3uNhbc1N4YE6O+xG44Q2nBxZNp8iB0cd7u58UTMtKbiR2NH 28QLQO3K7v0q9R7aD4D5os9ihXR3WGKY5gWGaVcOj7nyQ20Dxj7eyFGbRojDOq0XuCdN 61Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QAlhgRn1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si722827oth.325.2020.03.11.01.12.28; Wed, 11 Mar 2020 01:12:42 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QAlhgRn1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728245AbgCKIL2 (ORCPT + 99 others); Wed, 11 Mar 2020 04:11:28 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46615 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726198AbgCKIL1 (ORCPT ); Wed, 11 Mar 2020 04:11:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583914286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mclFMWusgTyOtMcXNsfUg9sVqxkjUF7Bq9avEjcdG/I=; b=QAlhgRn1m8LI6avl4qT+oMSftsWS8txCzkBiOOX9P4bxj7lOg2NvyhRyp5+CkM2POdcAbb PaWTtlAuTqiYCbSRXMC7FJM/2ZtY2py59elONVcQvS/FBp+sFYQ01DvK7VRKIshBZmiid+ eVMNJtUTVqD/1ofeVovtPQPahQJ8o4c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-sWznBkZzPgyeEBOnUFWxYg-1; Wed, 11 Mar 2020 04:11:22 -0400 X-MC-Unique: sWznBkZzPgyeEBOnUFWxYg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 980BC107ACC4; Wed, 11 Mar 2020 08:11:20 +0000 (UTC) Received: from ming.t460p (ovpn-8-26.pek2.redhat.com [10.72.8.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1E6610372C5; Wed, 11 Mar 2020 08:11:06 +0000 (UTC) Date: Wed, 11 Mar 2020 16:10:59 +0800 From: Ming Lei To: John Garry Cc: axboe@kernel.dk, jejb@linux.ibm.com, martin.petersen@oracle.com, hare@suse.de, bvanassche@acm.org, hch@infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, virtualization@lists.linux-foundation.org, esc.storagedev@microsemi.com, chenxiang66@hisilicon.com, Hannes Reinecke Subject: Re: [PATCH RFC v2 12/24] hpsa: use reserved commands Message-ID: <20200311081059.GC31504@ming.t460p> References: <1583857550-12049-1-git-send-email-john.garry@huawei.com> <1583857550-12049-13-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1583857550-12049-13-git-send-email-john.garry@huawei.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 12:25:38AM +0800, John Garry wrote: > From: Hannes Reinecke > > Enable the use of reserved commands, and drop the hand-crafted > command allocation. > > Signed-off-by: Hannes Reinecke > --- > drivers/scsi/hpsa.c | 147 ++++++++++++++------------------------------ > drivers/scsi/hpsa.h | 1 - > 2 files changed, 45 insertions(+), 103 deletions(-) > > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c > index 703f824584fe..c14dd4b6e598 100644 > --- a/drivers/scsi/hpsa.c > +++ b/drivers/scsi/hpsa.c > @@ -244,10 +244,6 @@ static struct hpsa_scsi_dev_t > *hpsa_find_device_by_sas_rphy(struct ctlr_info *h, > struct sas_rphy *rphy); > > -#define SCSI_CMD_BUSY ((struct scsi_cmnd *)&hpsa_cmd_busy) > -static const struct scsi_cmnd hpsa_cmd_busy; > -#define SCSI_CMD_IDLE ((struct scsi_cmnd *)&hpsa_cmd_idle) > -static const struct scsi_cmnd hpsa_cmd_idle; > static int number_of_controllers; > > static irqreturn_t do_hpsa_intr_intx(int irq, void *dev_id); > @@ -342,7 +338,7 @@ static inline struct ctlr_info *shost_to_hba(struct Scsi_Host *sh) > > static inline bool hpsa_is_cmd_idle(struct CommandList *c) > { > - return c->scsi_cmd == SCSI_CMD_IDLE; > + return c->scsi_cmd == NULL; > } > > /* extract sense key, asc, and ascq from sense data. -1 means invalid. */ > @@ -2445,7 +2441,12 @@ static void hpsa_cmd_resolve_events(struct ctlr_info *h, > * this command has completed. Then, check to see if the handler is > * waiting for this command, and, if so, wake it. > */ > - c->scsi_cmd = SCSI_CMD_IDLE; > + if (c->scsi_cmd && c->cmd_type == CMD_IOCTL_PEND) { > + struct scsi_cmnd *scmd = c->scsi_cmd; > + > + scsi_put_reserved_cmd(scmd); > + } > + c->scsi_cmd = NULL; > mb(); /* Declare command idle before checking for pending events. */ > if (dev) { > atomic_dec(&dev->commands_outstanding); > @@ -5502,7 +5503,6 @@ static void hpsa_cmd_init(struct ctlr_info *h, int index, > c->ErrDesc.Addr = cpu_to_le64((u64) err_dma_handle); > c->ErrDesc.Len = cpu_to_le32((u32) sizeof(*c->err_info)); > c->h = h; > - c->scsi_cmd = SCSI_CMD_IDLE; > } > > static void hpsa_preinitialize_commands(struct ctlr_info *h) > @@ -5803,6 +5803,7 @@ static int hpsa_scsi_host_alloc(struct ctlr_info *h) > sh->max_lun = HPSA_MAX_LUN; > sh->max_id = HPSA_MAX_LUN; > sh->can_queue = h->nr_cmds - HPSA_NRESERVED_CMDS; > + sh->nr_reserved_cmds = HPSA_NRESERVED_CMDS; Now .nr_reserved_cmds has been passed to blk-mq, you need to increase sh->can_queue to h->nr_cmds, because .can_queue is the whole queue depth (include the part of reserved tags), otherwise, IO tags will be decreased. Not look into other drivers, I guess they need such change too. Thanks, Ming