From patchwork Mon Oct 2 15:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 729632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1E1CE784BE for ; Mon, 2 Oct 2023 15:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238294AbjJBPuG (ORCPT ); Mon, 2 Oct 2023 11:50:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238217AbjJBPtn (ORCPT ); Mon, 2 Oct 2023 11:49:43 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A1FFDA for ; Mon, 2 Oct 2023 08:49:36 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E058221874; Mon, 2 Oct 2023 15:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696261770; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8SwG8QCunhR0mxEOuxNo60h3dMxbKO08hi0dtIPNBUk=; b=TFMJepLe6n+fP+hfF5tfDi1q0LwrOxzYKz92v00UeTcxrKwMmkk/Hsp+qappHke/ijbL2Q oY9/05qpv/xq2PlizLt5b82d8bhk1ymIpmjyVU8b5PkQm0xeqqTbEAoIY4DXSOA6QE0kdx hDgVlmYHZvjI+6D7m9ZGR+Gt5tG8B10= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696261770; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8SwG8QCunhR0mxEOuxNo60h3dMxbKO08hi0dtIPNBUk=; b=RH/OUa42Rer0idTD92FsZtxQrM2BkbHEmFQlTfD5Vtc9PJuHrm15lbwkqwXmIfS+gTQ7SQ TfxSCBTht70zzTBg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id C13B72C15A; Mon, 2 Oct 2023 15:49:30 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id D846251E7571; Mon, 2 Oct 2023 17:49:30 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: James Bottomley , linux-scsi@vger.kernel.org, Christoph Hellwig , Hannes Reinecke Subject: [PATCH 10/15] snic: reserve tag for TMF Date: Mon, 2 Oct 2023 17:49:22 +0200 Message-Id: <20231002154927.68643-11-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231002154927.68643-1-hare@suse.de> References: <20231002154927.68643-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Rework the hba reset function to not rely on scsi commands and reserve one command for HBA reset. Signed-off-by: Hannes Reinecke --- drivers/scsi/snic/snic.h | 2 +- drivers/scsi/snic/snic_main.c | 5 ++- drivers/scsi/snic/snic_scsi.c | 82 ++++++++--------------------------- 3 files changed, 21 insertions(+), 68 deletions(-) diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h index 32f5a34b6987..0b7411624bcf 100644 --- a/drivers/scsi/snic/snic.h +++ b/drivers/scsi/snic/snic.h @@ -366,7 +366,7 @@ int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int snic_abort_cmd(struct scsi_cmnd *); int snic_device_reset(struct scsi_cmnd *); int snic_host_reset(struct scsi_cmnd *); -int snic_reset(struct Scsi_Host *, struct scsi_cmnd *); +int snic_reset(struct Scsi_Host *); void snic_shutdown_scsi_cleanup(struct snic *); diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c index cc824dcfe7da..9bee91eedc10 100644 --- a/drivers/scsi/snic/snic_main.c +++ b/drivers/scsi/snic/snic_main.c @@ -494,9 +494,10 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Configure Maximum Outstanding IO reqs */ max_ios = snic->config.io_throttle_count; if (max_ios != SNIC_UCSM_DFLT_THROTTLE_CNT_BLD) - shost->can_queue = min_t(u32, SNIC_MAX_IO_REQ, + max_ios = min_t(u32, SNIC_MAX_IO_REQ, max_t(u32, SNIC_MIN_IO_REQ, max_ios)); - + /* Reserve one tag for HBA reset */ + shost->can_queue = max_ios - 1; snic->max_tag_id = shost->can_queue; shost->max_lun = snic->config.luns_per_tgt; diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index c50ede326cc4..f1ef781df837 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -952,13 +952,13 @@ snic_itmf_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) static void -snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc) +snic_hba_reset_scsi_cleanup(struct snic *snic) { struct snic_stats *st = &snic->s_stats; long act_ios = 0, act_fwreqs = 0; SNIC_SCSI_DBG(snic->shost, "HBA Reset scsi cleanup.\n"); - snic_scsi_cleanup(snic, snic_cmd_tag(sc)); + snic_scsi_cleanup(snic, snic->max_tag_id); /* Update stats on pending IOs */ act_ios = atomic64_read(&st->io.active); @@ -984,7 +984,6 @@ snic_hba_reset_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) u32 hid; u8 typ; u8 hdr_stat; - struct scsi_cmnd *sc = NULL; struct snic_req_info *rqi = NULL; spinlock_t *io_lock = NULL; unsigned long flags, gflags; @@ -999,18 +998,9 @@ snic_hba_reset_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) "reset_cmpl: type = %x, hdr_stat = %x, cmnd_id = %x, hid = %x, ctx = %lx\n", typ, hdr_stat, cmnd_id, hid, ctx); - /* spl case, host reset issued through ioctl */ - if (cmnd_id == SCSI_NO_TAG) { - rqi = (struct snic_req_info *) ctx; - SNIC_HOST_INFO(snic->shost, - "reset_cmpl:Tag %d ctx %lx cmpl stat %s\n", - cmnd_id, ctx, snic_io_status_to_str(hdr_stat)); - sc = rqi->sc; - - goto ioctl_hba_rst; - } + rqi = (struct snic_req_info *) ctx; - if (cmnd_id >= snic->max_tag_id) { + if (cmnd_id != snic->max_tag_id) { SNIC_HOST_ERR(snic->shost, "reset_cmpl: Tag 0x%x out of Range,HdrStat %s\n", cmnd_id, snic_io_status_to_str(hdr_stat)); @@ -1019,55 +1009,35 @@ snic_hba_reset_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) return 1; } - sc = scsi_host_find_tag(snic->shost, cmnd_id); -ioctl_hba_rst: - if (!sc) { - atomic64_inc(&snic->s_stats.io.sc_null); - SNIC_HOST_ERR(snic->shost, - "reset_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n", - snic_io_status_to_str(hdr_stat), cmnd_id); - ret = 1; - - return ret; - } - SNIC_HOST_INFO(snic->shost, - "reset_cmpl: sc %p rqi %p Tag %d flags 0x%llx\n", - sc, rqi, cmnd_id, CMD_FLAGS(sc)); + "reset_cmpl: rqi %p Tag %d\n", rqi, cmnd_id); - io_lock = snic_io_lock_hash(snic, sc); + io_lock = snic_io_lock_tag(snic, cmnd_id); spin_lock_irqsave(io_lock, flags); if (!snic->remove_wait) { spin_unlock_irqrestore(io_lock, flags); SNIC_HOST_ERR(snic->shost, "reset_cmpl:host reset completed after timeout\n"); - ret = 1; - - return ret; + return 1; } - rqi = (struct snic_req_info *) CMD_SP(sc); WARN_ON_ONCE(!rqi); if (!rqi) { atomic64_inc(&snic->s_stats.io.req_null); spin_unlock_irqrestore(io_lock, flags); - CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; SNIC_HOST_ERR(snic->shost, - "reset_cmpl: rqi is null,Hdr stat %s Tag 0x%x sc 0x%p flags 0x%llx\n", - snic_io_status_to_str(hdr_stat), cmnd_id, sc, - CMD_FLAGS(sc)); - - ret = 1; + "reset_cmpl: rqi is null,Hdr stat %s Tag 0x%x\n", + snic_io_status_to_str(hdr_stat), cmnd_id); - return ret; + return 1; } /* stats */ spin_unlock_irqrestore(io_lock, flags); /* scsi cleanup */ - snic_hba_reset_scsi_cleanup(snic, sc); + snic_hba_reset_scsi_cleanup(snic); SNIC_BUG_ON(snic_get_state(snic) != SNIC_OFFLINE && snic_get_state(snic) != SNIC_FWRESET); @@ -2203,7 +2173,7 @@ snic_device_reset(struct scsi_cmnd *sc) * snic_issue_hba_reset : Queues FW Reset Request. */ static int -snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) +snic_issue_hba_reset(struct snic *snic) { struct snic_req_info *rqi = NULL; struct snic_host_req *req = NULL; @@ -2219,26 +2189,15 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) goto hba_rst_end; } - if (snic_cmd_tag(sc) == SCSI_NO_TAG) { - memset(scsi_cmd_priv(sc), 0, - sizeof(struct snic_internal_io_state)); - SNIC_HOST_INFO(snic->shost, "issu_hr:Host reset thru ioctl.\n"); - rqi->sc = sc; - } - req = rqi_to_req(rqi); - io_lock = snic_io_lock_hash(snic, sc); + io_lock = snic_io_lock_tag(snic, snic->max_tag_id); spin_lock_irqsave(io_lock, flags); - SNIC_BUG_ON(CMD_SP(sc) != NULL); - CMD_STATE(sc) = SNIC_IOREQ_PENDING; - CMD_SP(sc) = (char *) rqi; - CMD_FLAGS(sc) |= SNIC_IO_INITIALIZED; snic->remove_wait = &wait; spin_unlock_irqrestore(io_lock, flags); /* Initialize Request */ - snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc), + snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic->max_tag_id, snic->config.hid, 0, (ulong) rqi); req->u.reset.flags = 0; @@ -2252,9 +2211,6 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) goto hba_rst_err; } - spin_lock_irqsave(io_lock, flags); - CMD_FLAGS(sc) |= SNIC_HOST_RESET_ISSUED; - spin_unlock_irqrestore(io_lock, flags); atomic64_inc(&snic->s_stats.reset.hba_resets); SNIC_HOST_INFO(snic->shost, "Queued HBA Reset Successfully.\n"); @@ -2270,8 +2226,6 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) spin_lock_irqsave(io_lock, flags); snic->remove_wait = NULL; - rqi = (struct snic_req_info *) CMD_SP(sc); - CMD_SP(sc) = NULL; spin_unlock_irqrestore(io_lock, flags); if (rqi) @@ -2284,8 +2238,6 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) hba_rst_err: spin_lock_irqsave(io_lock, flags); snic->remove_wait = NULL; - rqi = (struct snic_req_info *) CMD_SP(sc); - CMD_SP(sc) = NULL; spin_unlock_irqrestore(io_lock, flags); if (rqi) @@ -2300,7 +2252,7 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) } /* end of snic_issue_hba_reset */ int -snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) +snic_reset(struct Scsi_Host *shost) { struct snic *snic = shost_priv(shost); enum snic_state sv_state; @@ -2329,7 +2281,7 @@ snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) while (atomic_read(&snic->ios_inflight)) schedule_timeout(msecs_to_jiffies(1)); - ret = snic_issue_hba_reset(snic, sc); + ret = snic_issue_hba_reset(snic); if (ret) { SNIC_HOST_ERR(shost, "reset:Host Reset Failed w/ err %d.\n", @@ -2368,7 +2320,7 @@ snic_host_reset(struct scsi_cmnd *sc) sc, sc->cmnd[0], scsi_cmd_to_rq(sc), snic_cmd_tag(sc), CMD_FLAGS(sc)); - ret = snic_reset(shost, sc); + ret = snic_reset(shost); SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc, jiffies_to_msecs(jiffies - start_time),