Message ID | 20240213051716.6596-1-sh043.lee@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-62940-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp335781dyb; Mon, 12 Feb 2024 21:14:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbEUgFI3mq3z/ZvRo6DgWmEaiR+EX2RaLzSdwiDG/oiBX3GxHXX8QBPJ8pg9OHnWkS1OY3d26ff7IEkwIrpgrnCzvREA== X-Google-Smtp-Source: AGHT+IEnKq3F9MdizeuxXlabdjoNwYDtLd3m3rlOe4Lau7oL6qmkiRx1qpn18sMQRBb7KmGHyxOl X-Received: by 2002:a05:6830:4425:b0:6e2:e00f:c4d0 with SMTP id q37-20020a056830442500b006e2e00fc4d0mr6815415otv.20.1707801240478; Mon, 12 Feb 2024 21:14:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707801240; cv=pass; d=google.com; s=arc-20160816; b=E1zSOfe4XrTu9f+JRH+5YFCJ/Vj+yE8lbW8QYjIs7y2DU1LxW9HICi51ilYPvgTtDz Gz28i99smJHj/X8P3SYXKXftsu94heLYAXm99hc2XV1EQKzSSmn0lRbKkqFlwN2OmCR5 2DbcYXTpmRh1Sn+l72rn3s1zbqMrG3Z09L9/WBZK52pFfiAZtpxAeWB7i7OFl/PdOEAc d3ARjQfiys9oEa7eR22Pm8LnhUjDoBVVnkxPhjKmgzS97nUKS379GUysY420FGSUw/2V C4zoE7dJIquzHpKuMIOmDv41lXzAaBSg566Q/jqaiy+iMDrnwcMo/VUm5vEaIWEamRVz dKAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:dlp-filter:cms-type:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=dqPFTyfLpIiOwNn2UYQocQjz2kFlkgOBWnJcMM8k5K8=; fh=nrv5/Ym2ajEP5QmGuSojpaHGKZbO5NbV4SJOkIdYRf4=; b=Lkoq9PESOG/H+ixcqJOtJ4NLMs8MLV5vma23W5P+RNc08EqWNkgEcN0fdnG7gBoot1 OWny3CPpxGn0dP9DmquJaYOji0MsFNwCMh+0lcGrK1AJr6EeZyF9S4jSvq03ssQpY1gc Dca7esPIi5/pofOuhGo2wo97MgGBcevo2I8TR/Mh6LhjxjQ8FL7nleB0mICvng9z1Eai dI86YX9qjiv2IRxbz1jcXwxpafpUq0+BCyn0HEcy7MQqEeAJJAylT4i8xq+A4lRwroFm 9EUMrwhiEspLh2ZZG6VKlazHeMJ8XPgj7c4uXG7NkAzCbKQN5qfRVil0T7ScNAyVeV7l O/yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=j0RtezKw; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-62940-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62940-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCVaPMBS7V6WdDF2NNKc8R9YMHybrLoxtgLDtHFJE1SugT8ArMU5YJgqfjDVzexPzo8KOVdCd06vfULVluhMjIWLRt5bRw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l24-20020a63ba58000000b005dbc6dc4cdasi1415248pgu.255.2024.02.12.21.14.00 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 21:14:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62940-ouuuleilei=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=@samsung.com header.s=mail20170921 header.b=j0RtezKw; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-62940-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62940-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.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 50BE2B25201 for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 05:13:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FE3B12E40; Tue, 13 Feb 2024 05:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="j0RtezKw" Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 0611A11723 for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 05:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707801218; cv=none; b=AMxibKxXr86hMq1EjVSMNLF3qXdKJST4cXDeLoMXHHP1T/5z5ga+mRzYO06cJbEs5GKn5trRWtqe0AqeOfr9DKspXn8GGmVUb9j4KDu2G0He81Zk5jf/f8pNGWTve4sPAQE5zIHk6h1lUORJg1n5HViK/+8WMo5DbeA3kVHvLPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707801218; c=relaxed/simple; bh=DWFcKn1l9Sn/hd+zC927DFkvDijnYn0PyBhaocjqmPA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: References; b=QYdvkd9ZTlQ6CuVyAYHTtt4M+IKU89HMJy8fXWLbOR6Tft8uzihjdj1O/5MjFb6ZUmalnUZb0u1CuBZj9A8c/I+pn6J6sy/pACgixC/WaNH0r4mMFkgL8zmd3GP3e3bUtXpHgchFgfb05R+Nq4akPQVZe2+j2LKK3WRUEhYVYqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=j0RtezKw; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240213051333epoutp01cc33bb93c0dd23faa6c28938bd41944e~zVCfVxCzu1138111381epoutp01F for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 05:13:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240213051333epoutp01cc33bb93c0dd23faa6c28938bd41944e~zVCfVxCzu1138111381epoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707801213; bh=dqPFTyfLpIiOwNn2UYQocQjz2kFlkgOBWnJcMM8k5K8=; h=From:To:Cc:Subject:Date:References:From; b=j0RtezKwFfQt2vXITpkL1UhwRCJzuaenC7uSrN+cJbVYnkFR+j4lL13/9bPFKMl8W IymepB0g8RL9uzbNCUexWdiCUeE5vzqIsTn8cG55bckPHAMWc4SRKWVQVUmO02u01C NNpEJOi6XEN1HDC2mI/ofhLb7tJrYPzNNYB2a7sQ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20240213051333epcas1p1283e6c855368c394ace15522c9136aec~zVCexj1yQ2686026860epcas1p1H; Tue, 13 Feb 2024 05:13:33 +0000 (GMT) Received: from epsmgec1p1.samsung.com (unknown [182.195.36.227]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4TYqH05tM9z4x9Pv; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmgec1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 71.B8.08572.C7AFAC56; Tue, 13 Feb 2024 14:13:32 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc~zVCd_duAW2685026850epcas1p1c; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240213051332epsmtrp2d80db3c4e9ba94969b78a7d530bc6104~zVCd9xIvc0269502695epsmtrp2m; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) X-AuditID: b6c32a33-cefff7000000217c-07-65cafa7c6b12 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 7B.20.18939.C7AFAC56; Tue, 13 Feb 2024 14:13:32 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.101.71]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240213051332epsmtip1835b0865323701a316e6a73933c4c37c~zVCdt2vdC1628916289epsmtip17; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) From: Seunghui Lee <sh043.lee@samsung.com> To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, gregkh@linuxfoundation.org, avri.altman@wdc.com Cc: grant.jung@samsung.com, jt77.jang@samsung.com, dh0421.hwang@samsung.com, junwoo80.lee@samsung.com, jangsub.yi@samsung.com, cw9316.lee@samsung.com, sh8267.baek@samsung.com, wkon.kim@samsung.com, Seunghui Lee <sh043.lee@samsung.com> Subject: [PATCH] mmc: sd: Add a variable to check a faulty device Date: Tue, 13 Feb 2024 14:17:16 +0900 Message-Id: <20240213051716.6596-1-sh043.lee@samsung.com> X-Mailer: git-send-email 2.29.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmgW7Nr1OpBiv3aVq8/HmVzWLGqTZW i33XTrJb/Pq7nt2iefF6NouOrZOZLHY8P8NusetvM5PF5V1z2CyO/O9ntGj6s4/F4tqZE6wW x9eGW2y+9I3Fgc/jzrU9bB77565h9+jbsorR4/MmOY/2A91MAaxR2TYZqYkpqUUKqXnJ+SmZ eem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5QIcqKZQl5pQChQISi4uV9O1sivJL S1IVMvKLS2yVUgtScgrMCvSKE3OLS/PS9fJSS6wMDQyMTIEKE7Izzt85yFowX6zi3p2z7A2M O4S6GDk5JARMJFrnvmcBsYUEdjBKPOyq6mLkArI/MUq8mXcWKgHktH/igWn4MukXC0TRTkaJ vVsamCGcz4wSk4/PYwepYhPQkpi+aQsTSEJEoI1Rom/FY7AWZoEPjBK/+lYygVQJCzhKvGo+ ywZiswioSjT0PwPbxytgKbHrzEp2iH3yEn/u9zBDxAUlTs58AlbDDBRv3jobbLWEQCOHxJnz xxkhGlwk1s59yQphC0u8Or4FapCUxOd3e9kgGpoZJdoavrJAOBMYJV4seMUEUWUv0dzaDFTF AbRCU2L9Ln2IbXwS7772sIKEJQR4JTraoKGnLPHy0TKoTkmJJe23mCFsD4nL63vZIIEXK/Hg ySPWCYxys5D8MAvJD7MQli1gZF7FKJZaUJybnppsWGAIj8vk/NxNjOAkqmW8g/Hy/H96hxiZ OBgPMUpwMCuJ8F6acSJViDclsbIqtSg/vqg0J7X4EKMpMFQnMkuJJucD03heSbyhiaWBiZmR iYWxpbGZkjjvmStlqUIC6YklqdmpqQWpRTB9TBycUg1MXasnH3yzWGB9a43J1NNxTttSNidZ NYcHChXv7LBp3RSs2cdmeE7UfouCHVuP2WbONV/Uj7gtcF10at306MXWQVoePfdTcplMZnlM MglKvCOQKJFhJbn3ab+iznGexx2ppQuF5rzedyj2yGO2vn7ZmuvvmPQ4quU4eiODolY8W7/f +Szjvkc7X/itePVQ0Orjm4sXXx1UaGuXdn/GffrIrcQLbn2dB9t1/Kzub5tkqvP0srz8rtK4 Tesa2WImb1npFJ+YuKMr+ftShpPK2nwLve5Ia823M/DbnBTSp8m0LTTj0vdI8e1th+2F592d Im9TZM751LVn+a49j+8dWipv8Lt50c3Hev1+cwzj3D8psRRnJBpqMRcVJwIApklihisEAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsWy7bCSnG7Nr1OpBst+cVi8/HmVzWLGqTZW i33XTrJb/Pq7nt2iefF6NouOrZOZLHY8P8NusetvM5PF5V1z2CyO/O9ntGj6s4/F4tqZE6wW x9eGW2y+9I3Fgc/jzrU9bB77565h9+jbsorR4/MmOY/2A91MAaxRXDYpqTmZZalF+nYJXBnn 7xxkLZgvVnHvzln2BsYdQl2MnBwSAiYSXyb9Yuli5OIQEtjOKHHi9TZGiISkxOJHD9m6GDmA bGGJw4eLQcJCAh8ZJb5tDgGx2QS0JKZv2sIEYosI9DBK9O3KA5nDLPCLUWLH1GVsIAlhAUeJ V81nwWwWAVWJhv5nLCA2r4ClxK4zK9khdslL/LnfwwwRF5Q4OfMJWA0zULx562zmCYx8s5Ck ZiFJLWBkWsUomlpQnJuem1xgqFecmFtcmpeul5yfu4kRHOBaQTsYl63/q3eIkYmD8RCjBAez kgjvpRknUoV4UxIrq1KL8uOLSnNSiw8xSnOwKInzKud0pggJpCeWpGanphakFsFkmTg4pRqY HNybDl2pdNt3KNj726eGqd6m/9j+X59roO9pySzexmYVG/SsL8TghNSUpy6xS55uO39g74y7 ew34d8exH35Y+WLTfJELaarNS61W3Vp/Vovh4pnCncpzFpVH/CnQ+3voQdKfCZz1r9a3zmHl b22wvjFftSbI+86ls2sn/fkjF+rPdKeMb8epjeXFtlocfVufM6UcXLydfd4x+2jX6g2/ZhgW yH77VlKVfGPa6uaslosinRP2/W+6t1rFO+zJhFkbpZc6mTJ6W+78fCfcM7pDhTs+2EqHf+2U yvk/S8V+pZxb8dZ2zbN4pq6Ug44CtQsuH36w1m6jrH2qvaLnukqTaw3nl/dmt6nGp/wv8I9h UGIpzkg01GIuKk4EANd3Ui3fAgAA X-CMS-MailID: 20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc References: <CGME20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc@epcas1p1.samsung.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790759393627013464 X-GMAIL-MSGID: 1790759393627013464 |
Series |
mmc: sd: Add a variable to check a faulty device
|
|
Commit Message
이승희
Feb. 13, 2024, 5:17 a.m. UTC
In mobile devices, suspend/resume situations are frequent.
In the case of a defective SD card in which initialization fails,
unnecessary initialization time is consumed for each resume.
A field is needed to check that SD card initialization has failed
on the host. It could be used to remove unnecessary initialization.
Signed-off-by: Seunghui Lee <sh043.lee@samsung.com>
---
drivers/mmc/core/sd.c | 12 +++++++++++-
drivers/mmc/core/slot-gpio.c | 1 +
include/linux/mmc/host.h | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
Comments
> In mobile devices, suspend/resume situations are frequent. > In the case of a defective SD card in which initialization fails, unnecessary > initialization time is consumed for each resume. > A field is needed to check that SD card initialization has failed on the host. It > could be used to remove unnecessary initialization. I don't see where you are using this new init_failed field? Maybe instead, elaborate the logic to free_card: to detect a broken sd. e.g. instead of just if (!oldcard), if (!oldcard || ! mmc_sd_alive(host)) or something. Thanks, Avri > > Signed-off-by: Seunghui Lee <sh043.lee@samsung.com> > --- > drivers/mmc/core/sd.c | 12 +++++++++++- > drivers/mmc/core/slot-gpio.c | 1 + > include/linux/mmc/host.h | 1 + > 3 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index > c3e554344c99..f0eb3864dc24 100644 > --- a/drivers/mmc/core/sd.c > +++ b/drivers/mmc/core/sd.c > @@ -1410,6 +1410,7 @@ static int mmc_sd_init_card(struct mmc_host *host, > u32 ocr, > bool v18_fixup_failed = false; > > WARN_ON(!host->claimed); > + host->init_failed = false; > retry: > err = mmc_sd_get_cid(host, ocr, cid, &rocr); > if (err) > @@ -1752,6 +1753,8 @@ static int _mmc_sd_resume(struct mmc_host *host) > > mmc_power_up(host, host->card->ocr); > err = mmc_sd_init_card(host, host->card->ocr, host->card); > + if (err) > + host->init_failed = true; > mmc_card_clr_suspended(host->card); > > out: > @@ -1803,8 +1806,12 @@ static int mmc_sd_runtime_resume(struct > mmc_host *host) > > static int mmc_sd_hw_reset(struct mmc_host *host) { > + int err; > mmc_power_cycle(host, host->card->ocr); > - return mmc_sd_init_card(host, host->card->ocr, host->card); > + err = mmc_sd_init_card(host, host->card->ocr, host->card); > + if (err) > + host->init_failed = true; > + return err; > } > > static const struct mmc_bus_ops mmc_sd_ops = { @@ -1891,5 +1898,8 @@ int > mmc_attach_sd(struct mmc_host *host) > pr_err("%s: error %d whilst initialising SD card\n", > mmc_hostname(host), err); > > + if (err) > + host->init_failed = true; > + > return err; > } > diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index > 2a2d949a9344..93d081c7dd53 100644 > --- a/drivers/mmc/core/slot-gpio.c > +++ b/drivers/mmc/core/slot-gpio.c > @@ -33,6 +33,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) > struct mmc_gpio *ctx = host->slot.handler_priv; > > host->trigger_card_event = true; > + host->init_failed = false; > mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms)); > > return IRQ_HANDLED; > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index > 2f445c651742..1d75cfdbf981 100644 > --- a/include/linux/mmc/host.h > +++ b/include/linux/mmc/host.h > @@ -467,6 +467,7 @@ struct mmc_host { > struct timer_list retune_timer; /* for periodic re-tuning */ > > bool trigger_card_event; /* card_event necessary */ > + bool init_failed; /* check if failed to initialize */ > > struct mmc_card *card; /* device attached to this host */ > > -- > 2.29.0
> -----Original Message----- > From: Avri Altman <Avri.Altman@wdc.com> > Sent: Tuesday, February 13, 2024 5:42 PM > To: Seunghui Lee <sh043.lee@samsung.com>; linux-mmc@vger.kernel.org; > linux-kernel@vger.kernel.org; ulf.hansson@linaro.org; > gregkh@linuxfoundation.org > Cc: grant.jung@samsung.com; jt77.jang@samsung.com; > dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; jangsub.yi@samsung.com; > cw9316.lee@samsung.com; sh8267.baek@samsung.com; wkon.kim@samsung.com > Subject: RE: [PATCH] mmc: sd: Add a variable to check a faulty device > > > In mobile devices, suspend/resume situations are frequent. > > In the case of a defective SD card in which initialization fails, > > unnecessary initialization time is consumed for each resume. > > A field is needed to check that SD card initialization has failed on > > the host. It could be used to remove unnecessary initialization. > I don't see where you are using this new init_failed field? > Maybe instead, elaborate the logic to free_card: to detect a broken sd. > e.g. instead of just if (!oldcard), if (!oldcard || ! mmc_sd_alive(host)) > or something. > > Thanks, > Avri > Thank you for your suggestion. I'm going to use it in mmc_rescan as below. e.g. diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a8c17b4cd737..461cd75dc7ab 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2210,7 +2210,7 @@ void mmc_rescan(struct work_struct *work) container_of(work, struct mmc_host, detect.work); int i; - if (host->rescan_disable) + if (host->rescan_disable || host->init_failed) return; > > > > Signed-off-by: Seunghui Lee <sh043.lee@samsung.com> > > --- > > drivers/mmc/core/sd.c | 12 +++++++++++- > > drivers/mmc/core/slot-gpio.c | 1 + > > include/linux/mmc/host.h | 1 + > > 3 files changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index > > c3e554344c99..f0eb3864dc24 100644 > > --- a/drivers/mmc/core/sd.c > > +++ b/drivers/mmc/core/sd.c > > @@ -1410,6 +1410,7 @@ static int mmc_sd_init_card(struct mmc_host > > *host, > > u32 ocr, > > bool v18_fixup_failed = false; > > > > WARN_ON(!host->claimed); > > + host->init_failed = false; > > retry: > > err = mmc_sd_get_cid(host, ocr, cid, &rocr); > > if (err) > > @@ -1752,6 +1753,8 @@ static int _mmc_sd_resume(struct mmc_host *host) > > > > mmc_power_up(host, host->card->ocr); > > err = mmc_sd_init_card(host, host->card->ocr, host->card); > > + if (err) > > + host->init_failed = true; > > mmc_card_clr_suspended(host->card); > > > > out: > > @@ -1803,8 +1806,12 @@ static int mmc_sd_runtime_resume(struct > > mmc_host *host) > > > > static int mmc_sd_hw_reset(struct mmc_host *host) { > > + int err; > > mmc_power_cycle(host, host->card->ocr); > > - return mmc_sd_init_card(host, host->card->ocr, host->card); > > + err = mmc_sd_init_card(host, host->card->ocr, host->card); > > + if (err) > > + host->init_failed = true; > > + return err; > > } > > > > static const struct mmc_bus_ops mmc_sd_ops = { @@ -1891,5 +1898,8 @@ > > int mmc_attach_sd(struct mmc_host *host) > > pr_err("%s: error %d whilst initialising SD card\n", > > mmc_hostname(host), err); > > > > + if (err) > > + host->init_failed = true; > > + > > return err; > > } > > diff --git a/drivers/mmc/core/slot-gpio.c > > b/drivers/mmc/core/slot-gpio.c index > > 2a2d949a9344..93d081c7dd53 100644 > > --- a/drivers/mmc/core/slot-gpio.c > > +++ b/drivers/mmc/core/slot-gpio.c > > @@ -33,6 +33,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void > *dev_id) > > struct mmc_gpio *ctx = host->slot.handler_priv; > > > > host->trigger_card_event = true; > > + host->init_failed = false; > > mmc_detect_change(host, > > msecs_to_jiffies(ctx->cd_debounce_delay_ms)); > > > > return IRQ_HANDLED; > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index > > 2f445c651742..1d75cfdbf981 100644 > > --- a/include/linux/mmc/host.h > > +++ b/include/linux/mmc/host.h > > @@ -467,6 +467,7 @@ struct mmc_host { > > struct timer_list retune_timer; /* for periodic re-tuning */ > > > > bool trigger_card_event; /* card_event necessary */ > > + bool init_failed; /* check if failed to > initialize */ > > > > struct mmc_card *card; /* device attached to this host > */ > > > > -- > > 2.29.0
On 13/02/2024 09:49, 이승희 wrote: > > >> -----Original Message----- >> From: Avri Altman <Avri.Altman@wdc.com> >> Sent: Tuesday, February 13, 2024 5:42 PM >> To: Seunghui Lee <sh043.lee@samsung.com>; linux-mmc@vger.kernel.org; >> linux-kernel@vger.kernel.org; ulf.hansson@linaro.org; >> gregkh@linuxfoundation.org >> Cc: grant.jung@samsung.com; jt77.jang@samsung.com; >> dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; jangsub.yi@samsung.com; >> cw9316.lee@samsung.com; sh8267.baek@samsung.com; wkon.kim@samsung.com >> Subject: RE: [PATCH] mmc: sd: Add a variable to check a faulty device >> >>> In mobile devices, suspend/resume situations are frequent. >>> In the case of a defective SD card in which initialization fails, >>> unnecessary initialization time is consumed for each resume. >>> A field is needed to check that SD card initialization has failed on >>> the host. It could be used to remove unnecessary initialization. >> I don't see where you are using this new init_failed field? >> Maybe instead, elaborate the logic to free_card: to detect a broken sd. >> e.g. instead of just if (!oldcard), if (!oldcard || ! mmc_sd_alive(host)) >> or something. >> >> Thanks, >> Avri >> > Thank you for your suggestion. > I'm going to use it in mmc_rescan as below. > > e.g. > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a8c17b4cd737..461cd75dc7ab 100644 > --- a/drivers/mmc/core/core.c > +++ b/drivers/mmc/core/core.c > @@ -2210,7 +2210,7 @@ void mmc_rescan(struct work_struct *work) > container_of(work, struct mmc_host, detect.work); > int i; > > - if (host->rescan_disable) > + if (host->rescan_disable || host->init_failed) > return; I've seen SD cards that fail the first initialization attempt for both 'valid' reasons (e.g. weird insertion timing) and things like out-of-spec initialization time from the card, outright disabling these on the first fail is a bit too much IMO. Kind Regards, Christian
> -----Original Message----- > From: Christian Loehle <christian.loehle@arm.com> > Sent: Tuesday, February 13, 2024 10:35 PM > To: 이승희 <sh043.lee@samsung.com>; 'Avri Altman' <Avri.Altman@wdc.com>; > linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org; > ulf.hansson@linaro.org; gregkh@linuxfoundation.org > Cc: grant.jung@samsung.com; jt77.jang@samsung.com; > dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; jangsub.yi@samsung.com; > cw9316.lee@samsung.com; sh8267.baek@samsung.com; wkon.kim@samsung.com > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty device > > On 13/02/2024 09:49, 이승희 wrote: > > > > > >> -----Original Message----- > >> From: Avri Altman <Avri.Altman@wdc.com> > >> Sent: Tuesday, February 13, 2024 5:42 PM > >> To: Seunghui Lee <sh043.lee@samsung.com>; linux-mmc@vger.kernel.org; > >> linux-kernel@vger.kernel.org; ulf.hansson@linaro.org; > >> gregkh@linuxfoundation.org > >> Cc: grant.jung@samsung.com; jt77.jang@samsung.com; > >> dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > >> jangsub.yi@samsung.com; cw9316.lee@samsung.com; > >> sh8267.baek@samsungcom; wkon.kim@samsung.com > >> Subject: RE: [PATCH] mmc: sd: Add a variable to check a faulty device > >> > >>> In mobile devices, suspend/resume situations are frequent. > >>> In the case of a defective SD card in which initialization fails, > >>> unnecessary initialization time is consumed for each resume. > >>> A field is needed to check that SD card initialization has failed on > >>> the host. It could be used to remove unnecessary initialization. > >> I don't see where you are using this new init_failed field? > >> Maybe instead, elaborate the logic to free_card: to detect a broken sd. > >> e.g. instead of just if (!oldcard), if (!oldcard || ! > >> mmc_sd_alive(host)) or something. > >> > >> Thanks, > >> Avri > >> > > Thank you for your suggestion. > > I'm going to use it in mmc_rescan as below. > > > > e.g. > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index > > a8c17b4cd737..461cd75dc7ab 100644 > > --- a/drivers/mmc/core/core.c > > +++ b/drivers/mmc/core/core.c > > @@ -2210,7 +2210,7 @@ void mmc_rescan(struct work_struct *work) > > container_of(work, struct mmc_host, detect.work); > > int i; > > > > - if (host->rescan_disable) > > + if (host->rescan_disable || host->init_failed) > > return; > > I've seen SD cards that fail the first initialization attempt for both > 'valid' reasons (e.g. weird insertion timing) and things like out-of-spec > initialization time from the card, outright disabling these on the first > fail is a bit too much IMO. > > Kind Regards, > Christian I agree with you. It's a bit too much. It's just simple example. Anyway, It's difficult to distinguish between NO card and a faulty card. That's why I'd like to merge this. It helps that we check if it's a faulty card or not in a dump.
On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> wrote: > > In mobile devices, suspend/resume situations are frequent. > In the case of a defective SD card in which initialization fails, > unnecessary initialization time is consumed for each resume. > A field is needed to check that SD card initialization has failed > on the host. It could be used to remove unnecessary initialization. It's not clear to me, under what circumstance you want to optimize for. Is the SD card ever getting properly initialized during boot? Kind regards Uffe > > Signed-off-by: Seunghui Lee <sh043.lee@samsung.com> > --- > drivers/mmc/core/sd.c | 12 +++++++++++- > drivers/mmc/core/slot-gpio.c | 1 + > include/linux/mmc/host.h | 1 + > 3 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c > index c3e554344c99..f0eb3864dc24 100644 > --- a/drivers/mmc/core/sd.c > +++ b/drivers/mmc/core/sd.c > @@ -1410,6 +1410,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, > bool v18_fixup_failed = false; > > WARN_ON(!host->claimed); > + host->init_failed = false; > retry: > err = mmc_sd_get_cid(host, ocr, cid, &rocr); > if (err) > @@ -1752,6 +1753,8 @@ static int _mmc_sd_resume(struct mmc_host *host) > > mmc_power_up(host, host->card->ocr); > err = mmc_sd_init_card(host, host->card->ocr, host->card); > + if (err) > + host->init_failed = true; > mmc_card_clr_suspended(host->card); > > out: > @@ -1803,8 +1806,12 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) > > static int mmc_sd_hw_reset(struct mmc_host *host) > { > + int err; > mmc_power_cycle(host, host->card->ocr); > - return mmc_sd_init_card(host, host->card->ocr, host->card); > + err = mmc_sd_init_card(host, host->card->ocr, host->card); > + if (err) > + host->init_failed = true; > + return err; > } > > static const struct mmc_bus_ops mmc_sd_ops = { > @@ -1891,5 +1898,8 @@ int mmc_attach_sd(struct mmc_host *host) > pr_err("%s: error %d whilst initialising SD card\n", > mmc_hostname(host), err); > > + if (err) > + host->init_failed = true; > + > return err; > } > diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c > index 2a2d949a9344..93d081c7dd53 100644 > --- a/drivers/mmc/core/slot-gpio.c > +++ b/drivers/mmc/core/slot-gpio.c > @@ -33,6 +33,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) > struct mmc_gpio *ctx = host->slot.handler_priv; > > host->trigger_card_event = true; > + host->init_failed = false; > mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms)); > > return IRQ_HANDLED; > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h > index 2f445c651742..1d75cfdbf981 100644 > --- a/include/linux/mmc/host.h > +++ b/include/linux/mmc/host.h > @@ -467,6 +467,7 @@ struct mmc_host { > struct timer_list retune_timer; /* for periodic re-tuning */ > > bool trigger_card_event; /* card_event necessary */ > + bool init_failed; /* check if failed to initialize */ > > struct mmc_card *card; /* device attached to this host */ > > -- > 2.29.0 >
> -----Original Message----- > From: Ulf Hansson <ulf.hansson@linaro.org> > Sent: Wednesday, February 14, 2024 8:27 PM > To: Seunghui Lee <sh043.lee@samsung.com> > Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org; > gregkh@linuxfoundation.org; avri.altman@wdc.com; grant.jung@samsungcom; > jt77.jang@samsung.com; dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > jangsub.yi@samsung.com; cw9316.lee@samsung.com; sh8267.baek@samsungcom; > wkon.kim@samsung.com > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty device > > On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> wrote: > > > > In mobile devices, suspend/resume situations are frequent. > > In the case of a defective SD card in which initialization fails, > > unnecessary initialization time is consumed for each resume. > > A field is needed to check that SD card initialization has failed on > > the host. It could be used to remove unnecessary initialization. > > It's not clear to me, under what circumstance you want to optimize for. > > Is the SD card ever getting properly initialized during boot? > > Kind regards > Uffe > We receive a lot of reports about SD card issues in the market. There was no problem with the first time at the time of use, and there are many cases where people recognize that it is not recognized later on. In most cases, this is a problem with the SD card itself. SD card users cannot determine whether or not an SD card is a problem, so they should be guided in this regard. It is necessary to distinguish whether the SD card is inserted but unrecognized or the SD card itself is not inserted, and if there is a field that can check for initialization failure, it will facilitate guidance, so we considered the patch. The variable's usage is expected to be used through the sysfs node in the vendor module. > > > > Signed-off-by: Seunghui Lee <sh043.lee@samsung.com> > > --- > > drivers/mmc/core/sd.c | 12 +++++++++++- > > drivers/mmc/core/slot-gpio.c | 1 + > > include/linux/mmc/host.h | 1 + > > 3 files changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index > > c3e554344c99..f0eb3864dc24 100644 > > --- a/drivers/mmc/core/sd.c > > +++ b/drivers/mmc/core/sd.c > > @@ -1410,6 +1410,7 @@ static int mmc_sd_init_card(struct mmc_host *host, > u32 ocr, > > bool v18_fixup_failed = false; > > > > WARN_ON(!host->claimed); > > + host->init_failed = false; > > retry: > > err = mmc_sd_get_cid(host, ocr, cid, &rocr); > > if (err) > > @@ -1752,6 +1753,8 @@ static int _mmc_sd_resume(struct mmc_host *host) > > > > mmc_power_up(host, host->card->ocr); > > err = mmc_sd_init_card(host, host->card->ocr, host->card); > > + if (err) > > + host->init_failed = true; > > mmc_card_clr_suspended(host->card); > > > > out: > > @@ -1803,8 +1806,12 @@ static int mmc_sd_runtime_resume(struct > > mmc_host *host) > > > > static int mmc_sd_hw_reset(struct mmc_host *host) { > > + int err; > > mmc_power_cycle(host, host->card->ocr); > > - return mmc_sd_init_card(host, host->card->ocr, host->card); > > + err = mmc_sd_init_card(host, host->card->ocr, host->card); > > + if (err) > > + host->init_failed = true; > > + return err; > > } > > > > static const struct mmc_bus_ops mmc_sd_ops = { @@ -1891,5 +1898,8 @@ > > int mmc_attach_sd(struct mmc_host *host) > > pr_err("%s: error %d whilst initialising SD card\n", > > mmc_hostname(host), err); > > > > + if (err) > > + host->init_failed = true; > > + > > return err; > > } > > diff --git a/drivers/mmc/core/slot-gpio.c > > b/drivers/mmc/core/slot-gpio.c index 2a2d949a9344..93d081c7dd53 100644 > > --- a/drivers/mmc/core/slot-gpio.c > > +++ b/drivers/mmc/core/slot-gpio.c > > @@ -33,6 +33,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void > *dev_id) > > struct mmc_gpio *ctx = host->slot.handler_priv; > > > > host->trigger_card_event = true; > > + host->init_failed = false; > > mmc_detect_change(host, > > msecs_to_jiffies(ctx->cd_debounce_delay_ms)); > > > > return IRQ_HANDLED; > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index > > 2f445c651742..1d75cfdbf981 100644 > > --- a/include/linux/mmc/host.h > > +++ b/include/linux/mmc/host.h > > @@ -467,6 +467,7 @@ struct mmc_host { > > struct timer_list retune_timer; /* for periodic re-tuning */ > > > > bool trigger_card_event; /* card_event necessary */ > > + bool init_failed; /* check if failed to > initialize */ > > > > struct mmc_card *card; /* device attached to this host > */ > > > > -- > > 2.29.0 > >
On Thu, Feb 15, 2024 at 10:03:45AM +0900, 이승희 wrote: > > -----Original Message----- > > From: Ulf Hansson <ulf.hansson@linaro.org> > > Sent: Wednesday, February 14, 2024 8:27 PM > > To: Seunghui Lee <sh043.lee@samsung.com> > > Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org; > > gregkh@linuxfoundation.org; avri.altman@wdc.com; grant.jung@samsung.com; > > jt77.jang@samsung.com; dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > > jangsub.yi@samsung.com; cw9316.lee@samsung.com; sh8267.baek@samsung.com; > > wkon.kim@samsung.com > > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty device > > > > On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> wrote: > > > > > > In mobile devices, suspend/resume situations are frequent. > > > In the case of a defective SD card in which initialization fails, > > > unnecessary initialization time is consumed for each resume. > > > A field is needed to check that SD card initialization has failed on > > > the host. It could be used to remove unnecessary initialization. > > > > It's not clear to me, under what circumstance you want to optimize for. > > > > Is the SD card ever getting properly initialized during boot? > > > > Kind regards > > Uffe > > > We receive a lot of reports about SD card issues in the market. > There was no problem with the first time at the time of use, and there are many cases where people recognize that it is not recognized later on. In most cases, this is a problem with the SD card itself. > > SD card users cannot determine whether or not an SD card is a problem, so they should be guided in this regard. > It is necessary to distinguish whether the SD card is inserted but unrecognized or the SD card itself is not inserted, and if there is a field that can check for initialization failure, it will facilitate guidance, so we considered the patch. > > The variable's usage is expected to be used through the sysfs node in the vendor module. What "vendor module"? You need to include all of the needed code here please. thanks, greg k-h
On Thu, 15 Feb 2024 at 02:03, 이승희 <sh043.lee@samsung.com> wrote: > > > -----Original Message----- > > From: Ulf Hansson <ulf.hansson@linaro.org> > > Sent: Wednesday, February 14, 2024 8:27 PM > > To: Seunghui Lee <sh043.lee@samsung.com> > > Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org; > > gregkh@linuxfoundation.org; avri.altman@wdc.com; grant.jung@samsung.com; > > jt77.jang@samsung.com; dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > > jangsub.yi@samsung.com; cw9316.lee@samsung.com; sh8267.baek@samsung.com; > > wkon.kim@samsung.com > > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty device > > > > On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> wrote: > > > > > > In mobile devices, suspend/resume situations are frequent. > > > In the case of a defective SD card in which initialization fails, > > > unnecessary initialization time is consumed for each resume. > > > A field is needed to check that SD card initialization has failed on > > > the host. It could be used to remove unnecessary initialization. > > > > It's not clear to me, under what circumstance you want to optimize for. > > > > Is the SD card ever getting properly initialized during boot? > > > > Kind regards > > Uffe > > > We receive a lot of reports about SD card issues in the market. > There was no problem with the first time at the time of use, and there are many cases where people recognize that it is not recognized later on. In most cases, this is a problem with the SD card itself. Right. Thanks for clarifying. A follow up question from me is then, do you know more exactly *why* the SD cards encounter problems? In the past people have told me that powering on/off an SD card during system suspend/resume, too frequently, could damage the card. For non-removable cards, the card stays powered-off even after a system resume, but instead gets powered-on (and re-initialized) when there is a new request for it. In other words, if the problem is related to too frequent powering on/off the card, my advice would be to test with having the card set non-removable (the DT property for this is "non-removable"), to see if that can help. If that solves the problem, we can work towards another common solution instead. > > SD card users cannot determine whether or not an SD card is a problem, so they should be guided in this regard. > It is necessary to distinguish whether the SD card is inserted but unrecognized or the SD card itself is not inserted, and if there is a field that can check for initialization failure, it will facilitate guidance, so we considered the patch. > > The variable's usage is expected to be used through the sysfs node in the vendor module. As Greg said, please provide the complete code. Although, I want to stress already at this point, I don't see a solution with sysfs being the correct thing to do here. The kernel should be able to manage this problem itself. [...] Kind regards Uffe
> -----Original Message----- > From: Greg KH <gregkh@linuxfoundation.org> > Sent: Thursday, February 15, 2024 5:07 PM > To: 이승희 <sh043.lee@samsung.com> > Cc: 'Ulf Hansson' <ulf.hansson@linaro.org>; linux-mmc@vger.kernel.org; > linux-kernel@vger.kernel.org; avri.altman@wdc.com; grant.jung@samsung.com; > jt77.jang@samsung.com; dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > jangsub.yi@samsung.com; cw9316.lee@samsung.com; sh8267.baek@samsung.com; > wkon.kim@samsung.com > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty device > > On Thu, Feb 15, 2024 at 10:03:45AM +0900, 이승희 wrote: > > > -----Original Message----- > > > From: Ulf Hansson <ulf.hansson@linaro.org> > > > Sent: Wednesday, February 14, 2024 8:27 PM > > > To: Seunghui Lee <sh043.lee@samsung.com> > > > Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org; > > > gregkh@linuxfoundation.org; avri.altman@wdc.com; > > > grant.jung@samsung.com; jt77.jang@samsung.com; > > > dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > > > jangsub.yi@samsung.com; cw9316.lee@samsung.com; > > > sh8267.baek@samsung.com; wkon.kim@samsung.com > > > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty > > > device > > > > > > On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> > wrote: > > > > > > > > In mobile devices, suspend/resume situations are frequent. > > > > In the case of a defective SD card in which initialization fails, > > > > unnecessary initialization time is consumed for each resume. > > > > A field is needed to check that SD card initialization has failed > > > > on the host. It could be used to remove unnecessary initialization. > > > > > > It's not clear to me, under what circumstance you want to optimize for. > > > > > > Is the SD card ever getting properly initialized during boot? > > > > > > Kind regards > > > Uffe > > > > > We receive a lot of reports about SD card issues in the market. > > There was no problem with the first time at the time of use, and there > are many cases where people recognize that it is not recognized later on. > In most cases, this is a problem with the SD card itself. > > > > SD card users cannot determine whether or not an SD card is a problem, > so they should be guided in this regard. > > It is necessary to distinguish whether the SD card is inserted but > unrecognized or the SD card itself is not inserted, and if there is a > field that can check for initialization failure, it will facilitate > guidance, so we considered the patch. > > > > The variable's usage is expected to be used through the sysfs node in > the vendor module. > > What "vendor module"? You need to include all of the needed code here > please. > > thanks, > > greg k-h This only purpose of this variable is to identify a faulty card on host side. In the past, we can identify that the card is inserted or not with reading get_cd() function. But now, most mobile devices use hybrid type of SD card tray. If the tray is inserted, the return value of get_cd is the same whatever the SD card is inserted or not. It can help us diagonose the status of a SD card as well. Here is the example of usage. static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { struct mmc_host *host = dev_get_drvdata(dev); struct mmc_card *card = host->card; char *status = NULL; if (card) status = mmc_card_readonly(card) ? "PERMWP" : "NORMAL"; else status = host->init_failed ? "INITFAIL" : "NOCARD"; return sysfs_emit(buf, "%s\n", status); } As for the sysfs node, it should keep the path of node with or without the SD card. That's why I mention the vendor module. If I need to update the commit's comment, I'll fix it. If someone has the better idea(e.g. code, comment), please suggest it. Thank you for reviewing this. Seunghui Lee.
On Thu, Feb 15, 2024 at 08:15:45PM +0900, 이승희 wrote: > > -----Original Message----- > > From: Greg KH <gregkh@linuxfoundation.org> > > Sent: Thursday, February 15, 2024 5:07 PM > > To: 이승희 <sh043.lee@samsung.com> > > Cc: 'Ulf Hansson' <ulf.hansson@linaro.org>; linux-mmc@vger.kernel.org; > > linux-kernel@vger.kernel.org; avri.altman@wdc.com; grant.jung@samsung.com; > > jt77.jang@samsung.com; dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; > > jangsub.yi@samsung.com; cw9316.lee@samsung.com; sh8267.baek@samsung.com; > > wkon.kim@samsung.com > > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty device Does this really belong in the body of the email? You might want a nicer email client :) > > > The variable's usage is expected to be used through the sysfs node in > > the vendor module. > > > > What "vendor module"? You need to include all of the needed code here > > please. > > > > thanks, > > > > greg k-h > > This only purpose of this variable is to identify a faulty card on host side. > > In the past, we can identify that the card is inserted or not with reading get_cd() function. > But now, most mobile devices use hybrid type of SD card tray. > If the tray is inserted, the return value of get_cd is the same whatever the SD card is inserted or not. > It can help us diagonose the status of a SD card as well. > > Here is the example of usage. > > static ssize_t status_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > struct mmc_host *host = dev_get_drvdata(dev); > struct mmc_card *card = host->card; > char *status = NULL; > > if (card) > status = mmc_card_readonly(card) ? "PERMWP" : "NORMAL"; > else > status = host->init_failed ? "INITFAIL" : "NOCARD"; > > return sysfs_emit(buf, "%s\n", status); > } What will userspace do with this information? And why isn't this part of the patch you submitted? > As for the sysfs node, it should keep the path of node with or without the SD card. > That's why I mention the vendor module. What vendor module? What do you mean by vendor module? You know we can't add code to the kernel that is only used by code that is NOT in our kernel tree. You don't want us to take stuff like that, so why is it being proposed here? confused, greg k-h
> -----Original Message----- > > > On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> > wrote: > > > > > > > > In mobile devices, suspend/resume situations are frequent. > > > > In the case of a defective SD card in which initialization fails, > > > > unnecessary initialization time is consumed for each resume. > > > > A field is needed to check that SD card initialization has failed > > > > on the host. It could be used to remove unnecessary initialization. > > > > > > It's not clear to me, under what circumstance you want to optimize for. > > > > > > Is the SD card ever getting properly initialized during boot? > > > > > > Kind regards > > > Uffe > > > > > We receive a lot of reports about SD card issues in the market. > > There was no problem with the first time at the time of use, and there > are many cases where people recognize that it is not recognized later on. > In most cases, this is a problem with the SD card itself. > > Right. Thanks for clarifying. > > A follow up question from me is then, do you know more exactly *why* the > SD cards encounter problems? > > In the past people have told me that powering on/off an SD card during > system suspend/resume, too frequently, could damage the card. For non- > removable cards, the card stays powered-off even after a system resume, > but instead gets powered-on (and re-initialized) when there is a new > request for it. > > In other words, if the problem is related to too frequent powering on/off > the card, my advice would be to test with having the card set non- > removable (the DT property for this is "non-removable"), to see if that > can help. If that solves the problem, we can work towards another common > solution instead. > I understand your focus on finding the root cause of the problem. However, unlike internal storage, there is a limit to analyzing cards that have problems in the market. This is because there are many different SD card manufacturers and many manufacturers leave it to OEMs. For deferred resume, a responsiveness problem occurs on the user side on mobile devices. The response time of the initializing SD card initialization in the application seems to be slow. Currently, it seems to be a good structure for the first initialization at runtime resume. Regarding non-removable, We will test if we are given an opportunity to further analyze the cards occurring in the market. However, SD card detection is also used as a wakeup source and must be inserted/removed so I'll consider it for testing purposes. Thank you for the good suggestions though. > > > > SD card users cannot determine whether or not an SD card is a problem, > so they should be guided in this regard. > > It is necessary to distinguish whether the SD card is inserted but > unrecognized or the SD card itself is not inserted, and if there is a > field that can check for initialization failure, it will facilitate > guidance, so we considered the patch. > > > > The variable's usage is expected to be used through the sysfs node in > the vendor module. > > As Greg said, please provide the complete code. > > Although, I want to stress already at this point, I don't see a solution > with sysfs being the correct thing to do here. The kernel should be able > to manage this problem itself. > > [...] > > Kind regards > Uffe I understand it and reconsider this commit. Thank you for reviewing this. Seunghui Lee.
> -----Original Message----- > On Thu, Feb 15, 2024 at 08:15:45PM +0900, 이승희 wrote: > > > Subject: Re: [PATCH] mmc: sd: Add a variable to check a faulty > > > device > > Does this really belong in the body of the email? You might want a nicer > email client :) > It was caused by unfamiliarity with upstream. Sorry for the inconvenience. > > > > The variable's usage is expected to be used through the sysfs node > > > > in > > > the vendor module. > > > > > > What "vendor module"? You need to include all of the needed code > > > here please. > > > > > > thanks, > > > > > > greg k-h > > > > This only purpose of this variable is to identify a faulty card on host > side. > > > > In the past, we can identify that the card is inserted or not with > reading get_cd() function. > > But now, most mobile devices use hybrid type of SD card tray. > > If the tray is inserted, the return value of get_cd is the same whatever > the SD card is inserted or not. > > It can help us diagonose the status of a SD card as well. > > > > Here is the example of usage. > > > > static ssize_t status_show(struct device *dev, > > struct device_attribute *attr, char *buf) { > > struct mmc_host *host = dev_get_drvdata(dev); > > struct mmc_card *card = host->card; > > char *status = NULL; > > > > if (card) > > status = mmc_card_readonly(card) ? "PERMWP" : "NORMAL"; > > else > > status = host->init_failed ? "INITFAIL" : "NOCARD"; > > > > return sysfs_emit(buf, "%s\n", status); } > > What will userspace do with this information? > > And why isn't this part of the patch you submitted? > > > As for the sysfs node, it should keep the path of node with or without > the SD card. > > That's why I mention the vendor module. > > What vendor module? What do you mean by vendor module? You know we can't > add code to the kernel that is only used by code that is NOT in our kernel > tree. You don't want us to take stuff like that, so why is it being > proposed here? > > confused, > > greg k-h We need to inform users that there is a problem with the SD card. There is a diagnostic tool in the customer service app, Adding a sysfs node is under consideration so that the tool can diagnose the SD card. To do this, a node capable of diagnosing an SD card is needed regardless of whether an SD card is present or not. Since I understand that the proposed sysfs node is difficult to apply to the kernel, no separate commit was posted. So, I created this PR because I needed a variable to identify the faulty device. I will consider this part again. And if you have any other good ideas, please feel free to suggest them. Thank you for your review. Seunghui Lee.
On Fri, 16 Feb 2024 at 02:14, 이승희 <sh043.lee@samsung.com> wrote: > > > -----Original Message----- > > > > On Tue, 13 Feb 2024 at 06:13, Seunghui Lee <sh043.lee@samsung.com> > > wrote: > > > > > > > > > > In mobile devices, suspend/resume situations are frequent. > > > > > In the case of a defective SD card in which initialization fails, > > > > > unnecessary initialization time is consumed for each resume. > > > > > A field is needed to check that SD card initialization has failed > > > > > on the host. It could be used to remove unnecessary initialization. > > > > > > > > It's not clear to me, under what circumstance you want to optimize for. > > > > > > > > Is the SD card ever getting properly initialized during boot? > > > > > > > > Kind regards > > > > Uffe > > > > > > > We receive a lot of reports about SD card issues in the market. > > > There was no problem with the first time at the time of use, and there > > are many cases where people recognize that it is not recognized later on. > > In most cases, this is a problem with the SD card itself. > > > > Right. Thanks for clarifying. > > > > A follow up question from me is then, do you know more exactly *why* the > > SD cards encounter problems? > > > > In the past people have told me that powering on/off an SD card during > > system suspend/resume, too frequently, could damage the card. For non- > > removable cards, the card stays powered-off even after a system resume, > > but instead gets powered-on (and re-initialized) when there is a new > > request for it. > > > > In other words, if the problem is related to too frequent powering on/off > > the card, my advice would be to test with having the card set non- > > removable (the DT property for this is "non-removable"), to see if that > > can help. If that solves the problem, we can work towards another common > > solution instead. > > > > I understand your focus on finding the root cause of the problem. > However, unlike internal storage, there is a limit to analyzing cards that have problems in the market. > This is because there are many different SD card manufacturers and many manufacturers leave it to OEMs. I understand that this isn't an easy task, but for sure it should be doable. There are plenty of less robust SD cards out there, let's just try to find one and see if we can break it. :-) > > For deferred resume, a responsiveness problem occurs on the user side on mobile devices. > The response time of the initializing SD card initialization in the application seems to be slow. > Currently, it seems to be a good structure for the first initialization at runtime resume. You are correct - an initial latency for the *first* I/O request will be added. On the other hand, if the SD card remains unused after a system resume, there should be some energy to save, as the card would then remain powered-off. Moreover, if we also can avoid breaking the SD card, I'm sure it would be worth it. > > Regarding non-removable, > We will test if we are given an opportunity to further analyze the cards occurring in the market. > However, SD card detection is also used as a wakeup source and must be inserted/removed so I'll consider it for testing purposes. Yes, I understand that part. A proper solution needs to take care of removable cards, of course. The suggestion to set the slot as non-removable, was just to try to understand if that would solve the problem of breaking SD cards. If the card-detect irq, can be configured as a wakeup source, I think we should be able to distinguish - if we need to do a power-on (re-init) of the SD card during system resume or if we can avoid it. I try to get some time to put together a patch for this, no promises for when, but I will keep you posted. [...] Kind regards Uffe
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index c3e554344c99..f0eb3864dc24 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1410,6 +1410,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, bool v18_fixup_failed = false; WARN_ON(!host->claimed); + host->init_failed = false; retry: err = mmc_sd_get_cid(host, ocr, cid, &rocr); if (err) @@ -1752,6 +1753,8 @@ static int _mmc_sd_resume(struct mmc_host *host) mmc_power_up(host, host->card->ocr); err = mmc_sd_init_card(host, host->card->ocr, host->card); + if (err) + host->init_failed = true; mmc_card_clr_suspended(host->card); out: @@ -1803,8 +1806,12 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) static int mmc_sd_hw_reset(struct mmc_host *host) { + int err; mmc_power_cycle(host, host->card->ocr); - return mmc_sd_init_card(host, host->card->ocr, host->card); + err = mmc_sd_init_card(host, host->card->ocr, host->card); + if (err) + host->init_failed = true; + return err; } static const struct mmc_bus_ops mmc_sd_ops = { @@ -1891,5 +1898,8 @@ int mmc_attach_sd(struct mmc_host *host) pr_err("%s: error %d whilst initialising SD card\n", mmc_hostname(host), err); + if (err) + host->init_failed = true; + return err; } diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 2a2d949a9344..93d081c7dd53 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -33,6 +33,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) struct mmc_gpio *ctx = host->slot.handler_priv; host->trigger_card_event = true; + host->init_failed = false; mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms)); return IRQ_HANDLED; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 2f445c651742..1d75cfdbf981 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -467,6 +467,7 @@ struct mmc_host { struct timer_list retune_timer; /* for periodic re-tuning */ bool trigger_card_event; /* card_event necessary */ + bool init_failed; /* check if failed to initialize */ struct mmc_card *card; /* device attached to this host */