Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4648262ybi; Mon, 3 Jun 2019 14:44:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyphxzN6vbEl8FgVL5JZ2Xoxv67fcCn0lzoaj0rgYzFp6ZYlr+EHQyvcMtpv3OMqzOKa8U4 X-Received: by 2002:a63:ee0a:: with SMTP id e10mr12717050pgi.28.1559598241711; Mon, 03 Jun 2019 14:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559598241; cv=none; d=google.com; s=arc-20160816; b=B8FXeMvjXM+OIi5yScMqX0O0AqFF7URNEAOSsOvv+RrTmVzPKKGRQzUrUVkUY0z/Dk K/Hlon74w0sIGqiRhuLNnjatKh+b9C+fS2JgFsgYkp3T0HFEgm+Bi9SlvOw4qCeD0NHm DJ9hcqlvZPNa+GqhmQSV7e/DntdoKLOI5cX+PCRMwh2QkG0gXA9DXi4u0lPiDrv67U1Y /NDhooKLtW7IPLj3K7PdxdqwfPGt0KvHvOPTjkpIx+c/WOYBv5taVqyki+EQ1SvGgVfG MMsRmL45C0kmNbKhoAKI7heFqOqkFd1G1KDkyYNLRAqMa4WLRihvV1+MKtxhwS5W4g1M n+mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=05jpxIqovpSHGISvkH2VBhPPry9q9KrYsniszI/AFeQ=; b=lkwrCeA+4oCWzAa4UPhDQDJMKvA+vwpQ353PPuAt7SX3r1/9rXUmeENC2ygC7oLyoj sJPFapNu9VpGDD9v6gPlCXM9jnVaeFFGKH0E+YohfKMcFV6B1M9pv4qfF7wSvFUx4iMI I3nVkHbkBAIBWpOtnnKv5GqkFlPwvLw2/GcBARN6ZMR7HjeZTQcQ4XzlC3azMinPtAhj F8f9Fi4yU19f4UokUs4VHdcXnciT8D3BO4s1CZNzarErd1jKg+ZSZ0x17ug3wDup3zFK tVsNONHx5gVLzCWPb/O3b3c4smwc5AsPWDcQwy8SaOiScsGHhW5MgoviUj6sU1FcK4Db l2Zw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si18680244pgu.3.2019.06.03.14.42.58; Mon, 03 Jun 2019 14:44:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfFCUeP (ORCPT + 99 others); Mon, 3 Jun 2019 16:34:15 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:46589 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbfFCUeP (ORCPT ); Mon, 3 Jun 2019 16:34:15 -0400 Received: by mail-io1-f68.google.com with SMTP id i10so5561942iol.13 for ; Mon, 03 Jun 2019 13:34:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=05jpxIqovpSHGISvkH2VBhPPry9q9KrYsniszI/AFeQ=; b=Ot3RS8qQDcaHKH1Px+Pz5IG7M75o8dB8+pHYX3gmi6u7EY6fBIBTQsJ/tG4x4nV8Ga 40sbaxEoRNDgJMo38DkhIozYhWo9Bqt6BvzK1EiLzPUsbCW0ohPmj4bJ3p3IztPqsGfy OnTXKYLkd0u1VS28NHSYewiMqegKxmdJ66IfPdYlN19QkrGvk3eix1PiDwdjx4cOVfe1 tDoiZ0cqqiwprS2BTEbaydaaUVnGa0mU1jDu8indlbavJPdjP/rCfR0JJZOVjoeOPcvL wiYLKG0cmTh1/efBDv+NWih5r3OJbgiDTqGPQHgh5hKRb0g/O81G2oVfB/YtV4Ngn0+f CpaA== X-Gm-Message-State: APjAAAXoQF3wg9N8+FPYovZZ8jRJAsr20tLrf8avVK66RX9ugQ+MxEV2 AQ6fT+xD9cqQXUD14eTudKL2zw== X-Received: by 2002:a5d:8f99:: with SMTP id l25mr16677015iol.92.1559594053795; Mon, 03 Jun 2019 13:34:13 -0700 (PDT) Received: from google.com ([2620:15c:183:0:20b8:dee7:5447:d05]) by smtp.gmail.com with ESMTPSA id r139sm7147741ita.22.2019.06.03.13.34.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 03 Jun 2019 13:34:12 -0700 (PDT) Date: Mon, 3 Jun 2019 14:34:08 -0600 From: Raul Rangel To: Ulf Hansson Cc: "linux-mmc@vger.kernel.org" , Daniel Kurtz , Linux Kernel Mailing List , Adrian Hunter Subject: Re: [RFC PATCH 2/2] mmc: sdhci: Quirk for AMD SDHC Device 0x7906 Message-ID: <20190603203408.GB182838@google.com> References: <20190501175457.195855-1-rrangel@chromium.org> <20190501175457.195855-2-rrangel@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 28, 2019 at 09:41:07AM +0200, Ulf Hansson wrote: > 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? Patch one is required. Otherwise there is a possible race condition where the card remove is not detected. I'll go through the comments you added on the first patch. > > Should this have a stable tag? I would not put a stable tag on this patch series yet because there is a possible resource leak in 4.14. See https://lkml.org/lkml/2019/5/13/763 If we can get those patched merged then I think it's fine to backport the patch set. 4.19 doesn't suffer from the resource leak. I haven't audited anything before 4.14 though. Thanks, Raul > > 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 > >