Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2939286imm; Fri, 19 Oct 2018 02:14:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV62VoUT0lapy0C2t74IriJwnFatpoUuYXb3BGWO9+Oh+WJYIz2FKFtNvPSLha0vjnsBQhsgt X-Received: by 2002:a17:902:d715:: with SMTP id w21-v6mr2586724ply.186.1539940464780; Fri, 19 Oct 2018 02:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539940464; cv=none; d=google.com; s=arc-20160816; b=ytOoH1D/+WSauMs2KmVjL3Loh5EMLfdTKQDnaZEksULTuTvKUm9OiTIvqN185tMmkp vzS2aiY6LjqSeEP4HzVoA7emzeK+yfJwNDxeMJ4+6xQsYuAjeNGrI80Ec2d7zoSIF1li Xt12bTK9SO/KFS841mtmDbMat/DM5YhdtHKZ4AV/RRBveaq/yK9JlciwAwsxARmhiCEi y8SJePppIsoGzMV8VYEG0ar6SBkM6xe1wxtzt81JPXiZGq0ZpkQ4XmYneXYLV9aCtpC0 JGXxYMDljhIbFJulQkCCi9eBuG+F6WaLbrnjenapJbtDRQdp4AEjvtFiNMSt7PBcoavK RRMw== 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=XjkhtnZXlORa9jpt4NPlWTyaIGde8zW2/vaHprMs4h0=; b=uo6UB7C3DZ7pTG83jc0a+EXht0vCBEbGnuLTzzj45tM88koUeT/AW72FycP6zVSIgw cxs6+6FhngLjBCF9EnuAF7nCaYI/waypgHiY2PBU4txFwueGpn7fqxiTUPiXgML4PiRD ZC6/sk4dvieIUJ+VyRZ4yixAGHJt/34fhuX6/IZoOANwk2Tdch0Q557iodCwetUhiVBL xgA6Rb4sZWge7MwoA7Uhe/N00dEDCOFy1sKB2g78KOgFWaCGjDMvCDlCU3piNZtTmKBk 0ACMo5a7iA80UeXICdclhcjHt33+ZmJsWDj8wc3EAJwbCPcG5vXOWOmmGzG0QHJNFtX+ lSsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dzQmMMOy; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9-v6si23116390plt.111.2018.10.19.02.14.09; Fri, 19 Oct 2018 02:14:24 -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=@gmail.com header.s=20161025 header.b=dzQmMMOy; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727315AbeJSRSu (ORCPT + 99 others); Fri, 19 Oct 2018 13:18:50 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:34033 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbeJSRSt (ORCPT ); Fri, 19 Oct 2018 13:18:49 -0400 Received: by mail-qt1-f193.google.com with SMTP id o17-v6so37558567qtr.1; Fri, 19 Oct 2018 02:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XjkhtnZXlORa9jpt4NPlWTyaIGde8zW2/vaHprMs4h0=; b=dzQmMMOyxlrGhumx+pbnpUJEPOoy8e56DAvX7sFaBFElWTBq6+tkwsFUh2unqhFjV3 wMuGQ65Hnbfk8JLqJzofcyipV+QZ/V+JKTq2MAMysEuotP8xDe0HjQyzLjkssWxRkmWg 6nTq8hZMgr/PKC8vbepjlkwAvU8AsqpLRzhql+NrTLdAw9JtP9w98Vv3W+0t/HqQ4RL0 j4v/ZnnBCPfFeSRI+oZpJkeRkIC13K6umSJo31LBlaE3/axIf4erH80CZ6wbAnJgKYVk zIjFFT+xlH7SEMC10ykYQvWqDI/u3J96jknoEf18eZfCOif9JCav3Gx/e+VuCkrph9My yjJQ== 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=XjkhtnZXlORa9jpt4NPlWTyaIGde8zW2/vaHprMs4h0=; b=KHbRt8dCFZS3CHB5nO5xWNEJmn6/mB9dUzqgHU0L3lAlKSEiafpt/Hziz2xndVvNi0 10vET2SltobMKgpbEuUVAZkjvQLYS5wPc08O+rXL9ryw0ChKjVzXI6AdKxf6YhuEEgYv k0mJpS1dPPhNdWYh1yUx0L0hgrjEt93YHNp3Vb1BUjFsDcC4l9U4WHMeUbG4OkSjgvY+ Apk98AYIC9wjHmfeH5DrTrm54m7m7sCnW3IJELKgNjPsVY4TiMkaUm30qvqAs7UtJeha HXPYPSEj7h7d/McvOP/E1mHPWNRrdaqfphmiYm8X0QInpzaamOS7nu7A/4KzeDQW5ovQ iOgQ== X-Gm-Message-State: ABuFfoiE2rLCYKkWfuQkaA3uXhixeUMBvU/rtitiZwwBUDAwE4SB6poM kTjwS/XRAh/EU5gbL62WJZBFpNmMDjkNjXOfVAQ= X-Received: by 2002:a0c:819c:: with SMTP id 28mr34285479qvd.7.1539940415754; Fri, 19 Oct 2018 02:13:35 -0700 (PDT) MIME-Version: 1.0 References: <20181018215101.169847-1-rajatja@google.com> In-Reply-To: <20181018215101.169847-1-rajatja@google.com> From: Andy Shevchenko Date: Fri, 19 Oct 2018 12:13:24 +0300 Message-ID: Subject: Re: [PATCH] mmc: sdhci-pci: Try "cd" for card-detect lookup before using NULL To: Rajat Jain Cc: Adrian Hunter , Ulf Hansson , linux-mmc , Linus Walleij , Rajat Jain , Linux Kernel Mailing List , Mika Westerberg , Andy Shevchenko , Dmitry Torokhov , "open list:GPIO SUBSYSTEM" , ACPI Devel Maling List 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 Fri, Oct 19, 2018 at 12:53 AM Rajat Jain wrote: > > Problem: > > The card detect IRQ does not work with modern BIOS (that want > to use DSD to provide the card detect GPIO to the driver). > > Details: > > (Discussion: https://lkml.org/lkml/2018/9/25/1113) We have a Link tag for such references. > The mmc core provides the mmc_gpiod_request_cd() API to let host drivers > request the gpio descriptor for the "card detect" (or carrier detect?) pin. card detect is a right term. > This pin is specified in the ACPI for the SDHC device: > > * Either as a resource using _CRS. This is a method used by legacy BIOS. > (The driver needs to tell which resource index). > > * Or as a named property ("cd-gpio") in DSD (which may internally point cd-gpios (gpio suffix is a legacy). > to an entry in _CRS). This way, the driver can lookup using a string. > This is what modern BIOS prefer to use. > > This API finally results in a call to the following code: > > struct gpio_desc *acpi_find_gpio(..., const char *con_id,...) > { > ... > /* Lookup gpio (using "-gpio") in the _DSD */ > ... > if (!acpi_can_fallback_to_crs(adev, con_id)) > return ERR_PTR(-ENOENT); > ... > /* Falling back to _CRS is allowed, Lookup gpio in the _CRS */ > ... > } > > Note that this means that if the ACPI has _DSD properties, the kernel > will never use _CRS for the lookup (Because acpi_can_fallback_to_crs() > will always be false for any device hat has _DSD entries). > > The SDHCI driver is thus currently broken on a modern BIOS > (even if > BIOS provides both _CRS and DSD entries, either of which could be used for _DSD > a successful lookup). This is incorrect. _DSD for GPIOs without any accompanying _CRS doesn't make any sense. > Ironically, none of these will be used for the > lookup currently because: > > * Since the con_id is NULL, acpi_find_gpio() does not find a matching > entry in DSDT. (The DSDT entry has the property name = "cd-gpio") cd-gpios > > * Because ACPI contains DSDT entries, thus acpi_can_fallback_to_crs() > returns false (because device properties have been populated from > DSD), thus the _CRS is never used for the lookup. _DSD > > Fix: > > Try "cd" for lookup in the _DSD before falling back to using NULL so > as to try looking up in the _CRS. > > I've tested this patch successfully with both Legacy BIOS (that > provide only _CRS method) as well as modern BIOS (that provide both > _CRS and DSD). Also the use of "cd" also appears to be farly consistent _DSD fairly > across other users of this API (other MMC host controller drivers). > if (slot->cd_idx >= 0) { > - ret = mmc_gpiod_request_cd(host->mmc, NULL, slot->cd_idx, > + ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx, > slot->cd_override_level, 0, NULL); Yes. > + if (ret && ret != -EPROBE_DEFER) > + ret = mmc_gpiod_request_cd(host->mmc, NULL, > + slot->cd_idx, > + slot->cd_override_level, > + 0, NULL); And no. Instead of this part you need to provide an ACPI GPIO mapping table. See examples, like net/rfkill/rfkill-gpio.c (look for acpi_rfkill_default_gpios) > if (ret == -EPROBE_DEFER) > goto remove; -- With Best Regards, Andy Shevchenko