From patchwork Thu May 13 08:36:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 437608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2034C433ED for ; Thu, 13 May 2021 08:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 789C0613D6 for ; Thu, 13 May 2021 08:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232029AbhEMIf1 (ORCPT ); Thu, 13 May 2021 04:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232039AbhEMIe7 (ORCPT ); Thu, 13 May 2021 04:34:59 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6E41C06138C for ; Thu, 13 May 2021 01:33:39 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id 10so21195444pfl.1 for ; Thu, 13 May 2021 01:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0nXP7UQbagatx6nK2wQt6aH25tuCzRoI5v1TJaotLy0=; b=G4MuynAcF+XKY5xJIZYdploiZPaqICHoSHuRcr3B1KXzgTbgHQRNSYo2xH9JIHpt0Z frAtnwF5Z0IZY/b2kWHTkMve95mcudth3AuqZEOjo0lMswY3qt0vuUwLbnVT4r7jRAs0 lSDFBWwaX6reRZiXM1MLo2IZpaJ8HKHpUbKSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0nXP7UQbagatx6nK2wQt6aH25tuCzRoI5v1TJaotLy0=; b=ds5FLb9CEiwdoR2b+/QNCznVCdB2qTCA1tDk7GezCn8+BaGgRK+hRGDrflbUnShmRb p/1fLXTZpBC1I2796nMCg2uz2RRmmEAWaeL5LG4MxGKLeK3LHRt2PeYAT5MYcXn1dd5y b1Pi3jEHYml7mFhOPtcoDhrXk6Bc+rAJq+rfwo11XFtLV32XVSmMlIR4BacCUjowxZTq 22kEBdc/XKiHx0HkdTKiQ+5KWayO9Lh3JBH2Dz+MrrDgeZLbpLE92w2JWklJ8J1dx6NO bgjE2dsnZaLDDJ6XZIjYBxO+gNlVhfzKDmB67dFjJONv91+hhgsRToJ8U2S1qekx4364 Iueg== X-Gm-Message-State: AOAM532PU2BbOcePrtdbPZTpsCRpV97zwFpfMTceAmfLYciCSDmMVr/z 3L2656unW9SCSBWlBYk5UTm8WFc1mXyy8lluTYA7Yd9KebNRK7f1ugVtR2bbdZ4MAeshF3B6gzh 1YnkYBIdyUalIvRWRBuy5HpRKB/nB/J7l0XAzR1d3tB2iFF9oFIGO7iUIHM+pGoa5Pr8Oa0RsVT bvdNbbSg== X-Google-Smtp-Source: ABdhPJxCJiZCmlQfofXRWu2jCttj0a66DfvoQ5n9z3UGPyQ2g2vLk6lKzLUPqddZgiT09SzmIppMIw== X-Received: by 2002:a62:6481:0:b029:249:ecee:a05d with SMTP id y123-20020a6264810000b0290249eceea05dmr39669257pfb.9.1620894818537; Thu, 13 May 2021 01:33:38 -0700 (PDT) Received: from drv-bst-rhel8.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id i123sm1632468pfc.53.2021.05.13.01.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 01:33:37 -0700 (PDT) From: Kashyap Desai To: linux-scsi@vger.kernel.org Cc: jejb@linux.ibm.com, martin.petersen@oracle.com, steve.hagan@broadcom.com, peter.rivera@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, Kashyap Desai , sathya.prakash@broadcom.com Subject: [PATCH v5 19/24] mpi3mr: print pending host ios for debug Date: Thu, 13 May 2021 14:06:03 +0530 Message-Id: <20210513083608.2243297-20-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210513083608.2243297-1-kashyap.desai@broadcom.com> References: <20210513083608.2243297-1-kashyap.desai@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Kashyap Desai Reviewed-by: Tomas Henzl Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: sathya.prakash@broadcom.com --- drivers/scsi/mpi3mr/mpi3mr_os.c | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index ad3390e02034..cca9c4e9149c 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -333,6 +333,37 @@ void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc) } } +/** + * mpi3mr_print_scmd - print individual SCSI command + * @rq: Block request + * @data: Adapter instance reference + * @reserved: N/A. Currently not used + * + * Print the SCSI command details if it is in LLD scope. + * + * Return: true always. + */ +static bool mpi3mr_print_scmd(struct request *rq, + void *data, bool reserved) +{ + struct mpi3mr_ioc *mrioc = (struct mpi3mr_ioc *)data; + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + struct scmd_priv *priv = NULL; + + if (scmd) { + priv = scsi_cmd_priv(scmd); + if (!priv->in_lld_scope) + goto out; + + ioc_info(mrioc, "%s :Host Tag = %d, qid = %d\n", + __func__, priv->host_tag, priv->req_q_idx + 1); + scsi_print_command(scmd); + } + +out: + return(true); +} + /** * mpi3mr_flush_scmd - Flush individual SCSI command * @rq: Block request @@ -2350,6 +2381,43 @@ static int mpi3mr_map_queues(struct Scsi_Host *shost) mrioc->pdev, mrioc->op_reply_q_offset); } +/** + * mpi3mr_get_fw_pending_ios - Calculate pending I/O count + * @mrioc: Adapter instance reference + * + * Calculate the pending I/Os for the controller and return. + * + * Return: Number of pending I/Os + */ +static inline int mpi3mr_get_fw_pending_ios(struct mpi3mr_ioc *mrioc) +{ + u16 i; + uint pend_ios = 0; + + for (i = 0; i < mrioc->num_op_reply_q; i++) + pend_ios += atomic_read(&mrioc->op_reply_qinfo[i].pend_ios); + return pend_ios; +} + +/** + * mpi3mr_print_pending_host_io - print pending I/Os + * @mrioc: Adapter instance reference + * + * Print number of pending I/Os and each I/O details prior to + * reset for debug purpose. + * + * Return: Nothing + */ +static void mpi3mr_print_pending_host_io(struct mpi3mr_ioc *mrioc) +{ + struct Scsi_Host *shost = mrioc->shost; + + ioc_info(mrioc, "%s :Pending commands prior to reset: %d\n", + __func__, mpi3mr_get_fw_pending_ios(mrioc)); + blk_mq_tagset_busy_iter(&shost->tag_set, + mpi3mr_print_scmd, (void *)mrioc); +} + /** * mpi3mr_eh_host_reset - Host reset error handling callback * @scmd: SCSI command reference @@ -2366,6 +2434,7 @@ static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd) struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); int retval = FAILED, ret; + mpi3mr_print_pending_host_io(mrioc); ret = mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_EH_HOS, 1); if (ret)