From patchwork Thu Nov 8 17:08:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 150538 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1076642ljp; Thu, 8 Nov 2018 09:08:35 -0800 (PST) X-Received: by 2002:a62:2643:: with SMTP id m64-v6mr5278841pfm.74.1541696915715; Thu, 08 Nov 2018 09:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541696915; cv=none; d=google.com; s=arc-20160816; b=LaFjCdmAywCmAEP7I7SGmdGPHSTM/00S+NORTf0qYtlgp/Bl9pyvpFTsoJ5wGnx0GM o8Ze4tA9DL5gznbV+q7GqJ3SJri/FbbJGCpMhaxHTQeeo1rZk0Hu3UbY5QZmWP0SF9XE IU+Jrh+NviTBDY4xHdRUHuusVtpxZYH+CcC0E3izGTXqaYMFBRD2WOGrXe+cmv8vIUQA CKN4rUmmduuJffjyKC4xHVZiorY3kKP/HvCm8l9bMsd9b9mAe+TI6jBghujg6NWYGthN I0o3W+Wo0adeAbLHskdsq3IPAQ+9uru3GDsQABGdQzphOQPFxCmMSR4sqqncHtV5sc7q ZEuA== 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=A9/0kpOkbUFX6Cs4ROIwbJe6H8AsAc8U63ivXKgPQgs=; b=yq0+H5f7ahM4fZaGeAzJSN1elhOzp+oWJ1BfIOQK1tNbtOauug9hdqGh4LVlvwQ7tj EeGClpay3B9bCR4W6Z7UtTROKqSkiLJKEUEYyKygWjiaXWNqEYfzhqLVpjIBgCEfUdg3 4MN0Mw8a8J5KONN4emJqziHjluZeegiKK+/X+l3YkFfnHfDAIGd4SYAS9SptzKZtwXVh +5gZdMx9BB98nzoylfAsNac+1NFBggOwcZR2Ddyi4n4tmDYk2i6Mtx+IDLgXiPJYYmg8 RyIRWuDMB6Dp418JUyp/wYYJJWXTAuNNk2MOkRYc+5HITjjZAPFoiILLIXajokNSQ3Kk E3LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=buNmfCEh; 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 63-v6sor5710238pft.65.2018.11.08.09.08.35 for (Google Transport Security); Thu, 08 Nov 2018 09:08:35 -0800 (PST) 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=buNmfCEh; 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=A9/0kpOkbUFX6Cs4ROIwbJe6H8AsAc8U63ivXKgPQgs=; b=buNmfCEh3PM2toAPVWAiYB4BadC2IIXG3TEfFRkQueEi4CG5vjInU2IY7aw2M12JoY yUiBEkMcZCyz1hPxpxyMUwpe7rpH0izeauucNSsYMQ3P6pK57yUKgeNb58UHZ84+Col3 FpLoz7Go3sz49DnYoHBCVGJ3cRlI3eCWNh2sU= 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=A9/0kpOkbUFX6Cs4ROIwbJe6H8AsAc8U63ivXKgPQgs=; b=NcjDqLDaQtHovH39xgxUBS+tBRNmYJdIXluyf5jBP3GMTp06/8tcjAvxy6jh1S0WwB /1qqxZb24MoFB2jxnVtPdwK65AQqtUP9jYLbShw17hkBBiO3sgx5XeNptyrRuU8e7D34 FNK/qQpemu9JvxCiKJR/RV89oB/UHYwgMNI2tdy3F28hzIoKFbZDZRkcvh3BKoEQYxSx 9X/lNA4Ff+BrHmAxng97QSs4Iy4owNktRHj0cAwRzKKh2UB4ke6yyfqLByx8xU3PwKiV RvF6aibSSvhhkRWmsx+eikOkCQrKsKaKRCP8In/YOIBxlUWNea9LqNPYmK+N9/Lpninl jiAA== X-Gm-Message-State: AGRZ1gIolZiKqZKUCA1cw+fbGwEIoWH0z0hn6UrBDbqjdafVus9rJ0+A N9ZI+0gudajCkXjrXY3GK7OdTIvo X-Google-Smtp-Source: AJdET5czrxPZpCQU0tWB0hs1DV0tm9Z/7P9qS4q36EG58ZF52vEsRqH98vOJ/f4FCttoYg2DiBMbfA== X-Received: by 2002:a62:6143:: with SMTP id v64-v6mr5391265pfb.125.1541696914909; Thu, 08 Nov 2018 09:08:34 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id u9-v6sm4102228pfm.175.2018.11.08.09.08.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 09:08:34 -0800 (PST) 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: [RESEND][PATCH v3] scsi: ufs: Fix hynix ufs bug with quirk on hi36xx SoC Date: Thu, 8 Nov 2018 09:08:29 -0800 Message-Id: <1541696909-31620-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. This patch is necessary to boot on HiKey960 boards that use Hynix UFS chips (H28U62301AMR model: hB8aL1). 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 --- v2: * Narrowed the UFS chip model to the specific model where the issue has been seen. (SKhynix H28U62301AMR model: hB8aL1) * Reworked logic to be contained in ufs-hisi.c since it seems to be a controller issue that crops up with this specific chip v3: * Reworked back to using generic hba quriks which we then key on in the hisi driver. --- 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 23d7cca..ce2b4df 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -231,6 +231,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, "hB8aL1" /*H28U62301AMR*/, + UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME), END_FIX };