From patchwork Mon Jun 4 10:45:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10446319 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 DC932600CA for ; Mon, 4 Jun 2018 10:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB3AB2876C for ; Mon, 4 Jun 2018 10:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFB3628BFD; Mon, 4 Jun 2018 10:45:44 +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 07BF12876C for ; Mon, 4 Jun 2018 10:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752261AbeFDKpl (ORCPT ); Mon, 4 Jun 2018 06:45:41 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34163 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752235AbeFDKpi (ORCPT ); Mon, 4 Jun 2018 06:45:38 -0400 Received: by mail-qt0-f194.google.com with SMTP id d3-v6so5404414qto.1 for ; Mon, 04 Jun 2018 03:45:38 -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=2jgxp2K4CLXPQSb4GXP6CT4fCF4vBP5pv5GPkRYuNXY=; b=ePkesumBnR06hPPP6ch1C13vMKJDmqd7gNs+MK7XveWDc38FRAiBRk19hOaUxg+Mrz vvTXcF7x7TO54wZtWT6ijA2pTCE+0+TVov+vNumswy++pM+RQykMIkQKt7JwYMk/NfYQ 5AiJ3K958rd3R8305pgxnQezEZ2WsquXrKoBk= 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=2jgxp2K4CLXPQSb4GXP6CT4fCF4vBP5pv5GPkRYuNXY=; b=Rz98kILw+gYpQ+AQB1CfUfPgPtoTJcq/4KTSEJmVWvmHzF3Gbyf3xJHgM4Z0aSQrzc ku97k39GF+Ec2g2tsksQ9yzrZYxKPkkVGg4Rt8xGFQwrK9J9amhVFAXckhfnvXBg/Nqf IH6lPE+Q00X6nM8XYrKuJBkWV6ggMoLlJYE8UQpoeIvBiSHn+qP4D/9OiMVsgz9dgedv b4aoY5KadtXsaHpUzM8apW9ttPnqqFDv7Bu0GEbkTo3ii/6PttlevkZSG1ITby77ugbm ODhQHjp+cJwygoo5eJ43UjXJoYFReEsYrghuYn+ESaarxELkIttKEhd5nrHOEe0B4h22 gWjA== X-Gm-Message-State: APt69E3DrlSfi+zX6yS1yQHRM6EPSAh1itCDz4HsgNuGBaS5mwm67SSr vO+2vNzA1x9fAwEYcbOb2nnoe/0k X-Google-Smtp-Source: ADUXVKKdkprpYZuEGrxFpcuC4jPu6zDaGgwE9gNMW0BbcfoVNgWIOX7/RlfTjCKkce8B2yl7WI3Zgg== X-Received: by 2002:a0c:a4c4:: with SMTP id x62-v6mr14018916qvx.37.1528109137534; Mon, 04 Jun 2018 03:45:37 -0700 (PDT) Received: from dhcp-135-24-192-142.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id n21-v6sm7660500qtc.38.2018.06.04.03.45.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 03:45:36 -0700 (PDT) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Shivasharan S Subject: [PATCH 4/5] megaraid_sas: Support FW provided TM timeout values Date: Mon, 4 Jun 2018 03:45:12 -0700 Message-Id: <1528109113-1512-5-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1528109113-1512-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1528109113-1512-1-git-send-email-shivasharan.srikanteshwara@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 Firmware provides drive specific target reset and task abort timeout values. Driver needs to use these timeout values during task management calls. If FW does not provide these values, fall back to using earlier default timeout of 50seconds for TM. Signed-off-by: Sumit Saxena Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas.h | 29 ++++++++++++++++++++--- drivers/scsi/megaraid/megaraid_sas_base.c | 36 +++++++++++++++++++++++------ drivers/scsi/megaraid/megaraid_sas_fusion.c | 36 +++++++++++++++++++++++------ 3 files changed, 84 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 75dc25f78336..c199070f04b4 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -709,7 +709,8 @@ struct MR_TARGET_PROPERTIES { u32 max_io_size_kb; u32 device_qdepth; u32 sector_size; - u8 reserved[500]; + u8 reset_tmo; + u8 reserved[499]; } __packed; /* @@ -1400,6 +1401,19 @@ struct megasas_ctrl_info { #endif } adapter_operations4; u8 pad[0x800 - 0x7FE]; /* 0x7FE pad to 2K for expansion */ + + u32 size; + u32 pad1; + + u8 reserved6[64]; + + u32 rsvdForAdptOp[64]; + + u8 reserved7[3]; + + u8 TaskAbortTO; /* Timeout value in seconds used by Abort Task TM */ + u8 MaxResetTO; /* Max Supported Reset timeout in seconds. */ + u8 reserved8[3]; } __packed; /* @@ -1472,6 +1486,7 @@ enum FW_BOOT_CONTEXT { #define MEGASAS_DEFAULT_CMD_TIMEOUT 90 #define MEGASAS_THROTTLE_QUEUE_DEPTH 16 #define MEGASAS_BLOCKED_CMD_TIMEOUT 60 +#define MEGASAS_DEFAULT_TM_TIMEOUT 50 /* * FW reports the maximum of number of commands that it can accept (maximum * commands that can be outstanding) at any time. The driver must report a @@ -1915,7 +1930,9 @@ struct MR_PRIV_DEVICE { bool is_tm_capable; bool tm_busy; atomic_t r1_ldio_hint; - u8 interface_type; + u8 interface_type; + u8 task_abort_tmo; + u8 target_reset_tmo; }; struct megasas_cmd; @@ -2291,6 +2308,8 @@ struct megasas_instance { u8 adapter_type; bool consistent_mask_64bit; bool support_nvme_passthru; + u8 task_abort_tmo; + u8 max_reset_tmo; }; struct MR_LD_VF_MAP { u32 size; @@ -2512,7 +2531,11 @@ int megasas_get_ctrl_info(struct megasas_instance *instance); /* PD sequence */ int megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend); -void megasas_set_dynamic_target_properties(struct scsi_device *sdev); +void megasas_set_dynamic_target_properties(struct scsi_device *sdev, + bool is_target_prop); +int megasas_get_target_prop(struct megasas_instance *instance, + struct scsi_device *sdev); + int megasas_set_crash_dump_params(struct megasas_instance *instance, u8 crash_buf_state); void megasas_free_host_crash_buffer(struct megasas_instance *instance); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 165d8f6c50d5..198bff0c118d 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -120,8 +120,7 @@ static int megasas_register_aen(struct megasas_instance *instance, u32 seq_num, u32 class_locale_word); static void megasas_get_pd_info(struct megasas_instance *instance, struct scsi_device *sdev); -static int megasas_get_target_prop(struct megasas_instance *instance, - struct scsi_device *sdev); + /* * PCI ID table for all supported controllers */ @@ -1794,7 +1793,8 @@ static struct megasas_instance *megasas_lookup_instance(u16 host_no) * * Returns void */ -void megasas_set_dynamic_target_properties(struct scsi_device *sdev) +void megasas_set_dynamic_target_properties(struct scsi_device *sdev, + bool is_target_prop) { u16 pd_index = 0, ld; u32 device_id; @@ -1834,6 +1834,22 @@ void megasas_set_dynamic_target_properties(struct scsi_device *sdev) mr_device_priv_data->is_tm_capable = pd_sync->seq[pd_index].capability.tmCapable; } + + if (is_target_prop && instance->tgt_prop->reset_tmo) { + /* + * If FW provides target reset timeout value, driver will use + * the same. If not set, fallback to default values. + */ + mr_device_priv_data->target_reset_tmo = + min_t(u8, instance->max_reset_tmo, + instance->tgt_prop->reset_tmo); + mr_device_priv_data->task_abort_tmo = instance->task_abort_tmo; + } else { + mr_device_priv_data->target_reset_tmo = + MEGASAS_DEFAULT_TM_TIMEOUT; + mr_device_priv_data->task_abort_tmo = + MEGASAS_DEFAULT_TM_TIMEOUT; + } } /* @@ -1967,10 +1983,10 @@ static int megasas_slave_configure(struct scsi_device *sdev) is_target_prop = (ret_target_prop == DCMD_SUCCESS) ? true : false; megasas_set_static_target_properties(sdev, is_target_prop); - mutex_unlock(&instance->reset_mutex); - /* This sdev property may change post OCR */ - megasas_set_dynamic_target_properties(sdev); + megasas_set_dynamic_target_properties(sdev, is_target_prop); + + mutex_unlock(&instance->reset_mutex); return 0; } @@ -4720,6 +4736,8 @@ megasas_get_ctrl_info(struct megasas_instance *instance) ci->adapter_operations4.support_pd_map_target_id; instance->support_nvme_passthru = ci->adapter_operations4.support_nvme_passthru; + instance->task_abort_tmo = ci->TaskAbortTO; + instance->max_reset_tmo = ci->MaxResetTO; /*Check whether controller is iMR or MR */ instance->is_imr = (ci->memory_size ? 0 : 1); @@ -4738,6 +4756,10 @@ megasas_get_ctrl_info(struct megasas_instance *instance) instance->secure_jbod_support ? "Yes" : "No"); dev_info(&instance->pdev->dev, "NVMe passthru support\t: %s\n", instance->support_nvme_passthru ? "Yes" : "No"); + dev_info(&instance->pdev->dev, + "FW provided TM TaskAbort/Reset timeout\t: %d secs/%d secs\n", + instance->task_abort_tmo, instance->max_reset_tmo); + break; case DCMD_TIMEOUT: @@ -5832,7 +5854,7 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num, * * Returns 0 on success non-zero on failure. */ -static int +int megasas_get_target_prop(struct megasas_instance *instance, struct scsi_device *sdev) { diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 358d42df22e1..51e476b2677f 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -4108,7 +4108,8 @@ megasas_tm_response_code(struct megasas_instance *instance, */ static int megasas_issue_tm(struct megasas_instance *instance, u16 device_handle, - uint channel, uint id, u16 smid_task, u8 type) + uint channel, uint id, u16 smid_task, u8 type, + struct MR_PRIV_DEVICE *mr_device_priv_data) { struct MR_TASK_MANAGE_REQUEST *mr_request; struct MPI2_SCSI_TASK_MANAGE_REQUEST *mpi_request; @@ -4119,6 +4120,7 @@ megasas_issue_tm(struct megasas_instance *instance, u16 device_handle, struct fusion_context *fusion = NULL; struct megasas_cmd_fusion *scsi_lookup; int rc; + int timeout = MEGASAS_DEFAULT_TM_TIMEOUT; struct MPI2_SCSI_TASK_MANAGE_REPLY *mpi_reply; fusion = instance->ctrl_context; @@ -4170,7 +4172,16 @@ megasas_issue_tm(struct megasas_instance *instance, u16 device_handle, init_completion(&cmd_fusion->done); megasas_fire_cmd_fusion(instance, req_desc); - timeleft = wait_for_completion_timeout(&cmd_fusion->done, 50 * HZ); + switch (type) { + case MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK: + timeout = mr_device_priv_data->task_abort_tmo; + break; + case MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET: + timeout = mr_device_priv_data->target_reset_tmo; + break; + } + + timeleft = wait_for_completion_timeout(&cmd_fusion->done, timeout * HZ); if (!timeleft) { dev_err(&instance->pdev->dev, @@ -4363,7 +4374,8 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd) mr_device_priv_data->tm_busy = 1; ret = megasas_issue_tm(instance, devhandle, scmd->device->channel, scmd->device->id, smid, - MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK); + MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, + mr_device_priv_data); mr_device_priv_data->tm_busy = 0; mutex_unlock(&instance->reset_mutex); @@ -4435,7 +4447,8 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd) mr_device_priv_data->tm_busy = 1; ret = megasas_issue_tm(instance, devhandle, scmd->device->channel, scmd->device->id, 0, - MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET); + MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, + mr_device_priv_data); mr_device_priv_data->tm_busy = 0; mutex_unlock(&instance->reset_mutex); out: @@ -4490,6 +4503,8 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) u32 io_timeout_in_crash_mode = 0; struct scsi_cmnd *scmd_local = NULL; struct scsi_device *sdev; + int ret_target_prop = DCMD_FAILED; + bool is_target_prop = false; instance = (struct megasas_instance *)shost->hostdata; fusion = instance->ctrl_context; @@ -4661,9 +4676,6 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) megasas_setup_jbod_map(instance); - shost_for_each_device(sdev, shost) - megasas_set_dynamic_target_properties(sdev); - /* reset stream detection array */ if (instance->adapter_type == VENTURA_SERIES) { for (j = 0; j < MAX_LOGICAL_DRIVES_EXT; ++j) { @@ -4677,6 +4689,16 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); instance->instancet->enable_intr(instance); + + shost_for_each_device(sdev, shost) { + if ((instance->tgt_prop) && + (instance->nvme_page_size)) + ret_target_prop = megasas_get_target_prop(instance, sdev); + + is_target_prop = (ret_target_prop == DCMD_SUCCESS) ? true : false; + megasas_set_dynamic_target_properties(sdev, is_target_prop); + } + atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); dev_info(&instance->pdev->dev, "Interrupts are enabled and"