From patchwork Mon Sep 17 01:44:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 146819 Delivered-To: patches@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3224547ljw; Sun, 16 Sep 2018 18:44:35 -0700 (PDT) X-Received: by 2002:a17:902:a9ca:: with SMTP id b10-v6mr22270466plr.198.1537148674919; Sun, 16 Sep 2018 18:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537148674; cv=none; d=google.com; s=arc-20160816; b=Bx6dr+Q20tdXZRqowIMlpTKudSTAk1NTFztYSpH9yFtQa7UuJEK4to3HH9kTjfIhVY 5eH9/21Tp84T45UFNJA4S1SNUAyXPjJJkDy2HE1cFMViikivRobkoChh64Xaz01P9vWQ UZnXAGi38LR7Aos3Y5cW3vue+LiryuWWURrT+EHSXREQY5ZadaQQNg84jbhVJ+3cEGMm z1IhPavykPgYrDyU5s4AQEbV6QqQKtHJyhzzTExY/TwRcvEcY/hIT0LBsKIcQOOX03P5 Cej9tgIJDY7qJxPoeNLX5VULZnp0XSf2ItO/qGKpKRUAGsayXPl7NGOCuwQ6d7LDfTUo 2Gcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=3Za/D6q5EE8j4Je9C2TsJ4Mq0pq4Urup0pyYfH1BTl4=; b=hnb4sFPsQVm/jNkKhz0ZkCs5RVwaTCxdGBN1dTy3iIwDcQmP94A1Ybji9EyCVPto25 hzT7L9KeTl1qboz1nVQk8bb1KHOJxjz6G1DKCpgY2dZb5en7fUXyuBeEG3mp/3loyguM eqjEVqgoqh/A2jUvMtiLz44UAdyEGye2ossXa4dcAKx7vVzSocvnRV9pxvZlMOXXdlKg +yp67kQ6GSC3jPTqLTxiNykd+rwiBIitVkWdUijxVYPsOMXXMjftNpSXiAiEMqSmaKJ5 LIFLt/76gJ3I6rUbl849TDuV494tQiyaky92n6CmipnRltKUJ+VDiN0hQBfsP7gKov3s CWyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdRnIwwK; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q22-v6sor1431054pgj.353.2018.09.16.18.44.34 for (Google Transport Security); Sun, 16 Sep 2018 18:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdRnIwwK; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3Za/D6q5EE8j4Je9C2TsJ4Mq0pq4Urup0pyYfH1BTl4=; b=EdRnIwwKuB78Br0QgzgmjIXcBp0LliB+RoEH9RgvdoT5KWM90yfcBkXDYNb1ALSKmJ aHdgbmCdSYmI+qu1cPFHoxipEuNTTwQ0kmvdfuxh+SN+TTlRTK/9FhUGNugwD/kTue5B FC3/0i7srADRGP+fZSRrMSql+rFwSHlJRUcy4= 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; bh=3Za/D6q5EE8j4Je9C2TsJ4Mq0pq4Urup0pyYfH1BTl4=; b=Fz0yWT5TmPp5243GyAW3PIPeqA7jB85kIlUvu4q0zmI8iV9/rFzzGj6gNFGxxJzeRG d+kTopAHG7BMEVvMMU5WNTLlSqgr65/9fPW/Sx1W22dWjxR5z3NYuc/Khk0N5mHe7Cr/ 1Cxc3Sg9gGCDQuFXqFT2AaKul5f9B1Mv/5r70N4xn4xCIOKhb6hwZZBwCZXvSIZ+HcFN REzc72vcyw6L+Ui7jI3qquKfvdd8eQGKlm/Ddrj1T4KyfewsebT4VCYOz2mKNMom0wBL 6qfdpCbYNTrb2G30yGyR6WLu3CGknRhiabiM87oDiu8dDpjKR1kOxjONFh/qHLUy39be 8gvA== X-Gm-Message-State: APzg51CsPV0O+5x9KO0/YFAI+jWFUho1F9gmpt78HruOOHqkjSCbePBy gq4dfS3CWUzMQJdn9Qeism9qZ+tdnKZvdA== X-Google-Smtp-Source: ANB0VdbRpZj4Aw4nJZ2TDbdhiANHiiMoHo97L82V2KePw9saPMd614GwDsO+sIP3D+vpbdKC9updvw== X-Received: by 2002:a63:bd41:: with SMTP id d1-v6mr21588431pgp.309.1537148674258; Sun, 16 Sep 2018 18:44:34 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id p19-v6sm25606256pgh.60.2018.09.16.18.44.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Sep 2018 18:44:33 -0700 (PDT) From: John Stultz To: lkml Cc: Wei Li , Vinayak Holikatti , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Dmitry Shmidt , John Stultz Subject: [RFC][PATCH] scsi: ufs: Fix hynix ufs bug with quirk on hi36xx SoC Date: Sun, 16 Sep 2018 18:44:25 -0700 Message-Id: <1537148665-30592-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 From: Wei Li Hynix ufs has deviations on hi36xx platform which will result in ufs bursts transfer failures. To fix the problem, the Hynix device must set the register VS_DebugSaveConfigTime to 0x10, which will set time reference for SaveConfigTime is 250 ns. The time reference for SaveConfigTime is 40 ns by default. Feedback would be greatly appreciated! Cc: Vinayak Holikatti Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Signed-off-by: Wei Li Signed-off-by: Dmitry Shmidt [jstultz: Forward ported from older code, slight tweak to commit message] Signed-off-by: John Stultz --- drivers/scsi/ufs/ufs-hisi.c | 9 +++++++++ drivers/scsi/ufs/ufs_quirks.h | 6 ++++++ drivers/scsi/ufs/ufshcd.c | 2 ++ 3 files changed, 17 insertions(+) -- 2.7.4 diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c index 46df707..452e19f 100644 --- a/drivers/scsi/ufs/ufs-hisi.c +++ b/drivers/scsi/ufs/ufs-hisi.c @@ -20,6 +20,7 @@ #include "unipro.h" #include "ufs-hisi.h" #include "ufshci.h" +#include "ufs_quirks.h" static int ufs_hisi_check_hibern8(struct ufs_hba *hba) { @@ -390,6 +391,14 @@ static void ufs_hisi_set_dev_cap(struct ufs_hisi_dev_params *hisi_param) static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba) { + if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME) { + pr_info("ufs flash device must set VS_DebugSaveConfigTime 0x10\n"); + /* VS_DebugSaveConfigTime */ + ufshcd_dme_set(hba, UIC_ARG_MIB(0xD0A0), 0x10); + /* sync length */ + ufshcd_dme_set(hba, UIC_ARG_MIB(0x1556), 0x48); + } + /* update */ ufshcd_dme_set(hba, UIC_ARG_MIB(0x15A8), 0x1); /* PA_TxSkip */ diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index 71f73d1..5d2dfdb 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -131,4 +131,10 @@ struct ufs_dev_fix { */ #define UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME (1 << 8) +/* + * Some UFS devices require VS_DebugSaveConfigTime is 0x10, + * enabling this quirk ensure this. + */ +#define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME (1 << 9) + #endif /* UFS_QUIRKS_H_ */ diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9d5d2ca..3389e36 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -230,6 +230,8 @@ static struct ufs_dev_fix ufs_fixups[] = { UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL, UFS_DEVICE_NO_VCCQ), UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL, UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME), + UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL, + UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME), END_FIX };