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: 149407 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp52491ljp; Mon, 22 Oct 2018 17:31:59 -0700 (PDT) X-Received: by 2002:a62:460c:: with SMTP id t12-v6mr41048645pfa.206.1540254719758; Mon, 22 Oct 2018 17:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540254719; cv=none; d=google.com; s=arc-20160816; b=Np5tAMFY2ChwvUkjIWZi91K9Y2qyhU3iGgZYSaZEtoWvZBJ97hNRD2ECM+DtJr3WRr LGxIeW+aMKQ1AnfcycPXRA/9ESXHpb7WcuRQMOzD6qogt2TLda5TuVwlDJB6EvJshTXz hM9gwI5J46xnO8XBoGqi5kcf2GMtui0BhMe9T4No9EjlEKJmLh9kSmxwOoCrko0E5I3b syEWMLGDzp8k6O0JwuTtLA3Cl+yEcOe9RUHNE1Hx4Yh3Q9SekPUmQ/EpAn0r+pit//XR PETsrYPUHrfnfdIqa0v4hxdCXuVr+We/DABCCZQnGvnMdqFWenD3r8ut1wD8h50nYOUX gVNQ== 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=6mjVJo8FQcNol+fIkwm+4i7sGlA8vnjlD8h3YNdJi64=; b=NxOMPAHQ++MCbj6zJuf1ozttlH3/c1pPSXgv4L1+sJb4haoW+xszDa0szI6J1AkQnt r9Ud2BiK3Fmo6YtVKecki6wOmST8wmVmsPFPB5/TZ4PLjmHsGEQXDeZan17GUxWcIbHy jQTNx4BODSmKEFRPY94glvRkjsxNinSuaA02SsgEVYqSDh/keTAffqkXziooRJVngoRV r8pBoqSgzGl7cdAX08LxbPOFiSKQxy12QNyG/lESgdQ7fB12BRuVtp1L7qWxFY628oVv BTi7NTs03SQnm4Gl89KEtz3qQWjqQzl2CaQNhl8Vcjl0PPfIueO3ODp+iqkIKtteC6VD tspw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fewIorW0; 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 s11-v6sor23260288pfh.10.2018.10.22.17.31.59 for (Google Transport Security); Mon, 22 Oct 2018 17:31:59 -0700 (PDT) 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=fewIorW0; 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=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=OXiwG93y94riPDw/pHLJfpUo4q0OCGJMUKYQHScffN0DrsBMBM7iNyA/57TH7N4H7c ZqKe1GYE7DsFbiVNX5O7KOskrcnx7UWXwkLbxZWIlN4PLAE7O34y2NzafClen+kanPGw gWQdvN7uwUJZxk7YpdpNyNdfUVUHaKaLqOJVt6m8symmQmjsYzMs3WS2SvmD1gfyU7L/ WGVn765Mz312nEHzSBnnBA2iuhx11YdNifyIHzmzY/XUUPCnH/AqP1bqVSqdD1900CgE 6Ac2reK7U5rLWTP45+1uEYf1n7LxrPnOSHY7LnJDk04+vk1W1FgzJnJzWH1DdPp/S+3R 9ogw== X-Gm-Message-State: ABuFfogSH+ADq7ew+NsmTRbifUqOiJxZM63Y8vmU9/IzJp9eegDrL9sA XkShAfqBGyR1yMduIt1ZxPSj4+zQ 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) Return-Path: 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 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(-) -- 2.7.4 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,