From: Can Guo <cang@codeaurora.org> 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 <alim.akhtar@samsung.com>, Avri Altman <avri.altman@wdc.com>, Pedro Sousa <pedrom.sousa@synopsys.com>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, Stanley Chu <stanley.chu@mediatek.com>, Bean Huo <beanhuo@micron.com>, Tomas Winkler <tomas.winkler@intel.com>, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 2/5] scsi: ufs: Use DBD setting in mode sense Date: Thu, 5 Dec 2019 02:14:30 +0000 Message-ID: <0101016ed3d657e4-32a6dd52-1505-4312-97ff-2bd3bee59eb7-000000@us-west-2.amazonses.com> (raw) In-Reply-To: <1575512052-15999-1-git-send-email-cang@codeaurora.org> UFS standards requires DBD field to be set to 1 in mode sense(10). 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). When host send mode sense for page caching, 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 as required in UFS standards. Signed-off-by: Can Guo <cang@codeaurora.org> Reviewed-by: Bean Huo <beanhuo@micron.com> --- drivers/scsi/ufs/ufshcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c28c144..5484177 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4596,6 +4596,9 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) /* Mode sense(6) is not supported by UFS, so use Mode sense(10) */ sdev->use_10_for_ms = 1; + /* DBD field should be set to 1 in mode sense(10) */ + sdev->set_dbd_for_ms = 1; + /* allow SCSI layer to restart the device in case of errors */ sdev->allow_restart = 1; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
next prev parent reply index Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <1575512052-15999-1-git-send-email-cang@codeaurora.org> 2019-12-05 2:14 ` [PATCH v6 1/5] scsi: Adjust DBD setting in mode sense for caching mode page per LLD Can Guo 2019-12-05 7:10 ` Avri Altman 2019-12-05 2:14 ` Can Guo [this message] 2019-12-05 2:14 ` [PATCH v6 3/5] scsi: ufs: Release clock if DMA map fails Can Guo 2019-12-05 2:14 ` [PATCH v6 4/5] scsi: ufs: Do not clear the DL layer timers Can Guo 2019-12-05 2:14 ` [PATCH v6 5/5] scsi: ufs: Do not free irq in suspend Can Guo 2019-12-08 12:40 ` Stanley Chu
Reply instructions: You may reply publically to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=0101016ed3d657e4-32a6dd52-1505-4312-97ff-2bd3bee59eb7-000000@us-west-2.amazonses.com \ --to=cang@codeaurora.org \ --cc=alim.akhtar@samsung.com \ --cc=asutoshd@codeaurora.org \ --cc=avri.altman@wdc.com \ --cc=beanhuo@micron.com \ --cc=jejb@linux.ibm.com \ --cc=kernel-team@android.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-scsi@vger.kernel.org \ --cc=martin.petersen@oracle.com \ --cc=nguyenb@codeaurora.org \ --cc=pedrom.sousa@synopsys.com \ --cc=rnayak@codeaurora.org \ --cc=salyzyn@google.com \ --cc=saravanak@google.com \ --cc=stanley.chu@mediatek.com \ --cc=tomas.winkler@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-SCSI Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-scsi/0 linux-scsi/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-scsi linux-scsi/ https://lore.kernel.org/linux-scsi \ linux-scsi@vger.kernel.org public-inbox-index linux-scsi Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-scsi AGPL code for this site: git clone https://public-inbox.org/public-inbox.git