Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1257651lqd; Thu, 25 Apr 2024 10:00:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfmvN/0MRWVXhopXnowm4nbfcQWLeaAbAknDLMwxFjDoRfzrjVGgVyQ+JMHs7mOcknLvRcaqAUwbagaJLI2CQC0OW9FS4P07jWJztUtw== X-Google-Smtp-Source: AGHT+IEEoiFxrarWaN333PzoSDj2fOWP5JeHA1znfp2JZIwnSlbIu8I0VQyiTFVG0zyoUAsVScqq X-Received: by 2002:a17:906:c5a:b0:a58:868e:d662 with SMTP id t26-20020a1709060c5a00b00a58868ed662mr3167789ejf.11.1714064424168; Thu, 25 Apr 2024 10:00:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714064424; cv=pass; d=google.com; s=arc-20160816; b=Yxpn1mH1XLA+6hpe1G5CSSIfKfX9kb8FrPFgeahOihhjjXgZyCf1CD2fCnAhNaVEFP SQR2905LCCSXwUnkRDfU2xTstABNZh0FBw0MaVSlrECCRoiOj/gMjgDCL15qLRkR1M6k mYMEV5NUM8MwZD+t39n6kopyAHei3eeRt3kK1+yIoq9ycN+lVb+CSrL7wqjqPtjQawU9 Nrq0Ls32CUu1p+yKopP2ITt/xOie389B5h2Y1v1vYhd4ce8Hb6UyskYTqDzKpj9hSZ0C 2SP7FssKeOlLh2027hK/n3XibnNYbDxbSHaWHwiUH1lPPjoZqGnUh50oyvz4WOaxLSic LISQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=5abisNcD/ouIsr1NPEiIQ0iyqWHLbaxlL3KzDHmL5pg=; fh=HWKRbq/cxIEKbQKpzzlRVz91WynTCo/sOOI4Pk+ciIM=; b=llDPgg0DNwU2hu1rASLhtoG7fs7GP3PPgjXnPFHIj5kZvuI+Ci4KNa0qGNHWbag0JH szGYYf2Fzm3n1eburBP3buIJQ01K8+ty6jy89AyrTZ1rEJbq+eamKQDSyt64sb5CxT4e LI4TG3M7GNII2yKNL8PGfm4+A7MRHU+kuD0cZh9NHZHvhB7YHOdyKSEGgb9UKf+nuJmR AbNK8fVXbAOoV/fAxXcYmQrO9a2pkwA3eOmu8iQy07WVx0DovUfaeV4sERj+sXT/2k1d AuldxNY662q02aBXci+X70FctiHO15FobXxr3moouVChhsNu0gZD8xrvwhM1Rwpb4ccM u5hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GYaFQU/G"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-158933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kq19-20020a170906abd300b00a587342f7b5si4091376ejb.332.2024.04.25.10.00.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 10:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GYaFQU/G"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-158933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id DE0A61F22892 for ; Thu, 25 Apr 2024 17:00:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8694E14E2D8; Thu, 25 Apr 2024 17:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GYaFQU/G" Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 238F214D719 for ; Thu, 25 Apr 2024 16:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714064401; cv=none; b=JU5rz0OQYL/4BojBKqpuZ2x642ky6nRRIy79Givwyol0tj8HSQ+RnCUc56d6bmMewOI994oDp2wlNDAnqWcT6/qHANbSD475BV/1QV42Ecr6qTkA1ZRoiOjEsSbfxyWLoeT/flBVngl7Q1ZUirqSOsgEIoa6KKDsAed15PmfLGQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714064401; c=relaxed/simple; bh=qg8SZwpUN3b6LrPjOtHyorXHH1MH2warGErNjkgQBM8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Huny2kukFUWNapWNHZe2IUxaLltZGPG8SuOIqsbBRfJ9w79g2XNOfVOwblBcnevkdCWE5I0Dx4Z0a4dlKtHh+ziI0GiIHAk580/4fSG9bretPbYWUWboY7ryjoQ/D2bAyCRNUPvYLG9LdjDNqwrKCGFFqbqOcJzwx5pJtuTrH0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=GYaFQU/G; arc=none smtp.client-ip=209.85.219.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-de462f3d992so1439848276.2 for ; Thu, 25 Apr 2024 09:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714064399; x=1714669199; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5abisNcD/ouIsr1NPEiIQ0iyqWHLbaxlL3KzDHmL5pg=; b=GYaFQU/GPcag7Args3242vwOwSAIgS5F+azZOMhlh1ZOqpk66Ld9ccJlar2JtMVgss 2+YPMpts8R5lV3JUQLNKV2LjtAP7rMuvjWo4VKFlVV7r8bI/7BRWQ+Sh9c+DkWI65u1t d+CbpiWem4C/6+u11CIpdRrNg0chrBQBBAmPB/n+R56+6woSfhqEBRac6PNZqpruyX0M P6ZqScqxBIB34jnPcT45GTIOSV5Fh4wf2e4Shp5x/IhrGH4zmkhRTnXwBLA1jC1Ihthb Ne3EumkCjymhbnUyTtSJMSLdW8z+uzJD+4mSrBOEnSjfUjl1vk0K4WnMDzlUuXZ7x59+ 41mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714064399; x=1714669199; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5abisNcD/ouIsr1NPEiIQ0iyqWHLbaxlL3KzDHmL5pg=; b=Tc8M4KQPR1UMXlErOfMFbhcxJp3hzOcYfnt+1oW5VKgxGDDlcVpbQrE01eJHVY3zCC 8y9Z440uYTLuRCJsR7nC6ZrSRQ9+B6l9z3kW8TTmJ7faOAruU+eqnVkW6RkuTzv8VocE aXHK41zNCW4XDBymePQDKaLn512HZSvrpTlbSQiJj6vC9zUMIkT7+VOtm5gWfTJyJkAe n9IgUksIFgvdP7E6KFybe/OOlwoN5eNOgapDO7YxdjIFVIM66yqc+qpuFhSJraPV9/pL QWJ8TtrMRMUvUH+RhLKNth3lXh2Lh7Mvrt7d+vuNyTCIwT7rTa9u4JqeDPBN18d7zuja 4sKw== X-Forwarded-Encrypted: i=1; AJvYcCXJsSmuYpo8+uzGSsjD0hg6Pr+5BtQj0gzAeUc70LHUVm+IoIOrgQqLxZW4kchjX/csjWsdYfogj2Sl4VSH1Lg+NCK1HvxnAKlscm4b X-Gm-Message-State: AOJu0YwWcnfEc86iexcSXHw6LqhWYrP1vNtBYmdPI+8OEM0IM43eG9Jz 7aGqgODL/AyZR/Om3hqMN+jpn/vxEI3tlOgZtwfg77kaEgjMMySVlVC1kM22h6X20h1EvQxuYDV zkD7QvmUK+L0dNz9uPfKp60jOYM6zmSrY0CKInQ== X-Received: by 2002:a05:6902:2b01:b0:de5:9b53:614f with SMTP id fi1-20020a0569022b0100b00de59b53614fmr309834ybb.38.1714064399145; Thu, 25 Apr 2024 09:59:59 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327024545.138351-1-ricky_wu@realtek.com> <8b966794f2bb4fda8cc7d3e111bfef70@realtek.com> In-Reply-To: <8b966794f2bb4fda8cc7d3e111bfef70@realtek.com> From: Ulf Hansson Date: Thu, 25 Apr 2024 18:59:22 +0200 Message-ID: Subject: Re: [PATCH] mmc: core: resume not check card exist before powerup To: Ricky WU Cc: "wenchao.chen@unisoc.com" , "ricardo@marliere.net" , "marex@denx.de" , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" On Fri, 19 Apr 2024 at 08:53, Ricky WU wrote: > > Soft reminder > > If this solution, you still have concert on sd.c. > can we just do this check card flow in mmc host power up call_back? > > > > > > > > > _mmc_sd_resume > > > > add get_cd before call powerup, make sure the card exist > > > > > > Please elaborate more on what problem you are trying to solve, the > > > above doesn't make much sense to me, sorry. > > > > > > Yes, the card may be removed while the system is suspended. Then, even > > > if ->get_cd() indicates that there is no card inserted in the > > > SD-card-slot, we may still have the card being registered - and then > > > we need to unregister it. > > > That said, we need to call mmc_power_up() in order to try to > > > communicate with the card again. At least that is what the > > > mmc_rescan() work assumes when it runs the bus_ops->detect() callback > > > at some point later in time. > > > > > > > We saw the power up in a short time from waveform when removing the card, > > So we saw mmc_sd_resume call the power up did not check the card exist. Well, that doesn't really tell me if that is a problem or not? Doesn't the first command sent to the SD card (that has been removed) fail if there is no card inserted anyway? > > > > We think this the short time power up maybe cause OCP if no card exist. OCP? > > And this power up we think is unnecessary when no card exist. It may not be necessary, but in what way does it hurt? > > > > > > > > > > > > Signed-off-by: Ricky Wu > > > > --- > > > > drivers/mmc/core/sd.c | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > > > > > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index > > > > 1c8148cdda50..35e036672cfb 100644 > > > > --- a/drivers/mmc/core/sd.c > > > > +++ b/drivers/mmc/core/sd.c > > > > @@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct mmc_host > > > *host) > > > > if (!mmc_card_suspended(host->card)) > > > > goto out; > > > > > > > > + if (host->ops->get_cd && !host->ops->get_cd(host)) > > > > + goto out; > > > > + > > > > mmc_power_up(host, host->card->ocr); > > > > err = mmc_sd_init_card(host, host->card->ocr, host->card); > > > > mmc_card_clr_suspended(host->card); > > > > -- Kind regards Uffe