From patchwork Thu Oct 17 13:57:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 176644 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp965095ill; Thu, 17 Oct 2019 06:57:55 -0700 (PDT) X-Received: by 2002:a2e:5354:: with SMTP id t20mr2393896ljd.30.1571320675504; Thu, 17 Oct 2019 06:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320675; cv=none; d=google.com; s=arc-20160816; b=ZcaP6uqDF+PMF2eflrprlickHrNLCrYokHEDDEy+js7OF7MF38wmsiJKdBPmSUfLIJ z84ZV5KBRqNZNepPWCP87/hKD+FJIyeNInj9KIpJW6q3ZGURjsfZFAQHlwhSNnyb0ER+ MkuxZsIag8MxLspQmJO23FZurDEK9jn8i7rdHXEScHvFgoPWG84+WT5gQKHVTyxxZ3KV CNTAldcVsjNn8b+yU+ZtaDeCpxCf+kWVX8QYBn4L9EfEmOAsaM5VEXps9+cPk/q+k4oQ FmQaL6YYBemWs9ltM5d0kESYvv3pGWS6QHI/Vdbv15JPbSqL2jCpirf04ttLFZbKnDu2 PtPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W/IUaSbhHG4wv7nj6S/SBAPb0kMokkckyKlISAFdDyg=; b=q13MslynLJ1iPh+VDztJmYRPMrD5A1qeE8ldZpcv8hoqSYhGjQEvzsXWrjnRwMWq19 j7nwqXa3Gkmc8LZwAnJDSj7j0D1e3x7MlS3DYBUx9c6h1SuDDdquB+nAsrfCyqLs97dI GxBitYmkg93ONYoVbs61h82JW0Rgk3NJCs1APRqu+jqImXR3ccKdTI5D6GfptI/N1SPZ o469SQC2LxSW/jQMAUcJexSFknmjTq/UHpL9uXmVDQCB5pr7dSRK4e2htIXXP6z3QUiF cjxNoxaOvpdhzj8fURByJMK1MZ1yQyVMAstu7nsdZ3DXNWJ4do110S6Fjvn1Jbe2y/28 dG4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t+8qBMvE; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w4sor750583lfk.40.2019.10.17.06.57.55 for (Google Transport Security); Thu, 17 Oct 2019 06:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t+8qBMvE; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W/IUaSbhHG4wv7nj6S/SBAPb0kMokkckyKlISAFdDyg=; b=t+8qBMvE/y8RBPIQXO8pK0OYJq/4UahUSKfRo968q0KRtIBLbZxzfkR8l0K1moMpN2 kgLf2lJ9VJmqhrDP8vKnut+e46V9D+014tJ53GQNrIB4xCTnXih8D4s56ub1qy2PaS68 VSHSB0aTl/WObl74yg3tHB++wvXtlOfuV8eHWk0XVAyy+VkHpJn5edYxdECRR23iMru9 dqfkTPGhjS6pgcu92sKKBpc9SfdSW2PS8a3Ts1q1d4hvNh9BPOhOkbfMTdwNbndTUoD8 +iMCWx+hfBZHmQvxgKGHfuNzmwIQTldrR8AvzVots22cyjseUcGhRzRp3J6cZ//N2VXU IWAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W/IUaSbhHG4wv7nj6S/SBAPb0kMokkckyKlISAFdDyg=; b=OpfSdTIZiPDoY0VXKLQ7RCbZFUaGTzFGEqjOk0aowEtxtKEJT1qtP1hFvTwNGUaHTk /+qVBI0TMwHjAe/IVsrMOyBEbKM82GzAnfmfMU6DxWN7LArK0DNQTSEw10K5Rx7ci5cf vUYRy+V4azxBlItY07Xmz1uz6wS2tKcRwIn9/j3eYQURiqf+13sA9OFlTw/DKi0ZLNtH FwjQ40XjudSdjYrCdJiyuQhVQkBZkUEv10tb8vJf6lkpi4OJcxm/rAreh1N4H+LuW9ZU 8AakH271ypPYuQ0vYhbiQ199WeGBKUtLl3R/Iyhz0UfU8OaiRv4a6xsdaC0eP9QzqBmX vzXg== X-Gm-Message-State: APjAAAVXMivk/DktFZksZ6xssnWF5V3aaq3xV/40UPS22kh/U19dbjMq bMze+2WIOtIUaDwp1TksUXurRJln X-Google-Smtp-Source: APXvYqwBVphSUSV/EpVwjWyAvyg263gkH8JSDcG/pQR4rUzerRHYeILmO4ZHlINFlt4u0aJj7QmJEg== X-Received: by 2002:a19:5504:: with SMTP id n4mr2529787lfe.106.1571320675138; Thu, 17 Oct 2019 06:57:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id x17sm975088lji.62.2019.10.17.06.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:57:54 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Kalle Valo , Tony Lindgren , Wen Gong , Erik Stromdahl , Eyal Reizer , linux-wireless@vger.kernel.org Subject: [PATCH 1/2] mmc: core: Drop check for mmc_card_is_removable() in mmc_rescan() Date: Thu, 17 Oct 2019 15:57:38 +0200 Message-Id: <20191017135739.1315-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017135739.1315-1-ulf.hansson@linaro.org> References: <20191017135739.1315-1-ulf.hansson@linaro.org> Upfront in mmc_rescan() we use the host->rescan_entered flag, to allow scanning only once for non-removable cards. Therefore, it's also not possible that we can have bus attached, when we are scanning non-removable cards. For this reason, let' drop the check for mmc_card_is_removable() as it's redundant. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Douglas Anderson diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 221127324709..6f8342702c73 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2297,11 +2297,8 @@ void mmc_rescan(struct work_struct *work) mmc_bus_get(host); - /* - * if there is a _removable_ card registered, check whether it is - * still present - */ - if (host->bus_ops && !host->bus_dead && mmc_card_is_removable(host)) + /* Verify a registered card to be functional, else remove it. */ + if (host->bus_ops && !host->bus_dead) host->bus_ops->detect(host); host->detect_change = 0; From patchwork Thu Oct 17 13:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 176645 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp965127ill; Thu, 17 Oct 2019 06:57:57 -0700 (PDT) X-Received: by 2002:a2e:8e87:: with SMTP id z7mr325444ljk.45.1571320677493; Thu, 17 Oct 2019 06:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320677; cv=none; d=google.com; s=arc-20160816; b=QxFWgYOEltVsvqFwj9zAnAl/+itVAQEgtte0qlMkAjlLTkJ8LL2UcR8uQDEGaYsGUp YTv9ruVjc03hjmAuVOAIFvmXOQUdcv3Uuh/4FbbTuxVWk3dZYVk940TeWPSWeApdx4Yo om6fT/faKw8o1ruzzTpwe0HtlMzI006hMqSpDDAQ0Zrs0B5GWmvL2U41D2y4x6l11Z5b rAyQmBgDyyEjsGLpDrv1juqWETf/PwgfvS2Pc6vd0dPZIbbj2M+fpnZ65rd69yotKmq8 ghJFvUoF046XD+RdiMe7tDiSgMYcwkgOtX/32bOxi6jp/BCuMHWZHoUHC+E+/TrghsCv AG/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZnxS2XcZzdmlSU7FWbs0spB90/BTPVuxJl5GN2SI/co=; b=kjpW7R6rmVaBBjT7ucq1Qb/HtkGl+dZFOsq6UZEUGwF/wMfDRSJtfzmkDwyLAzwHRz Hp7nxyiSezUCiuvQeNc8KzENSYQCvF2IYj7yFCpAW9w2BlHWwoA6IHlCVhEpoxvS26NI HN1QobGWoSxY5vM5GpML6RsmH6LAIlibfxj9nXbLlHSE/zT/X5Th2khBDJaADyrOrfol 9XsemigvpuClIDl9jPYZrFfw0T6Mzn7AsTI3UKxM9JeXs1rWWV1PpsPpr8XVUgJqbRri /dVQguukdGjLlA3R3IAVuGkQG/IGrexQW0kp5dVc5KLgXEE2bm/KXl2liDeWGP9RtoSy 1PtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LATakpY7; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c9sor1459048ljd.3.2019.10.17.06.57.57 for (Google Transport Security); Thu, 17 Oct 2019 06:57:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LATakpY7; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZnxS2XcZzdmlSU7FWbs0spB90/BTPVuxJl5GN2SI/co=; b=LATakpY7OV1xSLKlXscaDeuX8qO2K20YfT4oZdMmUy4lt6LTHrt8mzvOSRQFx2X6F7 YBfZ2gv+CnJFNq9l4xoiYuOdFs3HtO6jZwP7PrpwEoN/oipWcUhv0sWI9yl5jOoBZ1wB mYBlnkIEEUcSbWz2QyjAdanz29kpRSBdnI87Eu//eSD07Z+29lqLAbxXyDDvBMmK8I33 VCBoxtduq36x8yIJ+AnUM6do3Ij9mUSb0XdcY0VTaJlbv9CM0ItuQCrUcprjFnxQVn9+ 9cI8DcfPTCuEGO2ZsJ8bgijSt9qwKh16MqxVvZgxoYmOdiSNHVIICpu51UjtvMrrkCus c7xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZnxS2XcZzdmlSU7FWbs0spB90/BTPVuxJl5GN2SI/co=; b=PGOHp3uwIo5hTSettJMHHnZBhuD0Q+iuQTHmFq8sjCoL+4gSsC62Gvb12021qOiIc0 bnfqhILFERD1+4tsVOj0WsslHQ9N4ze7WHMWAh5FWMNvsdJAsSSQGZoe9ENcVSos7dZ3 rguLXfaAfUtCYcuuWFhuMsxALo2dDj9HSBdwbiY5nP1vVdWxpx/XFnoayX0dTlBCGnI/ cEhSUnWHnJqg0OS+1Z0IipLURBhmAMeFxWYYIgB3YMziaPS08/38Z8lI482QSMoGLAAZ SJxyiOGxzQATGnNg20qpKgA5YfhR077sSni40HjFmYu1Yy9V17GO3/Zz4md/6okt7Ivi J88w== X-Gm-Message-State: APjAAAXCiG2FE1TMjvH7f9Wd/dCrpt7KSjQaIFJQfYCUiPdqYkUh6eqA drH/IN6JXRalDwDBvFqglsZ/JHoX X-Google-Smtp-Source: APXvYqw3vvsTZvTtxmCVOnu1swpXk54GoLGrxLXWlh71VuyIjZ7b3hcGeCd4vUWQTzz2BawLP8n5jw== X-Received: by 2002:a2e:9848:: with SMTP id e8mr2699331ljj.128.1571320676674; Thu, 17 Oct 2019 06:57:56 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id x17sm975088lji.62.2019.10.17.06.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:57:56 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Kalle Valo , Tony Lindgren , Wen Gong , Erik Stromdahl , Eyal Reizer , linux-wireless@vger.kernel.org Subject: [PATCH 2/2] mmc: core: Re-work HW reset for SDIO cards Date: Thu, 17 Oct 2019 15:57:39 +0200 Message-Id: <20191017135739.1315-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017135739.1315-1-ulf.hansson@linaro.org> References: <20191017135739.1315-1-ulf.hansson@linaro.org> It have turned out that it's not a good idea to try to power cycle and to re-initialize the SDIO card, via mmc_hw_reset. This because there may be multiple SDIO funcs attached to the same SDIO card. To solve this problem, we would need to inform each of the SDIO func in some way when mmc_sdio_hw_reset() gets called, but that isn't an entirely trivial operation. Therefore, let's instead take the easy way out, by triggering a card removal and force a new rescan of the SDIO card. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 3 +-- drivers/mmc/core/core.h | 2 ++ drivers/mmc/core/sdio.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6f8342702c73..39c4567e39d8 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1469,8 +1469,7 @@ void mmc_detach_bus(struct mmc_host *host) mmc_bus_put(host); } -static void _mmc_detect_change(struct mmc_host *host, unsigned long delay, - bool cd_irq) +void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq) { /* * If the device is configured as wakeup, we prevent a new sleep for diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 328c78dbee66..575ac0257af2 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -70,6 +70,8 @@ void mmc_rescan(struct work_struct *work); void mmc_start_host(struct mmc_host *host); void mmc_stop_host(struct mmc_host *host); +void _mmc_detect_change(struct mmc_host *host, unsigned long delay, + bool cd_irq); int _mmc_detect_card_removed(struct mmc_host *host); int mmc_detect_card_removed(struct mmc_host *host); diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 26cabd53ddc5..5d7462c223c3 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1050,8 +1050,15 @@ static int mmc_sdio_runtime_resume(struct mmc_host *host) static int mmc_sdio_hw_reset(struct mmc_host *host) { - mmc_power_cycle(host, host->card->ocr); - return mmc_sdio_reinit_card(host); + /* + * We may have more multiple SDIO funcs. Rather than to inform them all, + * let's trigger a removal and force a new rescan of the card. + */ + host->rescan_entered = 0; + mmc_card_set_removed(host->card); + _mmc_detect_change(host, 0, false); + + return 0; } static int mmc_sdio_sw_reset(struct mmc_host *host)