Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3955873imu; Mon, 12 Nov 2018 03:28:02 -0800 (PST) X-Google-Smtp-Source: AJdET5cK4MIT92ZFfwMcWD9Di9HsEr/aHVcCwy/aYyuJBKIm5kp+zfFfyCe2dIhL0+2o8tWspldq X-Received: by 2002:a63:9f19:: with SMTP id g25mr475917pge.327.1542022082644; Mon, 12 Nov 2018 03:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542022082; cv=none; d=google.com; s=arc-20160816; b=RAcq7E4PAlh/orf7mBLg9GxXPAbyUkEvlGCA9Cu/gOOZg4tWYfz8a9NCqhJDpGk0ci FI9yyO4j1v70Wqbn2JndpJ2ylDY2UJ888hzJtWyCPgQsXf8Hs6Txn9oNMgvbUXhUCXiC WDJBTq2Gcwg0E58Wk6mnByY66eszk08We2PfUONSZo5IdFCJpvyF6P23zQuaQwJJ92+L NcPX+Zcwcu3717pthWzb4rsr668yKwFvPZqi12CjlGHhcprL4i5uhys2BgLQAaJdODrE uYnG0jJP2j/13Fg+frKTNm+FCIxr90FWF8M/ji/tUWY/PWr6mF6DWWUuFeLRKm1NLu4u Wu+w== 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=yhIlc1SVFqKqcYPRbDWARTZm9pj1ecUjykjdD4Hqpxk=; b=RFadovnj51Gwxt2B44AQsknnyi9fDhMO+D22gWthSdsTICHLdL9FeRvQ3Gvf3X41AH 5mzThSuiKO/x0MvkIGKDibrVAMuAJuBrsB/YwF27mzgyyGhN1DvmbsFXkIuVhpKVv/ix atrda8tPmWJGo0n0pGLP+em3W9AGMSPHNf9ruNdFm9fSscyrY/igzPl3yBA/c2kOFst0 On073w7ZwpXFJmI5dUuqfviV6Bt1rXH/bKXto3RmSs1npz+jYf4EQwz7nfroIcMeGEtE zFUDOsss5602hExtiOgzwBtKHBSKvY/+tgS4gic6SfRmH23jwvr0RmyEG3BegdDV5BXe gP7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NDwnXkqN; 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 j7-v6si16422603plt.349.2018.11.12.03.27.47; Mon, 12 Nov 2018 03:28:02 -0800 (PST) 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=NDwnXkqN; 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 S1729341AbeKLVSw (ORCPT + 99 others); Mon, 12 Nov 2018 16:18:52 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37184 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728302AbeKLVSv (ORCPT ); Mon, 12 Nov 2018 16:18:51 -0500 Received: by mail-qk1-f193.google.com with SMTP id 131so12590687qkd.4; Mon, 12 Nov 2018 03:26:01 -0800 (PST) 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=yhIlc1SVFqKqcYPRbDWARTZm9pj1ecUjykjdD4Hqpxk=; b=NDwnXkqNE8ivocJ96bNaziE614xhBMsKI4eGgXI2GbKpzvAifpEfsRh40viEh3vkzy LI0CHd4/NpIlTE3Ul0RCVSukrWAqSZY1uQnPQRy0GD1XWV3xPQhgDvtgiw7WQYpR3/qU yOVc8Qg9gYb9ocsLc0NrDjJYY5T64pjZFahBJCcQCvvLpqJiYlFng1e0RW3NuJSMfLgR Wju+421Kqan3DW3MUYPo4wVbyMFLpzx3pwIEjD2YVxh/SmKA0QRw/6PpWOYJC76KUvZd lF4AEzqfQNmBc1Pb+f6xn82TKIf79GiIYvd/TdFBZMCx76uB+nEboTZQUtkVgJvqcpZ7 vv2Q== 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=yhIlc1SVFqKqcYPRbDWARTZm9pj1ecUjykjdD4Hqpxk=; b=F7ULjaIJ89YW0uRq2xAddSiIk4zfqxOtm+egqNQVmpB7qgenfptiIxstFspHI++O2R OwZFqpCM9sXDlyJEM06SKRRZ35GZx+y7IgMi6Amtppy/+yfZ+nbG2tgmmn0NAklczZZe /DHOsFoYzBpvyh4cdbom5zpsmwyUZ+t6Bbkafmq3Nd134gZA3xFy3U5319KAL3bbk15k FG09KhymGdt412kK8Ek5ClwFNcNU41feBtoja7aC8c6/O1tBf6jynKBN4wWfxd23gyLI WI0uwZONkDde2zOLTksiyUD5nHVX7ZfoaE57q14t8jgloLwcjUyyITPa+GZIlQ/nhbhR mykg== X-Gm-Message-State: AGRZ1gIuFRn8CN86UYmTO5gECQPsvjG5ZqxsR2Fr2XWgLRin0Efdkef/ 8ZnJi9xS2lrczXOAp2a+iHUjF3Gw6URqo8paxv0= X-Received: by 2002:ac8:6151:: with SMTP id d17mr466425qtm.194.1542021961399; Mon, 12 Nov 2018 03:26:01 -0800 (PST) MIME-Version: 1.0 References: <20181029221701.51376-1-rajatja@google.com> In-Reply-To: From: Andy Shevchenko Date: Mon, 12 Nov 2018 13:25:49 +0200 Message-ID: Subject: Re: [PATCH v2] mmc: sdhci-pci: Try "cd" for card-detect lookup before using NULL To: Ulf Hansson Cc: Rajat Jain , Adrian Hunter , 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 Mon, Nov 12, 2018 at 1:05 PM Ulf Hansson wrote: > > On 29 October 2018 at 23:17, 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: > > > > The mmc core provides the mmc_gpiod_request_cd() API to let host drivers > > request the gpio descriptor for the "card detect" pin. > > 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-gpios"/"cd-gpio") in _DSD (which internally > > points 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 (for index based lookup) and _DSD entries (for > > string based lookup). 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-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. > > > > 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" appears to be fairly consistent > > across other users of this API (other MMC host controller drivers). > > > > Link: https://lkml.org/lkml/2018/9/25/1113 > > Signed-off-by: Rajat Jain > > Applied for fixes, thanks! > > Should I add a stable tag to this as well? If you go with that it might make sense to have Fixes tag against commit f10e4bf6632b5be11cea875b66ba959833a69258 Author: Andy Shevchenko Date: Tue May 23 20:03:19 2017 +0300 gpio: acpi: Even more tighten up ACPI GPIO lookups -- With Best Regards, Andy Shevchenko