Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp834717pxb; Tue, 3 Nov 2020 13:55:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyicG/zH/8YkK87i+wK/S9+KQgEEbOpsdzY2nF7eb2mJVMatpXR4AUdrA/NpBYvQBEnHq8t X-Received: by 2002:a50:fe18:: with SMTP id f24mr17898187edt.162.1604440525470; Tue, 03 Nov 2020 13:55:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440525; cv=none; d=google.com; s=arc-20160816; b=cXz3ce4KUxMuCxoT+FIceZElxBB+6hbdCfAFhjkIporCh7rDchJm7H61oUogBxm9mx iJjQ90ZdAh9vbMU4zE0CwepP5hMxaogQNsvBM3ESU5Xj8p8CgQVk65jyY4hQwukil5s2 cu0+IpbNV/+hDBnSVkSNSYC/LZGGF/P2wJJntv6RzpyQWBRiW0qg037TbUGBpNR1U+Yk 4hDlbE4XU4Sb3XrDik8EFmodiQ0kGRA4deP5wIxy4EkMa4aPIwn4P1VN4MbSrlaWeDBn aE+4HR6YSopzwum5EqpQhHNRdJ654+e6E9ACMBIEuDoBV2oI5uq0Hvh+uwDsvE3bH1yC aiXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sB0+Q1RxEqO02rYlpBtNYnlAj7ILzm2oE3qj/oZYFbU=; b=J2krIwCP+JftPK6trPptQ0UJl8V4lgLqe3EOURCI9kszkqnOqUVWqSraQFt8YJFtq/ TmVbaBBZFQJ/C6AZfHeutrIeQBze4vsY5tfdslrh4zX53O4rj3KT6z+1yMf4cU+RDUtU dLcO8paRvOH0dTCbw4L/2EsBArBbKslOpzF3SsAV98It4OKw6RM32nMBGqdrIbuS4qWZ D3L628ZjyaIjkyC3MnOyCCQuV+K5pKL9dROTH3ABKaWjAXbmoPTmgaONyvYqfTiz7l4y CYUOR1vBBbIA1Gv+o+ZkFnuNMXe8yjVL0oyxakIOezJSLiLUOmBwMM0xb2G2+QNItCds Q2jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBJVwjy9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o60si14175318eda.61.2020.11.03.13.55.01; Tue, 03 Nov 2020 13:55:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBJVwjy9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731191AbgKCUqX (ORCPT + 99 others); Tue, 3 Nov 2020 15:46:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:35578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731182AbgKCUqV (ORCPT ); Tue, 3 Nov 2020 15:46:21 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F2DE8206F9; Tue, 3 Nov 2020 20:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436380; bh=Tw1fXgs+U2aGtftqhsnQFWkOzgkK5wWe3iFmQRB4q+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBJVwjy9B1QyPFa1qyoGOeYjktWY2m/KFplQXBc46JLevM4nLVfodSH5Pvj+jp+1z huJt/ssZiPNVFAcF5AppQ+9vRwdh7+hZlYB6YvDxyAVPzEcVt+wJhIdW9nDqWJ6rUy 9ZKB0keVpnJP//VIjuvv3HAcATxJRoNfHWs8A0S8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Raul E Rangel , Adrian Hunter , Ulf Hansson Subject: [PATCH 5.9 187/391] mmc: sdhci-acpi: AMDI0040: Set SDHCI_QUIRK2_PRESET_VALUE_BROKEN Date: Tue, 3 Nov 2020 21:33:58 +0100 Message-Id: <20201103203359.506340102@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Raul E Rangel commit f23cc3ba491af77395cea3f9d51204398729f26b upstream. This change fixes HS400 tuning for devices with invalid presets. SDHCI presets are not currently used for eMMC HS/HS200/HS400, but are used for DDR52. The HS400 retuning sequence is: HS400->DDR52->HS->HS200->Perform Tuning->HS->HS400 This means that when HS400 tuning happens, we transition through DDR52 for a very brief period. This causes presets to be enabled unintentionally and stay enabled when transitioning back to HS200 or HS400. Some firmware has invalid presets, so we end up with driver strengths that can cause I/O problems. Fixes: 34597a3f60b1 ("mmc: sdhci-acpi: Add support for ACPI HID of AMD Controller with HS400") Signed-off-by: Raul E Rangel Acked-by: Adrian Hunter Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200928154718.1.Icc21d4b2f354e83e26e57e270dc952f5fe0b0a40@changeid Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-acpi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) --- a/drivers/mmc/host/sdhci-acpi.c +++ b/drivers/mmc/host/sdhci-acpi.c @@ -662,6 +662,43 @@ static int sdhci_acpi_emmc_amd_probe_slo (host->mmc->caps & MMC_CAP_1_8V_DDR)) host->mmc->caps2 = MMC_CAP2_HS400_1_8V; + /* + * There are two types of presets out in the wild: + * 1) Default/broken presets. + * These presets have two sets of problems: + * a) The clock divisor for SDR12, SDR25, and SDR50 is too small. + * This results in clock frequencies that are 2x higher than + * acceptable. i.e., SDR12 = 25 MHz, SDR25 = 50 MHz, SDR50 = + * 100 MHz.x + * b) The HS200 and HS400 driver strengths don't match. + * By default, the SDR104 preset register has a driver strength of + * A, but the (internal) HS400 preset register has a driver + * strength of B. As part of initializing HS400, HS200 tuning + * needs to be performed. Having different driver strengths + * between tuning and operation is wrong. It results in different + * rise/fall times that lead to incorrect sampling. + * 2) Firmware with properly initialized presets. + * These presets have proper clock divisors. i.e., SDR12 => 12MHz, + * SDR25 => 25 MHz, SDR50 => 50 MHz. Additionally the HS200 and + * HS400 preset driver strengths match. + * + * Enabling presets for HS400 doesn't work for the following reasons: + * 1) sdhci_set_ios has a hard coded list of timings that are used + * to determine if presets should be enabled. + * 2) sdhci_get_preset_value is using a non-standard register to + * read out HS400 presets. The AMD controller doesn't support this + * non-standard register. In fact, it doesn't expose the HS400 + * preset register anywhere in the SDHCI memory map. This results + * in reading a garbage value and using the wrong presets. + * + * Since HS400 and HS200 presets must be identical, we could + * instead use the the SDR104 preset register. + * + * If the above issues are resolved we could remove this quirk for + * firmware that that has valid presets (i.e., SDR12 <= 12 MHz). + */ + host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; + host->mmc_host_ops.select_drive_strength = amd_select_drive_strength; host->mmc_host_ops.set_ios = amd_set_ios; host->mmc_host_ops.execute_tuning = amd_sdhci_execute_tuning;