From patchwork Tue Feb 4 08:54:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183065 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5064349ile; Tue, 4 Feb 2020 00:55:23 -0800 (PST) X-Received: by 2002:a19:740a:: with SMTP id v10mr14048451lfe.65.1580806522803; Tue, 04 Feb 2020 00:55:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580806522; cv=none; d=google.com; s=arc-20160816; b=QMq4cmhc8Q9IQXzRuQZ0iDd5nrd0V8sNdr/Oi3rshmtiCcOssolsQslFlHZBivGIzm u5iftbD+BR022VCNRdyaO39MohRlTucKg/OTn1M5Yj1G+5uIZ7BPX+P4znf5TycGD/Ad /3+DEYVV3L6Bc57sgkCm1nHjVn12luJR0Mw3+kEVaGYYpnSUohG414gqEmmdwHqaVC5P s0DfU/uzyMMxcyvVEgHF1OX26sRV37tqWaXatploQURXJeZd63xT/+xXqdXdQG6fKxf6 wmgO3L5HzJ/0QqY//VLAQDUF1+2AJugruhZk1w703PzANh0dPlBSENwMJNaNSKCyfKK4 fJJg== 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=4MoUz8e+cau8Xa7ChnTAxFphu0xbbPqaxCnfeEAChL0=; b=m6vFZFXiv7YyQSrho40UhSGrYjCCgyW0nXnH434tBg/V90GMknvDWm47tT86nTGU3w oCr2xcQGCTYzS1Ej81FYMH/4roGfIq2QIRyHhVQPyWf94LKttaJr3jFseuYeylzv3VZz LteHC2Q20wJkNjYQb3NFOzSe4Oi9GQaTKlkJT55mhT5hvCdGY5d+HVJdaeHmggmLzMNr bOvIgCSDVCoWdpHss/H9uLzA79Hb/pVF6cb3bx5blDyFy8LiBD5bo31nIMAnnBBtKZgS o0GMNT2T4MWBcgy8LODGsyBrbsgg0R1ErG3e+6Ihg3XiNeXa3uQmmeLLCe//z6ExC/Ut mlpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eHizTPsn; 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 r2sor5311212lfi.66.2020.02.04.00.55.22 for (Google Transport Security); Tue, 04 Feb 2020 00:55:22 -0800 (PST) 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=eHizTPsn; 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=4MoUz8e+cau8Xa7ChnTAxFphu0xbbPqaxCnfeEAChL0=; b=eHizTPsnr1OuaxkljuFvA0GqC4CKdaPoYVpAxKqjyXiKJbjxcsyGVaNmHuM/aCVmSj 8EpJotdRKkCcFIiiwxWwQEVFid2SGGI8FeToEKXasAmZvM19XrNlHcTHEUEVTAvDDX30 OaAG+WFqy8A78zqMAMSUBu3WBPMtn4Zw7Rscsy1Am2ueocR/OTfm8LNiEUBXY4uEGFQO BSTJno3fdP37LAIHlZsyBvFHVmihFR9Mpx1u7HF5gh85DJMA481xbRUs895qlrsqAfei aRIQICJcNDcIrZCTifg3GSoc1NKyz//SRTsxcUXBEXpnIrxhIh2LyfODwRRbvTjuUTG0 x6bA== 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=4MoUz8e+cau8Xa7ChnTAxFphu0xbbPqaxCnfeEAChL0=; b=c7wCEjax0/VKDL9yq9W3Q2LJduYDXQEmuKv5ZNtD1nFWG9vD8uG0exOnNvPDXFxNpX VZS40Ajg4ijuaCGckEYTgCWn1vB3j3v5snaSnkQarjwtXsFAJpm2ftB5G4HtSoJmhMvW L338J8fTizadQb3ZelpBG6PIDwxraKtJ6YC2d72Wzbopxeb2Q3iLLxX2dbi4UjeXXHlY wSrwWpykTRjFYMuwnRuNkq9wM9F2+iqDLRJeI06tDri5CTTevST6Jq9eoLPGs1Ic0fNI fS8gAs37jutjUxlst0NsGaErqh/cyjAj6aMS5dilNgykDM6QGPMC+4doGvUti64MTUSX uFRA== X-Gm-Message-State: APjAAAXNrX43hEeUijPEgPX3EVH7dTDlrYs3pBKJW5hDT25Q74MHeuhw EQ9T+QjTD74+P/ykz8G8sEVmG3+H X-Google-Smtp-Source: APXvYqycLBF/cQ1QLZbuX0A3oqIaEhvd983hPS/2XotETjrWa0tuCjLI/wsSJfbiArTwQtN+brBGyw== X-Received: by 2002:ac2:485c:: with SMTP id 28mr14319585lfy.118.1580806522261; Tue, 04 Feb 2020 00:55:22 -0800 (PST) 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 n2sm11156283ljj.1.2020.02.04.00.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 00:55:21 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Wolfram Sang , Ludovic Barre , Baolin Wang , Linus Walleij , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl Subject: [PATCH 10/12] mmc: core: Convert to mmc_poll_for_busy() for HPI commands Date: Tue, 4 Feb 2020 09:54:47 +0100 Message-Id: <20200204085449.32585-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204085449.32585-1-ulf.hansson@linaro.org> References: <20200204085449.32585-1-ulf.hansson@linaro.org> Rather than open coding the polling loop in mmc_interrupt_hpi(), let's convert to use mmc_poll_for_busy(). Note that, moving to mmc_poll_for_busy() for HPI also improves the behaviour according to below. - Adds support for polling via the optional ->card_busy() host ops. - Require R1_READY_FOR_DATA to be set in the CMD13 response before exiting the polling loop. - Adds a throttling mechanism to avoid CPU hogging when polling. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 20 +++++--------------- drivers/mmc/core/mmc_ops.h | 1 + 2 files changed, 6 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 4d8f90d01740..87d54a559b31 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -471,6 +471,8 @@ static int mmc_busy_status(struct mmc_card *card, bool retry_crc_err, case MMC_BUSY_ERASE: err = R1_STATUS(status) ? -EIO : 0; break; + case MMC_BUSY_HPI: + break; default: err = -EINVAL; } @@ -829,6 +831,7 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width) static int mmc_send_hpi_cmd(struct mmc_card *card) { + unsigned int busy_timeout_ms = card->ext_csd.out_of_int_time; struct mmc_command cmd = {}; unsigned int opcode; int err; @@ -850,7 +853,8 @@ static int mmc_send_hpi_cmd(struct mmc_card *card) return err; } - return 0; + /* Let's poll to find out when the HPI request completes. */ + return mmc_poll_for_busy(card, busy_timeout_ms, MMC_BUSY_HPI); } /** @@ -864,7 +868,6 @@ int mmc_interrupt_hpi(struct mmc_card *card) { int err; u32 status; - unsigned long prg_wait; if (!card->ext_csd.hpi_en) { pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host)); @@ -898,19 +901,6 @@ int mmc_interrupt_hpi(struct mmc_card *card) } err = mmc_send_hpi_cmd(card); - if (err) - goto out; - - prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time); - do { - err = mmc_send_status(card, &status); - - if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN) - break; - if (time_after(jiffies, prg_wait)) - err = -ETIMEDOUT; - } while (!err); - out: return err; } diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index 8cd05fb583da..38dcfeeaf6d5 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -13,6 +13,7 @@ enum mmc_busy_cmd { MMC_BUSY_CMD6, MMC_BUSY_ERASE, + MMC_BUSY_HPI, }; struct mmc_host;