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: 10674713 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 31ABB14E2 for ; Thu, 8 Nov 2018 17:08:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18B452D6E3 for ; Thu, 8 Nov 2018 17:08:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C5542D884; Thu, 8 Nov 2018 17:08:37 +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 948F32D6E3 for ; Thu, 8 Nov 2018 17:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726914AbeKICpB (ORCPT ); Thu, 8 Nov 2018 21:45:01 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38115 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726801AbeKICpB (ORCPT ); Thu, 8 Nov 2018 21:45:01 -0500 Received: by mail-pf1-f194.google.com with SMTP id b11-v6so9580287pfi.5 for ; Thu, 08 Nov 2018 09:08:35 -0800 (PST) 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=POu+VY+zF0yl0H1POEHpZT6OxY7aDFo/F9B5D8yFoM2xk3t/PwrPqxinuXa3jvUwMt elRVquhvl/lNHOaUuj8Zf9EyREJ6uhR3gOAfBo6Fly0ceYqVitpaaWgZeXib5tGmnHSt K2iGjQtIXILXPGX84BnZSCcl3lrLEmVUPEjHwMHC+lCC+F9RAJDRneVWfqa5EyJ4QY5c 5uhTKijbROTPkB47KlWWUTf+3N8ceNojAkFERMTq8cdpp8F9aBM+fmME5UPR9EKfT4id WqvEITwo1i7zKyjWcxCx50eRGwjH79sQJrQmLHYqDMJ/t0hA7A+SIMBTJ4vSvMIB0/se eGWw== X-Gm-Message-State: AGRZ1gKLZmETCyMZcFwFzxMMB9+qSY9NPZ7B4lTMc71omdEyA3lMu1sG 55kDZLdc4MJ7KuMTpBpQbqcnjg== 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) 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 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 (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(+) 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 };