From patchwork Fri Jul 2 13:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 469551 Delivered-To: patches@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1400691jao; Fri, 2 Jul 2021 06:42:44 -0700 (PDT) X-Received: by 2002:a05:651c:504:: with SMTP id o4mr3847572ljp.357.1625233364775; Fri, 02 Jul 2021 06:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625233364; cv=none; d=google.com; s=arc-20160816; b=hHghLU+psGyJjOll8ssemNI+yfI94PUnToltP9ip+uHCSCLpHJOqJ7DDSpAY1N5F15 jPzkXRgZm4XYtOMQYSviE0ltlEtWDoK66CfZNirp30ZlMFu5EOS9BRYy+IK+LE5FbeH1 l2rgwyOZiVMmGWdV8eFkOQ+zyMd9MO35LMDIK6a3qLuIPVlxVucbHBPz+4Kp1Dw7naBr QHNiEQfYu0QnQxkstbfDqvDODBUNlSfPmt25ijc/Fd11E6DabGw6rYb90yvDqvdfZEvW TfI1pu0gTTFURY3EkQX+pjaDaKGbmoJ/SWxiWZDEZySVT8s9iZl6v528iZ0VIb7TfPhl XeNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=3pL4MvxeWog2IfLGYd7eKX1l2HS5OPUQFZV3aIXsKoU=; b=XRHX3xcuJuV/3/wtYSDAtq4yAGaIBApSZ2gpwcUz7tsjdQ1wohzhVtVSurbw/jd+zJ QFrsX1f2KToWCAZ/vflVXgocYaod7ZnAtyvZPAuZazEzM+7gecwKlCaRQdz6FxABb9eR 1VLFRMFp0Q+xWomK+59reauiyZ+tm14ErABYOqtayyrX8aohpZkLPscFVwiR04nXzCCg QQegBXBAVNXIB87SXCg48idPY880lln40fCr2Q8/IJWQwbXP8lqFp9j24wre1K91+nQm 5zaG4b5SLzciSw0remoMm77vKxenYAx1vYGyXfvbptD4iY3gu8fDKhHbM2gS+FmpKbtW M/Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nv08IjPc; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id r10sor1386449ljc.58.2021.07.02.06.42.44 for (Google Transport Security); Fri, 02 Jul 2021 06:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nv08IjPc; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 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 :mime-version:content-transfer-encoding; bh=3pL4MvxeWog2IfLGYd7eKX1l2HS5OPUQFZV3aIXsKoU=; b=nv08IjPcm+Hty4Sfpv6VlE2MwUc+YQ6djusyBTlemq2QO4zTYkE5Wliw8U9hmoCNH6 +8OoyCP2c0aigcm2jF8FsL2zPS6ew+KDiNDtTKLepR8Mf9f5x1m+ldINo5Qeqkk/M0Z+ k1b7E6CH4JqzukdAFcOHdOT0YmNi7+rCpogKoz0HLPCbHL4wlBTXrl/5wVPUAn3zI41s DHchW5QY943HsLRExewAcTc9iLyElLN7nVViRLAqyttIbanU973GIDlQtTfxcxfJrqbN S9/9gk9+8T8iCxwVIOSsgXbxWT3YK1xkIhDzUbKDjMOfqvaioD2TYsuOQ8Nin85Wyr4o Psdw== 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:mime-version:content-transfer-encoding; bh=3pL4MvxeWog2IfLGYd7eKX1l2HS5OPUQFZV3aIXsKoU=; b=L6z26igsY3B2BPoUU8GV7UsO83eiSWveFHnaj42aRhq3z14QGO7JbCJpdcOoTM0ve8 d/x1VIvOTccLcFUt8dINSaE1H8xCGptCXoxz8TmFvlngxNkkEx+HuHXij10IGxykN6+b y1oAxVnsyhNnILV8E5ZxUmKccHOtAc9Vr/A2R1i27BuBP/hX0b5OFnuZ5xoi9x7qBnWJ 9uPDlJXAz0GHsimqknEl3MEN27wY7wCKK4IVdOYvKYty/NbADbtWx3WQajxaUgWstolq xOiZ3seSw3btkCc/IrkzfXZfJIEV8ST/i6wzr3Yi+jyOT7iUz3pXlmrzEQJP5FmIL28Q 4c+w== X-Gm-Message-State: AOAM531HEymBywyc5XwwBUP1SWnaWcjKXhrS5EXb/yy+jAOKPjh5SDZQ AzjLkbJ5JejK9HPWIcs2u/0Ngei7 X-Google-Smtp-Source: ABdhPJwD0eRwhqZIHnQ52EyyAN9A8UlJ0xC8X2hYvZ5HvnpXibYcI5DKr+pTGJkxqY2tl1jB1dynPA== X-Received: by 2002:a2e:804d:: with SMTP id p13mr3936926ljg.324.1625233364409; Fri, 02 Jul 2021 06:42:44 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id u5sm277486lfg.268.2021.07.02.06.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 06:42:43 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Linus Walleij , Wolfram Sang , Shawn Lin , Christian Lohle , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mmc: core: Avoid hogging the CPU while polling for busy in the I/O err path Date: Fri, 2 Jul 2021 15:42:27 +0200 Message-Id: <20210702134229.357717-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702134229.357717-1-ulf.hansson@linaro.org> References: <20210702134229.357717-1-ulf.hansson@linaro.org> MIME-Version: 1.0 When mmc_blk_fix_state() sends a CMD12 to try to move the card into the transfer state, it calls card_busy_detect() to poll for the card's state with CMD13. This is done without any delays in between the commands being sent. Rather than fixing card_busy_detect() in this regards, let's instead convert into using the common mmc_poll_for_busy(), which also helps us to avoid open-coding. Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 2 +- drivers/mmc/core/mmc_ops.c | 4 +++- drivers/mmc/core/mmc_ops.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 88f4c215caa6..1b5576048cdb 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1630,7 +1630,7 @@ static int mmc_blk_fix_state(struct mmc_card *card, struct request *req) mmc_blk_send_stop(card, timeout); - err = card_busy_detect(card, timeout, NULL); + err = mmc_poll_for_busy(card, timeout, false, MMC_BUSY_IO); mmc_retune_release(card->host); diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 973756ed4016..e2c431c0ce5d 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -435,7 +435,7 @@ static int mmc_busy_cb(void *cb_data, bool *busy) u32 status = 0; int err; - if (host->ops->card_busy) { + if (data->busy_cmd != MMC_BUSY_IO && host->ops->card_busy) { *busy = host->ops->card_busy(host); return 0; } @@ -457,6 +457,7 @@ static int mmc_busy_cb(void *cb_data, bool *busy) break; case MMC_BUSY_HPI: case MMC_BUSY_EXTR_SINGLE: + case MMC_BUSY_IO: break; default: err = -EINVAL; @@ -521,6 +522,7 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, return __mmc_poll_for_busy(card, timeout_ms, &mmc_busy_cb, &cb_data); } +EXPORT_SYMBOL_GPL(mmc_poll_for_busy); bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd, unsigned int timeout_ms) diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index 41ab4f573a31..ae25ffc2e870 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -15,6 +15,7 @@ enum mmc_busy_cmd { MMC_BUSY_ERASE, MMC_BUSY_HPI, MMC_BUSY_EXTR_SINGLE, + MMC_BUSY_IO, }; struct mmc_host;