Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4696049ybi; Tue, 28 May 2019 00:44:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwaG+sP0y5Tx4/RHsV/hteCahnY+kinkg9DBlGYjVeaLuGIsKphHyrjMFyR36E7F81mSD2 X-Received: by 2002:a65:4084:: with SMTP id t4mr41097323pgp.224.1559029442547; Tue, 28 May 2019 00:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559029442; cv=none; d=google.com; s=arc-20160816; b=GndiucxGyQWwUoABf8P7yoJOj6XrYSvfm0qirb19AZnYuY7+W4+pzWw27UxOXAu5rF eO/zBOMFiIlFlASnc/UFz+tsaSRPq72WKg6FUG/ITzX/L9QVRUyP/dzoGFweVY973QAQ 5+rjr06+OTqwMs1cWiH+h8l0YEKRz7arlM2yjw6UWT2/Hs5r0cXn1W86MXcdZsIfSq+t oallPaAPWkGNP35e0MZr2XqXggvTZNi/no8nymklx8YFCCsXFqvl7t8HkCT1yyGc+B5d bN3DLinhqNiqnPbpt59JqOabXJiO7kTO1wZ9fURhxzavBv66YLVwbwhfHLpselJGDChz 4qDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1vGN/kzzR5Fvs1V+frWiaUjVK/pSpV0oxUQjIS8ijsM=; b=xU1txNZi3AF0ofExxHCfD3CrV+3x9BxvUAoNxY1FXOTt8Tcj076sBa9KNloZ8TS4eV tBKlbpUnMQXAjlUdl//MqP4rq79lY+rgdz3+ma4lFv0GzQRb7CGmpBjbWMlaEgRPn3zM xpn8ZrCg3eiJHZ/xUJt995w6jpdDG+AsVuEijURZSxc72gqtp871+GmTd95shHA2lL1j Uxx1x5v7/Z/S+vAuxSh/vyeN1BvBfVG5OshV0/Pye00TNULwlxLy7BlgjrtjiDe2gMUQ 1pyc17mCKuGW6fOYCrnOSR/7iNCk3koSqm0Rx7dIDOuR23bnFLLmwNEtCfm28a0nVssV qjLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G5vlq0fA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z21si20445259plo.386.2019.05.28.00.43.46; Tue, 28 May 2019 00:44:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G5vlq0fA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727498AbfE1Hlo (ORCPT + 99 others); Tue, 28 May 2019 03:41:44 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:35019 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727261AbfE1Hln (ORCPT ); Tue, 28 May 2019 03:41:43 -0400 Received: by mail-vs1-f68.google.com with SMTP id q13so12183285vso.2 for ; Tue, 28 May 2019 00:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1vGN/kzzR5Fvs1V+frWiaUjVK/pSpV0oxUQjIS8ijsM=; b=G5vlq0fAtwDVkOkfBP2QoDt1YEgVybU9XYwYxfr77EwtQYmXJtwF0Se2SLiRbWygug uweyGlm3MM63NmP5XYWc+1VIg3lu323ebw2/DD+PrGK2L/sfswbJSxYn3bR9+2N+GV6G 6p/AnLDq35nD5IMEQRiGZ8u/KM2daatFWSiTTW+GSngTXp52QXv4a5CMi4hc1VEnVJfo ynMmhOxfxGdLOBBBTkYnnuNJE5ynQcUmjA/h2bACdpqdKcXvRKmYxKZvI2E397mWj9eE nHTSH6OkcRYNz+6lSyCvTogEJ4o9LrsCqPFdZDvCssza0sBLgzG/s3H/knojtFphR3kS sxkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1vGN/kzzR5Fvs1V+frWiaUjVK/pSpV0oxUQjIS8ijsM=; b=kZGaLQw12CO2EKYqarH8erlokI2N0Jd6jkFcgc+t1ovZyzKq7O3wHY68TTKJUEMiWo y0psTqxITPoqA3hzH8LBhfk5ppFVM7z5Xsg85w02cgWXiiGjNf2scE4njBeQDJzlzvfQ IOMnTVLI+WZQKBDQNRlZ3Z8Xe5G3wxQs06iE5K4H1Ii1zX8XGi4wF8C9rs7D8pVMieGd wJrODMZUgyGo6bqkTOUOobTG+30oFkfyf0nQ3xxqg7Y71eV7PSXYPea1jUJqhgFfGHeR f18VhmKtZ81bkoBLzHllQLqQ2SM9KovItq0LuJTz367vSpuUyO8rHfFjUUD1Eqs+9N3v qyKA== X-Gm-Message-State: APjAAAVZdyliyfIznEzequ6x0Dnq36YlGizroUlHq7ETn6BW3XVcOHhU FrMJlzHxcm+1TcaKM02/Fr9tPFDVxDWnwUptpLVS1A== X-Received: by 2002:a67:ebc5:: with SMTP id y5mr71189644vso.34.1559029302928; Tue, 28 May 2019 00:41:42 -0700 (PDT) MIME-Version: 1.0 References: <20190501175457.195855-1-rrangel@chromium.org> <20190501175457.195855-2-rrangel@chromium.org> In-Reply-To: <20190501175457.195855-2-rrangel@chromium.org> From: Ulf Hansson Date: Tue, 28 May 2019 09:41:07 +0200 Message-ID: Subject: Re: [RFC PATCH 2/2] mmc: sdhci: Quirk for AMD SDHC Device 0x7906 To: Raul E Rangel Cc: "linux-mmc@vger.kernel.org" , Daniel Kurtz , Linux Kernel Mailing List , Adrian Hunter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2019 at 19:55, Raul E Rangel wrote: > > AMD SDHC 0x7906 requires a hard reset to clear all internal state. > Otherwise it can get into a bad state where the DATA lines are always > read as zeros. > > This change requires firmware that can transition the device into > D3Cold for it to work correctly. If the firmware does not support > transitioning to D3Cold then the power state transitions are a no-op. > > Signed-off-by: Raul E Rangel Does this also solve the problem you tried to fix in patch1, without patch1? Should this have a stable tag? Kind regards Uffe > --- > > drivers/mmc/host/sdhci-pci-core.c | 51 ++++++++++++++++++++++++++++++- > 1 file changed, 50 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c > index 99b0fec2836b..532fbcbd373b 100644 > --- a/drivers/mmc/host/sdhci-pci-core.c > +++ b/drivers/mmc/host/sdhci-pci-core.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1498,11 +1499,59 @@ static int amd_probe(struct sdhci_pci_chip *chip) > return 0; > } > > +static u32 sdhci_read_present_state(struct sdhci_host *host) > +{ > + return sdhci_readl(host, SDHCI_PRESENT_STATE); > +} > + > +void amd_sdhci_reset(struct sdhci_host *host, u8 mask) > +{ > + struct sdhci_pci_slot *slot = sdhci_priv(host); > + struct pci_dev *pdev = slot->chip->pdev; > + u32 present_state; > + > + /* > + * SDHC 0x7906 requires a hard reset to clear all internal state. > + * Otherwise it can get into a bad state where the DATA lines are always > + * read as zeros. > + */ > + if (pdev->device == 0x7906 && (mask & SDHCI_RESET_ALL)) { > + pci_clear_master(pdev); > + > + pci_save_state(pdev); > + > + pci_set_power_state(pdev, PCI_D3cold); > + pr_debug("%s: power_state=%u\n", mmc_hostname(host->mmc), > + pdev->current_state); > + pci_set_power_state(pdev, PCI_D0); > + > + pci_restore_state(pdev); > + > + /* > + * SDHCI_RESET_ALL says the card detect logic should not be > + * reset, but since we need to reset the entire controller > + * we should wait until the card detect logic has stabilized. > + * > + * This normally takes about 40ms. > + */ > + readx_poll_timeout( > + sdhci_read_present_state, > + host, > + present_state, > + present_state & SDHCI_CD_STABLE, > + 10000, > + 100000 > + ); > + } > + > + return sdhci_reset(host, mask); > +} > + > static const struct sdhci_ops amd_sdhci_pci_ops = { > .set_clock = sdhci_set_clock, > .enable_dma = sdhci_pci_enable_dma, > .set_bus_width = sdhci_set_bus_width, > - .reset = sdhci_reset, > + .reset = amd_sdhci_reset, > .set_uhs_signaling = sdhci_set_uhs_signaling, > }; > > -- > 2.21.0.593.g511ec345e18-goog >