From patchwork Thu Oct 20 09:05:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Saxena X-Patchwork-Id: 9386363 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 D8DA9607F0 for ; Thu, 20 Oct 2016 09:05:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78DF28B5D for ; Thu, 20 Oct 2016 09:05:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC788291FE; Thu, 20 Oct 2016 09:05:59 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1406A28B5D for ; Thu, 20 Oct 2016 09:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757523AbcJTJFa (ORCPT ); Thu, 20 Oct 2016 05:05:30 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:36797 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752657AbcJTJF0 (ORCPT ); Thu, 20 Oct 2016 05:05:26 -0400 Received: by mail-pf0-f177.google.com with SMTP id e6so32842105pfk.3 for ; Thu, 20 Oct 2016 02:05:26 -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=Dc1AtIt4vOAd0qvSzXnWhvIZPXiWHYg8egw1viB+fyw=; b=V52h6bKfA2o8LM3Ob0SYJ1ONA86wxhjQmFsjqAXGgHbcu6xiEAYdHIkhj1mDY7G6cO VWpeG8OIMZ4utsU3SO5J+0YaIJzpyuhEsCX6B69QubszLaHbzfawORXIA60bwjgbtc+K PCi1OXjpsxR4Aqmfok8mPZUCOcLdOJOoBVYJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Dc1AtIt4vOAd0qvSzXnWhvIZPXiWHYg8egw1viB+fyw=; b=kIfxSXns2oRqNYdliqbZ+JKtD512d8ott8A3tySGxyqZ0Dqw87GuTanAhcOfgESbTv tXxrlCcYQW4s35MmIPOnJuhMGpxREF0j2Rlap1G4uwo1xfm7mLaz69vodL+3iCoXy3IG 7R7KT5EKdmY5/nuilHHGpqva8CWveHqfKC1EDsJMuoK8m07aAqmVvYh4LA02YxRNNdMB u6bbj5WOOOsmv4Hybvn2DEXhCW0Idc77E3rfmAh90e9RMwrJMFaKiN+HgA3UU1c32Eo7 iiE51yzonVCDUKxMYsWmPdXIoq7zM+cPYymxWZWM9av7UpideQaJsNsvQ5qwYmanM892 lhCA== X-Gm-Message-State: AA6/9RkJvF1xmeQfQdpxfuvzpVQ/2lx/TP7RSuvBAG/c6cpaejJpNzxrBV3vuuKsZam8oprS X-Received: by 10.98.25.67 with SMTP id 64mr19893353pfz.46.1476954325871; Thu, 20 Oct 2016 02:05:25 -0700 (PDT) Received: from dhcp-135-24-192-142.localdomain ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id 136sm69738199pfu.87.2016.10.20.02.05.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Oct 2016 02:05:25 -0700 (PDT) From: Sumit Saxena To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, thenzl@redhat.com, jejb@linux.vnet.ibm.com, kashyap.desai@broadcom.com, Sumit Saxena , stable@vger.kernel.org Subject: [PATCH v2 4/7] megaraid_sas: Send SYNCHRONIZE_CACHE command to firmware Date: Thu, 20 Oct 2016 02:05:02 -0700 Message-Id: <1476954305-576-5-git-send-email-sumit.saxena@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1476954305-576-1-git-send-email-sumit.saxena@broadcom.com> References: <1476954305-576-1-git-send-email-sumit.saxena@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 From previous patch we have below changes in v2 - 1. Updated change log. Provided more detail in change log. 2. Agreed to remove module parameter. If we remove module parameter, we can ask customer to disable WCE on drive to get similar impact. 3. Always Send SYNCHRONIZE_CACHE for JBOD (non Raid) Device to Firmware. Current megaraid_sas driver returns SYNCHRONIZE_CACHE(related to Drive Cache) command back to SCSI layer without sending it down to firmware as firmware supposed to take care of flushing disk cache for all drives belongs to Virtual Disk at the time of system reboot/shutdown. We evaluate and understood that for Raid Volume, why driver should not send SYNC_CACHE command to the Firmware. There may be a some reason in past, but now it looks to be not required and we have fixed this issue as part of this patch. Commit- " 02b01e0 [SCSI] megaraid_sas: return sync cache call with success" added the code in driver to return SYNCHRONIZE_CACHE without sending it to firmware back in 2007. Earlier MR was mainly for Virtual Disk, so same code continue for JBOD as well whenever JBOD support was added and it introduced bug that SYNCHRONIZE_CACHE is not passed to FW for JBOD (non Raid disk). But our recent analysis indicates that, From Day-1 MR Firmware always expect Driver to forward SYNCHRONIZE_CACHE for JBOD (non Raid disk) to the Firmware. We have fixed this as part of this patch. - Additional background - There are some instance of MegaRaid FW (E.a Gen2 and Gen2.5 FW) set WCE bit for Virtual Disk but firmware does not reply correct status for SYNCH_CACHE. It is very difficult to find out which Device ID and firmware has capability to manage SYNC_CACHE, so we managed to figure out which are the new firmware (canHandleSyncCache is set in scratch pad register at 0xB4) and use that interface for correct behavior as explained above. E.g Liberator/Thunderbolt MegaRaid FW returns SYNC_CACHE as Unsupported command (this is a firmware bug) and eventually command will be failed to SML. This will cause File system to go Read-only. - New behavior described - IF application requests SYNCH_CACHE IF 'JBOD' Driver sends SYNCH_CACHE command to the FW FW sends SYNCH_CACHE to drive FW obtains status from drive and returns same status back to driver ELSEIF 'VirtualDisk' IF any FW which supports new API bit called canHandleSyncCache Driver sends SYNCH_CACHE command to the FW FW does not send SYNCH_CACHE to drives FW returns SUCCESS ELSE Driver does not send SYNCH_CACHE command to the FW. Driver return SUCCESS for that command. ENDIF ENDIF ENDIF CC: stable@vger.kernel.org Signed-off-by: Kashyap Desai Signed-off-by: Sumit Saxena --- drivers/scsi/megaraid/megaraid_sas.h | 3 +++ drivers/scsi/megaraid/megaraid_sas_base.c | 10 ++-------- drivers/scsi/megaraid/megaraid_sas_fusion.c | 5 +++++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index ca86c88..43fd14f 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -1429,6 +1429,8 @@ enum FW_BOOT_CONTEXT { #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT 14 #define MR_MAX_MSIX_REG_ARRAY 16 #define MR_RDPQ_MODE_OFFSET 0X00800000 +#define MR_CAN_HANDLE_SYNC_CACHE_OFFSET 0X01000000 + /* * register set for both 1068 and 1078 controllers * structure extended for 1078 registers @@ -2140,6 +2142,7 @@ struct megasas_instance { u8 is_imr; u8 is_rdpq; bool dev_handle; + bool fw_sync_cache_support; }; struct MR_LD_VF_MAP { u32 size; diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 3236632..f7a2ab1 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1700,16 +1700,10 @@ inline int megasas_cmd_type(struct scsi_cmnd *cmd) goto out_done; } - switch (scmd->cmnd[0]) { - case SYNCHRONIZE_CACHE: - /* - * FW takes care of flush cache on its own - * No need to send it down - */ + if (MEGASAS_IS_LOGICAL(scmd) && (scmd->cmnd[0] == SYNCHRONIZE_CACHE) && + (!instance->fw_sync_cache_support)) { scmd->result = DID_OK << 16; goto out_done; - default: - break; } return instance->instancet->build_and_issue_cmd(instance, scmd); diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 2159f6a..2e61306 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -748,6 +748,11 @@ static int megasas_create_sg_sense_fusion(struct megasas_instance *instance) goto fail_fw_init; } + instance->fw_sync_cache_support = (scratch_pad_2 & + MR_CAN_HANDLE_SYNC_CACHE_OFFSET) ? 1 : 0; + dev_info(&instance->pdev->dev, "FW supports sync cache\t: %s\n", + instance->fw_sync_cache_support ? "Yes" : "No"); + IOCInitMessage = dma_alloc_coherent(&instance->pdev->dev, sizeof(struct MPI2_IOC_INIT_REQUEST),