From patchwork Tue Oct 23 00:31:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10652637 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 AC78814DE for ; Tue, 23 Oct 2018 00:32:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0057328F70 for ; Tue, 23 Oct 2018 00:32:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E43EF28F98; Tue, 23 Oct 2018 00:32:01 +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 CC64A28F70 for ; Tue, 23 Oct 2018 00:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbeJWIwu (ORCPT ); Tue, 23 Oct 2018 04:52:50 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45444 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbeJWIwu (ORCPT ); Tue, 23 Oct 2018 04:52:50 -0400 Received: by mail-pg1-f195.google.com with SMTP id s3-v6so6578888pga.12 for ; Mon, 22 Oct 2018 17:31:59 -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=6mjVJo8FQcNol+fIkwm+4i7sGlA8vnjlD8h3YNdJi64=; b=fewIorW0Ov/kbOpQIkLdcGkZw7y7mdYJzNhY/t7ZdWFWu+KsdULeF6ilNeVOg0oyja VCVUTiZKNybVzcsIbVQqSeK+bNsaiKjEvDlj3NL7SoAoFbOufe2QQCpG8KMCdVnjSnru GX4BU3l9vx0HXg0iTRRBnmqvHPIK7pfhgV81I= 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=6mjVJo8FQcNol+fIkwm+4i7sGlA8vnjlD8h3YNdJi64=; b=abA5iaFATM41lKjVMnZZ8UYmjnTj1XhYna+tFXcUqARGbOE0F2u88OkIXK6kunhEWe qXGlzVym7B6yRcl9mBDwhGHGVSbI8TK3raMG1AIRqMGSJFdsv+UtJkiTPjKDYTLZaXH+ BAVKkNUkFZj8Kr7POtW0jjzGYUTpHsBGjNN9wiQwOb3NAATPWOYKslilxy0GDetvJKoq 0e35vAYpXnpjDWMr2l3tQ3YcYIt6nVddSQLSrMt1bD81mqL7DuKcyXUs7BeNSJVDWc1n hk7LDyQnnjCSIn4YWknPrluzmdYw4d4msl6859YS17i+ly/DpOrBn1wRoczE82fWECbb Hcng== X-Gm-Message-State: ABuFfojcNSG7UaGQljPKZKoTpLzHKVIs3496VdiyahP4yrtgoxamwXbq 2K7w88d44E8HACLkrDLdoRPBwEWR7U4= X-Google-Smtp-Source: ACcGV61KsQH5Xg3EV6JtvK5EHUcafvjxZIzb3suedZb6sjWMQenRnjxsHj8ssIko4qyLNrx+1wAu3Q== X-Received: by 2002:a62:11cb:: with SMTP id 72-v6mr47220418pfr.120.1540254718925; Mon, 22 Oct 2018 17:31:58 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id j188-v6sm48787664pfg.132.2018.10.22.17.31.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 17:31:57 -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 v2] scsi: ufs: Fix hynix ufs bug with quirk on hi36xx SoC Date: Mon, 22 Oct 2018 17:31:50 -0700 Message-Id: <1540254710-26936-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). Not sure if this is the preferred way of scoping the quirk to the controller or not. 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 --- 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 --- drivers/scsi/ufs/ufs-hisi.c | 14 ++++++++++++++ drivers/scsi/ufs/ufshcd.c | 2 +- drivers/scsi/ufs/ufshcd.h | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c index 46df707..a306acf 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,19 @@ 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) { + struct ufs_dev_desc card = {0}; + + if (!ufs_get_device_desc(hba, &card)) { + if ((card.wmanufacturerid == UFS_VENDOR_SKHYNIX) && + (STR_PRFX_EQUAL("hB8aL1" /*H28U62301AMR*/, card.model))) { + pr_info("Hynix 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/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c55f38e..326fa32 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6242,7 +6242,7 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) return ret; } -static int ufs_get_device_desc(struct ufs_hba *hba, +int ufs_get_device_desc(struct ufs_hba *hba, struct ufs_dev_desc *dev_desc) { int err; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 33fdd3f..31c0562 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -877,6 +877,8 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, u8 param_offset, u8 *param_read_buf, u8 param_size); +int ufs_get_device_desc(struct ufs_hba *hba, + struct ufs_dev_desc *dev_desc); int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, u32 *attr_val); int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,