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: 10601991 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 D09A91750 for ; Mon, 17 Sep 2018 01:44:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF05429077 for ; Mon, 17 Sep 2018 01:44:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0E4D29114; Mon, 17 Sep 2018 01:44:36 +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 1EFD929077 for ; Mon, 17 Sep 2018 01:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727564AbeIQHJg (ORCPT ); Mon, 17 Sep 2018 03:09:36 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35975 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbeIQHJg (ORCPT ); Mon, 17 Sep 2018 03:09:36 -0400 Received: by mail-pg1-f194.google.com with SMTP id d1-v6so6871974pgo.3 for ; Sun, 16 Sep 2018 18:44:34 -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=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=DOf78f31nomJYw8bkIN9WbU2eslXS2CVAY1z0fXSxqo/5ngHce5624nXNKDs+K9JfE cpWeUOITCKLutcnaEI5/6Ma097cbgHko/rPEoqRMg6HWOdUM/ZctxJQ8cZboD8WHQdJb I4Vw1o46DwMbaSKzLrRAr+BKCYOQVzdopk6cu6c6gPMMb9nY6LXPrws8U+/2o+CNv1E6 rT40kFTTLy5gBHY4O0WiPRhhHSvRwYSrqjrF4hdscH67YN07wnUO9z9bT359wK7hlk// 2WtRi2F3qK33gX0nqzTWx9934o30zVhLw7Xvk4OKM3YUwktz61Vnlg+DlSCWwOf8qoUW /RQg== X-Gm-Message-State: APzg51BTPk/XYvpblijTnkwwA/lxbvnGsgnMRfmcBu+f/HMLoKVcGWqU QPbh80pSckBHin6g/xedAZeMaQ== 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) 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 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. 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(+) 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 };