Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1194057ybx; Fri, 1 Nov 2019 18:21:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNdYEXyIfEyGGB1h4m0E8ykFlgA6grOLpzyxd4J6yYEQTlKyjRECcqn7U6BbF3azzajIJV X-Received: by 2002:a50:e68c:: with SMTP id z12mr15669213edm.53.1572657719442; Fri, 01 Nov 2019 18:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572657719; cv=none; d=google.com; s=arc-20160816; b=Jxq+3NaI5Snz9VV5inmHla+8gYEQpX2mFxDvHBShqCrslzS6y9GXS25AcNb+NYxnQ9 Yx/rNnDJsWYQHv6KHkcHFjfKA5NnWEC81bZzkaHgHzbI4QWNgQXECe+S5KXx2P20BMyX HNWP8VO5kjPGiiwWYkPrImk5R3GL04Sn0wrwJeo0R2R7M8st2vBXmIj2FOGpvtJfBxa/ VIXJgT06UqzAzJqqPktBjQeExXpJ1Q71+jP7kfqcqMPNwU2sB9iZV/Ps2jm0VVlrbTWq 4N7UXW9oTjaADie4oS7jkzWtjHRd6Znd8itX0dPFNfX5/5Cfy+Fsl6WdCJi1t3bif+PA D3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter; bh=pauXmu5FfQr8SbeBs+ZjlAas3RHF62ZM9inuM9WX5Y0=; b=V1P0W2wsvglGyADTYkWfK4GNN2D/Mec6NYhzwJW4GWiu4igHhcsBG2vCX4ROD6V1eV K/M8cMu9lhXe6E98EvMge7c2ELYmJswPgMFYreaDWxtihTsq5SO76gFuW/H0Sa6slfgz SKE0sqIV3EP4gaRhR+oNJX/EMfChOyyOXP+8tiFHCYZU+9AfBq5RL0vt3pGY34rJGOZt gZFQd3D92zrVPfHrXEh3ucOAAGvrL2MW1wf2aIL9Q/0jNukO/WTT/OYltr5IW1cLna/6 P88lumN+WaeyIMOUeV7hQT4y0TTRQMyxsyaoi9kLwWSpSes1sQ6JYJg2ExvnI8pYelin lK4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=qti.qualcomm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si6904120ejb.341.2019.11.01.18.21.35; Fri, 01 Nov 2019 18:21:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=qti.qualcomm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbfKBBUv (ORCPT + 99 others); Fri, 1 Nov 2019 21:20:51 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:33444 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbfKBBUu (ORCPT ); Fri, 1 Nov 2019 21:20:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5DF9B615E4; Sat, 2 Nov 2019 01:20:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E9D8861564; Sat, 2 Nov 2019 01:20:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E9D8861564 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=pass (p=none dis=none) header.from=qti.qualcomm.com Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=cang@qti.qualcomm.com From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Subhash Jadavani , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 2/5] scsi: ufs: Set DBD setting in mode sense for caching mode page Date: Fri, 1 Nov 2019 18:20:27 -0700 Message-Id: <1572657631-25749-3-git-send-email-cang@qti.qualcomm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1572657631-25749-1-git-send-email-cang@qti.qualcomm.com> References: <1572657631-25749-1-git-send-email-cang@qti.qualcomm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Can Guo Host sends MODE_SENSE_10 with caching mode page, to check if the device supports the cache feature. UFS standards requires DBD field to be set to 1. Some card vendors are more strict and check the DBD field, hence respond with CHECK_CONDITION (Sense key set to ILLEGAL_REQUEST and ASC set to INVALID FIELD IN CDB). As a result of the CHECK_CONDITION response, host assumes that the device doesn't support the cache feature and doesn't send SYNCHRONIZE_CACHE commands to flush the device cache. This can result in data corruption in case of sudden power down, when there is data stored in the device cache. This patch fixes the DBD field setting in case of caching mode page. Signed-off-by: Can Guo --- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 0026199..0a6b8f9 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8353,6 +8353,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) host->max_channel = UFSHCD_MAX_CHANNEL; host->unique_id = host->host_no; host->max_cmd_len = UFS_CDB_SIZE; + host->set_dbd_for_caching = 1; hba->max_pwr_info.is_valid = false; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project