Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1316212lqp; Mon, 15 Apr 2024 02:40:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9f0J8asMXJ0ZuBCpk1VTklNCg5jyNki5OPyj2H5JVZTG9apW3RAtam4D6BYeJBup4omGAZeUYJOVSVxlUzVi+DS7udYP0qi9626vTiw== X-Google-Smtp-Source: AGHT+IE85Pg/viHt2FqCZF3hTcyHARTloEVsIKyLhkqhbTcmnsp+zT5ntKNGDxC1ussFRaVtNzyq X-Received: by 2002:a05:6a20:9483:b0:1a7:9e84:dc51 with SMTP id hs3-20020a056a20948300b001a79e84dc51mr10391661pzb.7.1713174008068; Mon, 15 Apr 2024 02:40:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713174008; cv=pass; d=google.com; s=arc-20160816; b=TJVvzi158TSmJwlUkGw3RSOrItdYhYWyfMFi3vJ8yvDY01tCcC/UeI22cdgSeUqKCK hUOC04ZTYKgFZm6xwNiIduqEzS9SOcfC5YVldjmy65UgS/O+rxxn3sxhl6YhoE8pWD1M L7w2t15XzfsGEJYRSaLS/VgJ0Hn14QSOoeoAHcrtz79PBlgxf71YgAAKEJw9opynPoqS HXoMwtDl8RJEaZbRtlNl32wGwl+KW4eBvnlrUt+SxpaMWClvSrw9ocbEClCgXN8/i16a F3uc/weyuTd2Mj519roHExzMTmZ+2ktpIyTxMbG2yKE0aGSIY9IMRqSnPjUd2TbsUNMV WiKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=LCXRLPG0Llto+g6rfh29zpyPCa3TJXyJ2FIeuPuw+b0=; fh=72BtwwOxnpSzLrErfFGGQIhwSGZZGyPlpYt1b+BKBl0=; b=ggAKFkBCuw1b4WSvv31bVOVRR8l+2/CSBorngqCDGD1JYeYcfU+53+xGQ8izVZZssO sXhjXJRdFfXPaDssHhQakt6Fzk8FdAdM/88PAlcVx/+wyfTATE/no6PBqKhwQiiT/WT4 xNYsvhiaMHcS0rD73eYPpbXB30ApnbrYFcEEfeUlh9gepo/RcyLAjVJrrRLDpiOZYl0Y EYPMIyXlGCz4alp4mH0/6+hzDZY7JKYNzyNMw6LpDMwI/HoH4Ixd+sNt1hwkxFZ15hJK huT7k5reZnb3uiaAYsKlloqye0VwhC/5pDDg0dZpYtPEQQlFdgpXLj35zdoTCWdyiE8+ 6K/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="f2Kqu/nS"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-144840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144840-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p3-20020a634f43000000b005dc528a9d0bsi7534958pgl.241.2024.04.15.02.40.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 02:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="f2Kqu/nS"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-144840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144840-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id ED733B225E5 for ; Mon, 15 Apr 2024 09:35:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20E553FE31; Mon, 15 Apr 2024 09:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="f2Kqu/nS" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FE493FB99; Mon, 15 Apr 2024 09:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713173724; cv=none; b=B0ctOp7hmkvb2BtPp8AvIMJZjE7FzB4Q9AT1TE8tYsTzfgKoXYVgMuvYcu51AkkUa9QPetLIqbj8tpBR8VB5GvsUsyDM8PjuvVFLg0c8CoeJCyt8fuSeVjEf0mR0qZIyst+/BJas7cLni6Myp4mC7sm7U0eu/nUW3xKuFZ7nI0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713173724; c=relaxed/simple; bh=wBSd5Y+TxWHD4LOFHSfb4cgjJpmNUSVnhOraR697swQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sL7jBQcTSXvxiHJ3DW5lnm5LdfaTNbapQAqT5Ec/65vyyeGKmy3MPYwlz/9NQEu1mM8QKwZ+nX0CIo4ilp/WCLCQat3/lIOVOAzcPUweuc1WEARS8qwh3YDwbaH6GdIRATqHidw8/BS9g220/QGkJsqhkh3pM8oBuk5F37B6Wbs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=f2Kqu/nS; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713173723; x=1744709723; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=wBSd5Y+TxWHD4LOFHSfb4cgjJpmNUSVnhOraR697swQ=; b=f2Kqu/nSbHxB8YNuz6SC2yWQhFN+yPcROnOCgzZr4G/II6QeEAX5TBmm TrGAr6jh3kq43DbNLGr5PVDyxr7QToBMwc1Sw/gqWEXwiAPbG2/r1o5Cf QzhPgsqJjc61/vBvdNyj71yH78om99Qiw9QO/2F0pVLc60AK5E69Tf2mi VdFlSan0oy5uh52kTfwYS2AqWpK4iDFlBdUyTuUUFntPSXjbAagwOuWqV ZxAbrSSZgVeQB8uziZXCx3vGbY5IVD1FHaB1jd15SrBobNuUMSkEncaQm yWM2pNak0xKRdwtStkSKxgZQpHJvMDPoPKkpqfBmlKHyc7BHBPFsHRkgk A==; X-CSE-ConnectionGUID: 2JGKiuuwTkSZ17MqBdHPTg== X-CSE-MsgGUID: mElYACCuSS+NXX44BZzKdw== X-IronPort-AV: E=McAfee;i="6600,9927,11044"; a="19945547" X-IronPort-AV: E=Sophos;i="6.07,202,1708416000"; d="scan'208";a="19945547" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2024 02:35:22 -0700 X-CSE-ConnectionGUID: GnbRCkgnSgGpFl3/1d/tYw== X-CSE-MsgGUID: tS21odWISD2AIiblLYPrkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,202,1708416000"; d="scan'208";a="52807041" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.249.38.19]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2024 02:35:19 -0700 Message-ID: Date: Mon, 15 Apr 2024 12:35:14 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sdhci: Fix SD card detection issue To: richard clark , Thierry Reding , Jon Hunter Cc: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20240415070620.133143-1-richard.xnu.clark@gmail.com> <52c08a01-8357-44dd-b727-a06438ec6c30@intel.com> Content-Language: en-US From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +Nvidia guys On 15/04/24 11:11, richard clark wrote: > On Mon, Apr 15, 2024 at 3:18 PM Adrian Hunter wrote: >> >> On 15/04/24 10:06, Richard Clark wrote: >>> The mmc_gpio_get_cd(...) will return 0 called from sdhci_get_cd(...), which means >>> the card is not present. Actually, the card detection pin is active low by default >>> according to the SDHCI psec, thus the card detection result is not correct, more >> >> SDHCI spec covers the SDHCI lines. GPIO is separate. >> >>> specificly below if condition is true in mmc_rescan(...): >>> ... >>> if (mmc_card_is_removable(host) && host->ops->get_cd && >>> host->ops->get_cd(host) == 0) { >>> ... >>> goto out; >>> } >>> The SD card device will have no chance to be created. >>> >>> This commit fixes this detection issue via the MMC_CAP2_CD_ACTIVE_HIGH cap2 flag, >>> parsed from the 'cd-inverted' property of DT. >> >> What hardware / driver is it? > sdhci-tegra on Orin. >>> >>> Signed-off-by: Richard Clark >>> --- >>> drivers/mmc/host/sdhci.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c >>> index c79f73459915..79f33a161ca8 100644 >>> --- a/drivers/mmc/host/sdhci.c >>> +++ b/drivers/mmc/host/sdhci.c >>> @@ -2483,6 +2483,9 @@ static int sdhci_get_cd(struct mmc_host *mmc) >>> * Try slot gpio detect, if defined it take precedence >>> * over build in controller functionality >>> */ >>> + if (!(mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)) >>> + gpio_cd = !gpio_cd; >> >> MMC_CAP2_CD_ACTIVE_HIGH is already handled in >> mmc_gpiod_request_cd(), and this turns an error (gpio_cd < 0) >> into 0, which is not right. > > But in case of 'cd-inverted' is not specified, the gpio CD pin return > 0 which will be explained as card is not present. >> >>> + >>> if (gpio_cd >= 0) >>> return !!gpio_cd; >>> >>