From patchwork Mon Oct 1 22:58:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10622881 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0705D175A for ; Mon, 1 Oct 2018 22:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32350237F1 for ; Mon, 1 Oct 2018 22:58:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21B5F23F88; Mon, 1 Oct 2018 22:58:26 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0D6E0237F1 for ; Mon, 1 Oct 2018 22:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbeJBFia (ORCPT ); Tue, 2 Oct 2018 01:38:30 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37705 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbeJBFia (ORCPT ); Tue, 2 Oct 2018 01:38:30 -0400 Received: by mail-pf1-f194.google.com with SMTP id j23-v6so24547pfi.4 for ; Mon, 01 Oct 2018 15:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=XVGguNxmvicpsvPN9XyposHjvHXdJRHd3e9kTGdUpjY=; b=AGTK1O8AH3Uc176l48Ttdo/DKB5ks1S7TGG1YA4j+qMzd04FJhqbcUxYLCDTDZ8y3K MW9W2NM9mXXPACe3aZAQxxCiMl949ypv/w+9EjQUEGfgC41NY+9YFotzVKb9IbrK+P/U Zf9NFw0NwR/8ZoOd3j760P9XQ2jQuqyPRqW4s= 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=XVGguNxmvicpsvPN9XyposHjvHXdJRHd3e9kTGdUpjY=; b=USFh+Y8hrbamqj046cHSJnRKt/uP43nDIbqzinxdHPJhLIRIXGIgdN/+Taxgm5kFBy LDLZT5ZVdk256ioAMh5lHY0yflv4UHoYLMQb9xDqOEv3GS5FgtMWH8jgQB45+7TExVI/ Xlh9n+to8HnfwDLyOESt9W06Dh3/tXEGh2sLAVto1HIwMTNvF9WVf7/G5lVGpsw5FBT0 8zFP+BRmIavXMR9qAFxvol+HCwjqmhaVqCt0gU8ggq64JfYO9BV4GYponEzRdM8r4HWW euyi4yAukNnKdf/CIsn3DM+5ZiMDLuLP2GUlyAqrcT1A1FxDmxiFRWi3i1aGNDCNaVh6 tJqA== X-Gm-Message-State: ABuFfogGTRaeyQHT1WW3IChk23wWJyXX19C/Us9aC+jeaq6WCpRmln8T pF86NhVt3tP+ySgHloLswJI326Y14WE= X-Google-Smtp-Source: ACcGV63moVCi/iW3DSQxIXaVkr34YlUdIPrmYv40Ush9UTJxjyeOK8xXHoyekLHOp2i2qHsZOdXa2w== X-Received: by 2002:a17:902:7e0f:: with SMTP id b15-v6mr13668804plm.246.1538434702985; Mon, 01 Oct 2018 15:58:22 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id m26-v6sm20457843pfi.102.2018.10.01.15.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Oct 2018 15:58:21 -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: [RESEND][PATCH] scsi: ufs: Fix hynix ufs bug with quirk on hi36xx SoC Date: Mon, 1 Oct 2018 15:58:18 -0700 Message-Id: <1538434698-1042-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 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: 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. 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(+) 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 c55f38e..a67f298 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 };