From patchwork Thu May 31 10:34:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitra P B X-Patchwork-Id: 10440673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 230B7603B5 for ; Thu, 31 May 2018 10:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15DEB2921A for ; Thu, 31 May 2018 10:35:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A9ED2922D; Thu, 31 May 2018 10:35:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 535342921A for ; Thu, 31 May 2018 10:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754524AbeEaKfY (ORCPT ); Thu, 31 May 2018 06:35:24 -0400 Received: from mail-qk0-f181.google.com ([209.85.220.181]:37119 "EHLO mail-qk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754522AbeEaKfV (ORCPT ); Thu, 31 May 2018 06:35:21 -0400 Received: by mail-qk0-f181.google.com with SMTP id j12-v6so13457785qkk.4 for ; Thu, 31 May 2018 03:35:21 -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=xG4zA1fSAfUSZp0SIHz8r5NQ4gkxd9NoELzZ5OlafX0=; b=QuRh7CqR+2lkix8Nt+o2t8IyOdnHoKBWrbtErWesb2Y50YpIVZj3Fjed+DoackWLtJ 61FX4k+MfKkeXWOg4K/wnBmatAcJ6tJOOt4sevAt03QGoChClqfbYdIrnV7eyV2HoiFi JHcBkasL7Ad6asCBbQcJE7bN0tNvBERruLCv4= 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=xG4zA1fSAfUSZp0SIHz8r5NQ4gkxd9NoELzZ5OlafX0=; b=ML4Lly0guz1ao92ebVbQfvXtSsikUmoc90PIvRzCJIXub9NQTPWfIhgX5Pex8QdfKM 0c5no0V9ao29tUsB14Ck6/eoCgHN48SN+T/AknJYk35AqNVKsw4bX8qu4mpACPuU67S/ Sxj3fmejphv3vytXoaa0bAzAtlqzil2KxzLhxU4fUw66xMXrvLVsA1lcXqmeRk8spXc7 ncp41Wuej0WbXuVH+W7d4e6DSdDYikQP10PPOQyx3Cft9ycN58MTY+BTup4sOWZeq/nH WQdCOvSosY+iQ5s+azXGoslnLP4PWUAzQHqrG0mP9bf0BieeJkHvJuXji/78TlR8Q+a/ MPww== X-Gm-Message-State: APt69E0t3gWlVRwKahi13ekccxak+voPiHq3U9OykuHlmaViBC5ibfXR bNWlCmC12AFRGZLcaLCRFlQVxETayDM= X-Google-Smtp-Source: ADUXVKKVm1WE6A7Wm13rcfx1vYgzpgFN3LNNo8gI7i34zgPDlxTSEYsj+T+FrkpNzH/0NDgnAXiFpA== X-Received: by 2002:a37:28c4:: with SMTP id o65-v6mr5727061qko.200.1527762920064; Thu, 31 May 2018 03:35:20 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id n79-v6sm12661343qkn.84.2018.05.31.03.35.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 03:35:19 -0700 (PDT) From: Chaitra P B To: linux-scsi@vger.kernel.org Cc: sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Chaitra P B Subject: [PATCH 4/6] mpt3sas: Fix, False timeout prints for ioctl and other internal commands during controller reset. Date: Thu, 31 May 2018 06:34:50 -0400 Message-Id: <1527762892-3204-5-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527762892-3204-1-git-send-email-chaitra.basappa@broadcom.com> References: <1527762892-3204-1-git-send-email-chaitra.basappa@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When an ioctl is sent to FW and if there is a controller reset issued before ioctl gets completed, then in controller reset path all the pending ioctl commands are terminated from "mpt3sas_ctl_reset_handler" function. And this will wake up the waiting ioctl commands in ioctl path and prints timeout which is actually not a timeout. Introduced "mpt3sas_base_check_cmd_timeout" function to check and print whether command got timed out (or) terminated due to Host reset. Signed-off-by: Chaitra P B --- drivers/scsi/mpt3sas/mpt3sas_base.c | 52 +++++++++++++++++++++++++---------- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 ++ drivers/scsi/mpt3sas/mpt3sas_config.c | 7 ++--- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 38 ++++++++++--------------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 16 +++++------ 5 files changed, 65 insertions(+), 50 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index bf04fa9..cef480a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -102,6 +102,34 @@ static int _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc); /** + * mpt3sas_base_check_cmd_timeout - Function + * to check timeout and command termination due + * to Host reset. + * + * @ioc: per adapter object. + * @status: Status of issued command. + * @mpi_request:mf request pointer. + * @sz: size of buffer. + * + * @Returns - 1/0 Reset to be done or Not + */ +u8 +mpt3sas_base_check_cmd_timeout(struct MPT3SAS_ADAPTER *ioc, + u8 status, void *mpi_request, int sz) +{ + u8 issue_reset = 0; + + if (!(status & MPT3_CMD_RESET)) + issue_reset = 1; + + pr_err(MPT3SAS_FMT "Command %s\n", ioc->name, + ((issue_reset == 0) ? "terminated due to Host Reset" : "Timeout")); + _debug_dump_mf(mpi_request, sz); + + return issue_reset; +} + +/** * _scsih_set_fwfault_debug - global setting of ioc->fwfault_debug. * */ @@ -5354,7 +5382,7 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, { u16 smid; u32 ioc_state; - bool issue_reset = false; + u8 issue_reset = 0; int rc; void *request; u16 wait_state_count; @@ -5413,12 +5441,10 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, ioc->ioc_link_reset_in_progress) ioc->ioc_link_reset_in_progress = 0; if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", - ioc->name, __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2SasIoUnitControlRequest_t)/4); - if (!(ioc->base_cmds.status & MPT3_CMD_RESET)) - issue_reset = true; + issue_reset = + mpt3sas_base_check_cmd_timeout(ioc, + ioc->base_cmds.status, mpi_request, + sizeof(Mpi2SasIoUnitControlRequest_t)/4); goto issue_host_reset; } if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID) @@ -5456,7 +5482,7 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, { u16 smid; u32 ioc_state; - bool issue_reset = false; + u8 issue_reset = 0; int rc; void *request; u16 wait_state_count; @@ -5509,12 +5535,10 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, wait_for_completion_timeout(&ioc->base_cmds.done, msecs_to_jiffies(10000)); if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", - ioc->name, __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2SepRequest_t)/4); - if (!(ioc->base_cmds.status & MPT3_CMD_RESET)) - issue_reset = false; + issue_reset = + mpt3sas_base_check_cmd_timeout(ioc, + ioc->base_cmds.status, mpi_request, + sizeof(Mpi2SepRequest_t)/4); goto issue_host_reset; } if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index f02974c..ec222ad 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1482,6 +1482,8 @@ int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc); void mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc); +u8 mpt3sas_base_check_cmd_timeout(struct MPT3SAS_ADAPTER *ioc, + u8 status, void *mpi_request, int sz); /* scsih shared API */ struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc, diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c b/drivers/scsi/mpt3sas/mpt3sas_config.c index e87c76a..0d87e7b 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_config.c +++ b/drivers/scsi/mpt3sas/mpt3sas_config.c @@ -406,10 +406,9 @@ _config_request(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigRequest_t mpt3sas_base_put_smid_default(ioc, smid); wait_for_completion_timeout(&ioc->config_cmds.done, timeout*HZ); if (!(ioc->config_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", - ioc->name, __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2ConfigRequest_t)/4); + mpt3sas_base_check_cmd_timeout(ioc, + ioc->config_cmds.status, mpi_request, + sizeof(Mpi2ConfigRequest_t)/4); retry_count++; if (ioc->config_cmds.smid == smid) mpt3sas_base_free_smid(ioc, smid); diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 3269ef4..1005249 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -995,11 +995,10 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, ioc->ignore_loginfos = 0; } if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", ioc->name, - __func__); - _debug_dump_mf(mpi_request, karg.data_sge_offset); - if (!(ioc->ctl_cmds.status & MPT3_CMD_RESET)) - issue_reset = 1; + issue_reset = + mpt3sas_base_check_cmd_timeout(ioc, + ioc->ctl_cmds.status, mpi_request, + karg.data_sge_offset); goto issue_host_reset; } @@ -1621,12 +1620,10 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, MPT3_IOCTL_DEFAULT_TIMEOUT*HZ); if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", ioc->name, - __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2DiagBufferPostRequest_t)/4); - if (!(ioc->ctl_cmds.status & MPT3_CMD_RESET)) - issue_reset = 1; + issue_reset = + mpt3sas_base_check_cmd_timeout(ioc, + ioc->ctl_cmds.status, mpi_request, + sizeof(Mpi2DiagBufferPostRequest_t)/4); goto issue_host_reset; } @@ -1968,12 +1965,9 @@ mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type, MPT3_IOCTL_DEFAULT_TIMEOUT*HZ); if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", ioc->name, - __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2DiagReleaseRequest_t)/4); - if (!(ioc->ctl_cmds.status & MPT3_CMD_RESET)) - *issue_reset = 1; + *issue_reset = mpt3sas_base_check_cmd_timeout(ioc, + ioc->ctl_cmds.status, mpi_request, + sizeof(Mpi2DiagReleaseRequest_t)/4); rc = -EFAULT; goto out; } @@ -2235,12 +2229,10 @@ _ctl_diag_read_buffer(struct MPT3SAS_ADAPTER *ioc, void __user *arg) MPT3_IOCTL_DEFAULT_TIMEOUT*HZ); if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", ioc->name, - __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2DiagBufferPostRequest_t)/4); - if (!(ioc->ctl_cmds.status & MPT3_CMD_RESET)) - issue_reset = 1; + issue_reset = + mpt3sas_base_check_cmd_timeout(ioc, + ioc->ctl_cmds.status, mpi_request, + sizeof(Mpi2DiagBufferPostRequest_t)/4); goto issue_host_reset; } diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index bf57827..23902ad 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2709,11 +2709,9 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, u64 lun, mpt3sas_base_put_smid_hi_priority(ioc, smid, msix_task); wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); if (!(ioc->tm_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", - ioc->name, __func__); - _debug_dump_mf(mpi_request, - sizeof(Mpi2SCSITaskManagementRequest_t)/4); - if (!(ioc->tm_cmds.status & MPT3_CMD_RESET)) { + if (mpt3sas_base_check_cmd_timeout(ioc, + ioc->tm_cmds.status, mpi_request, + sizeof(Mpi2SCSITaskManagementRequest_t)/4)) { rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); rc = (!rc) ? SUCCESS : FAILED; @@ -7741,10 +7739,10 @@ _scsih_ir_fastpath(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phys_disk_num) wait_for_completion_timeout(&ioc->scsih_cmds.done, 10*HZ); if (!(ioc->scsih_cmds.status & MPT3_CMD_COMPLETE)) { - pr_err(MPT3SAS_FMT "%s: timeout\n", - ioc->name, __func__); - if (!(ioc->scsih_cmds.status & MPT3_CMD_RESET)) - issue_reset = 1; + issue_reset = + mpt3sas_base_check_cmd_timeout(ioc, + ioc->scsih_cmds.status, mpi_request, + sizeof(Mpi2RaidActionRequest_t)/4); rc = -EFAULT; goto out; }