From patchwork Fri May 8 09:52:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186319 Delivered-To: patches@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp4001720ill; Fri, 8 May 2020 02:52:15 -0700 (PDT) X-Received: by 2002:a2e:a417:: with SMTP id p23mr1215397ljn.19.1588931535763; Fri, 08 May 2020 02:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588931535; cv=none; d=google.com; s=arc-20160816; b=wcuWlgmHA6KB1uL9o7MFHKxrFMGYeG1zyOWEmYs3W+iJOKby6V/EL9sLyDgnmSFPzO KVoppfL3sEY3ZmnWadtET/4zeFsce8wv+/cakftbS3iTgO8o5yeMwhwf+EIUPclP9oIM VIB/0zAyDjwQga8t0DGeVzZhp95A+gCkaP29jU8STM4GGFhYKZ/nKfgBg6r2adb55dm3 i/pQA4oqsbL+4ho2uZPMtuLqDhzqyU0f7z0JWChgAG2iSPNfqaTlZ2Fubz1KHg3RUIIr db2h75VWYGBa69Br701AM7x+V7dBd9sf8KXtoZmIxDYDum0MyJkj91r8VhNvGz1tF8s9 w3GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=Kj0gLXRuliK3KdID/M87B7g/98tNYDKPX2QUn3XOTQs=; b=pWJzXuSzU2xfkbs63Mf6KIQGfANumPvEhb4LIBR3W4q0rr110finEMdeXGABvelU+D xRmq2an7R9rHamXO4YpAQxMiqAtXGQ4A/sZpNMdwAKeLOM/0AowBc99u5pZY2H9imNId KuslWLWF/LfyZPDsnSHHDq2kX/7iHnqtFwkZdBj7W6CE2isHQV/zKV38GfUM7q8UCPVv Ww2lvGbe1X78PjB5B1JNZwH59/uuKC3gOOc11iSyqJ2BwRZnLEDsqAWSLrl8Gl6Rub4+ N2/TmbWhcyGvQ+8qgvhEN8lcoIqAlXigmH3lQTMbkmonhFl5bxTFUZ2avll9q3/QdeOl FOSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OZhK7txA; 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 o6sor751233lja.22.2020.05.08.02.52.15 for (Google Transport Security); Fri, 08 May 2020 02:52:15 -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=OZhK7txA; 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:mime-version :content-transfer-encoding; bh=Kj0gLXRuliK3KdID/M87B7g/98tNYDKPX2QUn3XOTQs=; b=OZhK7txAGLD+FSfIpWbIoCZ0NEyJBgp/BtS++3PsuU1LgWgEHgTWM4a3k4nF2Q6Yw7 oYFe1+dnKTQNn7bUOSbVdXydIta7K+DEKKgIVrH719Fx3KeUR4rGn/+8B8wHr/nIxxxd aE7L8xJHuwYiJcOeHPhLL+5Z1IcpW/5Neuz/e3sF7pIENLRs6Xot5alcb5mjxHJilxiW UAfuBKJgGZH/+6nEGSp4gCImy1IwFnUJwqjLEtTEJXCvrwYyjSSNo8dl0hX6gG0AASpD gkjdyK29xioHXidw1lt6uK1jR3KWISfPCN1HkxggdzBzQ1rpLnnFSNUm+37GBd1ZDuQk vzyg== 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:mime-version :content-transfer-encoding; bh=Kj0gLXRuliK3KdID/M87B7g/98tNYDKPX2QUn3XOTQs=; b=KIlk9JZCAMlzyrn1tkIogYC5EPRXi+6jBj+DQks8bn/mrCqkKV4Gor80bgtadWi/h1 rBG1Xq6t2fDo79e9TcRSS/r2Uhle2+a5pKZA6gRAb/TrYPgIlcuUjCUYQN1Ptn7kr4lX CQlQcmQBsn/54YNMXd2MELzWfwKHY+vNzi3Z1T1RG9+C9nhK3Q3DmX7eCnd1caZfS3Hp 3pzQR5wiaC0wk/VVYigfq6lY8gus+O67on0WLy5VquFL3s3xGVqsfcKlOvQPnSOMzsmt zRDWm11G2blamrEj0YQCWVQXfKtr0S67TFulW6m2M9NQhk6imqkz29ou4yu50BzLeQWo 1gWQ== X-Gm-Message-State: AOAM5316xvIZ+sajMoCf6/JrRSW2vmorUh/0QjiUw/t4l0aQlNbgsYN+ LbHMJes8znTwUyPomiBckmDXW8dp X-Google-Smtp-Source: ABdhPJwKJB8uOVbN/pIbEuDd4HOoQ+C6BSyPbgNfn+VuvpOjHLllMfAT7oWr8g3IVoR3TkCia0SmRQ== X-Received: by 2002:a2e:2c11:: with SMTP id s17mr1136801ljs.119.1588931535130; Fri, 08 May 2020 02:52:15 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id x24sm804019lji.52.2020.05.08.02.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 02:52:13 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Sascha Sommer Subject: [PATCH v2 12/19] mmc: sdricoh_cs: Throttle polling rate for data transfers Date: Fri, 8 May 2020 11:52:10 +0200 Message-Id: <20200508095210.14123-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Rather than to poll in a busy-loop, let's convert into using read_poll_timeout() and insert a small delay between each polling attempts. In particular, this avoids hogging the CPU. Additionally, to convert to read_poll_timeout() we also need to switch from using a specific number of polling attempts, into a specific timeout in us instead. The previous 100000 attempts, is translated into a total timeout of total 1s, as that seemed like reasonable value to pick. Cc: Sascha Sommer Signed-off-by: Ulf Hansson --- Changes in v2: - Use read_poll_timeout() instead of readl_poll_timeout(), as to preserve the debug print in sdricoh_readl(). --- drivers/mmc/host/sdricoh_cs.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 97ef7d71375a..8392158e2e9f 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -59,7 +60,7 @@ static unsigned int switchlocked; /* timeouts */ #define CMD_TIMEOUT 100000 -#define TRANSFER_TIMEOUT 100000 +#define SDRICOH_DATA_TIMEOUT_US 1000000 /* list of supported pcmcia devices */ static const struct pcmcia_device_id pcmcia_ids[] = { @@ -123,21 +124,24 @@ static inline unsigned int sdricoh_readb(struct sdricoh_host *host, return value; } +static bool sdricoh_status_ok(struct sdricoh_host *host, unsigned int status, + unsigned int wanted) +{ + sdricoh_writel(host, R2E4_STATUS_RESP, status); + return status & wanted; +} + static int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted) { - unsigned int loop; + int ret; unsigned int status = 0; - unsigned int timeout = TRANSFER_TIMEOUT; struct device *dev = host->dev; - for (loop = 0; loop < timeout; loop++) { - status = sdricoh_readl(host, R21C_STATUS); - sdricoh_writel(host, R2E4_STATUS_RESP, status); - if (status & wanted) - break; - } - - if (loop == timeout) { + ret = read_poll_timeout(sdricoh_readl, status, + sdricoh_status_ok(host, status, wanted), + 32, SDRICOH_DATA_TIMEOUT_US, false, + host, R21C_STATUS); + if (ret) { dev_err(dev, "query_status: timeout waiting for %x\n", wanted); return -ETIMEDOUT; } From patchwork Fri May 8 09:52:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186320 Delivered-To: patches@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp4001796ill; Fri, 8 May 2020 02:52:23 -0700 (PDT) X-Received: by 2002:a05:651c:1055:: with SMTP id x21mr1118492ljm.210.1588931542914; Fri, 08 May 2020 02:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588931542; cv=none; d=google.com; s=arc-20160816; b=YGT8lRUko0e4jYyQj7GWN6GKwcF4Zlkyj7J71amLtswg/aHFDqH9GgyvriAszVN1oX 2bl5ZLY+j45SU0nJf7mx9+dYV2ThXhHiz/26fTe08or9phgycjZm5+HdkRWOCXJ+vQXq VgKNEbRsvKJ7Dq5CrYnesEkllAcFAL78o07xT+n7gp/J+KbAqSqOp97rRKk1DiYXt1Ih M0dwl9ejLtKR7Ljawt134cKr5EZFBNrYJbL2Tli72J47Z2HYnbaRLYz3Mk1nxYHDBfGE MUKKJZqgXuPoSFoZQTm81Q8djhvktho3e/As1cAOWKFnp0zvh4ktLveJA6607W9S1cIg A9Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=oGYd9AQdlcl1pmEoCpIEqwK9BJV8M5Www8GEN3oe3Ig=; b=r10CpaCHyu2/FowBlE8WnzdIzZ5+fDxMDq+RmtpnpJyruiGLfPsGnTRDwCKfILS29/ J1YL4jyy+kbHHfMscusYkDDgm3jlQs0ip/t65NZXgXS0MvfjGMkRoA675Gq+4lMck0WW 1AV4X8gE8uXZ1BYleESVA1g+IXQFisKDnG7NaOdQV7vHd6ZZeHSqWxvyGzeXdAaxzOeQ AH5r2sK/ZiExFKtAKi/ehha0CYJovtvNKCaKOeYcLyvUeoXbH2TvXK5QDItmd1Ly4Tw3 gVLW8Jsjs+TJD0PIjuIwQosfXMXvamuma0zgoMyGwS9q040F1VIY9xctrkvGWrXCduO2 CRHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NMJTr4se; 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 c20sor735214ljd.44.2020.05.08.02.52.22 for (Google Transport Security); Fri, 08 May 2020 02:52:22 -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=NMJTr4se; 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:mime-version :content-transfer-encoding; bh=oGYd9AQdlcl1pmEoCpIEqwK9BJV8M5Www8GEN3oe3Ig=; b=NMJTr4seavNIw4MU48DBNqlL2h3DmB9iiou0clJEgkDlBHjlexF0pA4JwH2dtezgNj qzN5yqpjoYCuEklNGZun92vnduKttdI8mQVj3zygoS4PsCBZfuddQxgJUriLuVnPSWG4 gOKf+WINBzHRjlC28YLZ+J5tnTeD4bTVTrolmIiLwbloDsAmjoJQ/DimqFjOLrARIGe/ qKhE13cy5BM32+8URt2LgIN69y14RjRB1evcfBPSHtBBf3fXUUqYxv8i0AYmywFPFqbt Z0BfwYaX/LMeQ8dpNEvX5wf/sSFijmpkFM4/OV7GRED8Zx+fx9tTp0UcaS34EPBV5LQu PWSg== 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:mime-version :content-transfer-encoding; bh=oGYd9AQdlcl1pmEoCpIEqwK9BJV8M5Www8GEN3oe3Ig=; b=he7wKwbiSERWWSYmBgaVdeL4l2wjNPu2AeVtfyjuD4uqcbsitTlW02uTGsRIZpKAyd fEDvG/i92J5vjBqn57wbqmTJlwENfAXyaUMkytnIpd5b3YYrHdMSWDddVkrTdxU7agzV ZWmmx8/ZQnWXivA9mzQmopPTtv0W+MUWG6XzyvDjl0LYx1T2ErPBXoDY853VN9cyOQZd ZJrJPiE+1xG/U4Wbj6gMxV3mtnK2c0rm3iw2JWqrtHNFaaCpge8RRnmmFD5EU6fBoJ/r xYQoEvd/f5PqKPGcgh0C+nGHid7ATlXl7yI4UsLuziTcMHN9j1YhQZVM48uWRXM56MPT AvnA== X-Gm-Message-State: AOAM530uZppLZBefaI04VUITutORxXfJ2kM1Wp1lyV9EUTABhYpbeCWc spPitVUo+DPGlKBB6UyUbBqt82vaktcB2g== X-Google-Smtp-Source: ABdhPJwCCb++sgF0Td/juhrOMNNZRkLd9l8oaoFT7HL2UEXXsKf8Y5+u0M/vD6BBBablFsIbR883Cw== X-Received: by 2002:a2e:8017:: with SMTP id j23mr1094276ljg.22.1588931542491; Fri, 08 May 2020 02:52:22 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id j29sm902171lfp.90.2020.05.08.02.52.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 02:52:21 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Sascha Sommer Subject: [PATCH v2 13/19] mmc: sdricoh_cs: Throttle polling rate for commands Date: Fri, 8 May 2020 11:52:18 +0200 Message-Id: <20200508095218.14177-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Rather than to poll in a busy-loop, let's convert into using read_poll_timeout() and insert a small delay between each polling attempts. In particular, this avoids hogging the CPU. Additionally, to convert to read_poll_timeout() we also need to switch from using a specific number of polling attempts, into a specific timeout in us instead. The previous 100000 attempts, is translated into a total timeout of total 1s, as that seemed like reasonable value to pick. Cc: Sascha Sommer Signed-off-by: Ulf Hansson --- Changes in v2: - Use read_poll_timeout() instead of readl_poll_timeout(), as to preserve the debug print in sdricoh_readl(). --- drivers/mmc/host/sdricoh_cs.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 8392158e2e9f..0594b5ffe151 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c @@ -59,7 +59,7 @@ static unsigned int switchlocked; #define STATUS_BUSY 0x40000000 /* timeouts */ -#define CMD_TIMEOUT 100000 +#define SDRICOH_CMD_TIMEOUT_US 1000000 #define SDRICOH_DATA_TIMEOUT_US 1000000 /* list of supported pcmcia devices */ @@ -158,8 +158,7 @@ static int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted) static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd) { unsigned int status; - int result = 0; - unsigned int loop = 0; + int ret; unsigned char opcode = cmd->opcode; /* reset status reg? */ @@ -175,24 +174,24 @@ static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd) /* fill parameters */ sdricoh_writel(host, R204_CMD_ARG, cmd->arg); sdricoh_writel(host, R200_CMD, (0x10000 << 8) | opcode); + /* wait for command completion */ - if (opcode) { - for (loop = 0; loop < CMD_TIMEOUT; loop++) { - status = sdricoh_readl(host, R21C_STATUS); - sdricoh_writel(host, R2E4_STATUS_RESP, status); - if (status & STATUS_CMD_FINISHED) - break; - } - /* don't check for timeout in the loop it is not always - reset correctly - */ - if (loop == CMD_TIMEOUT || status & STATUS_CMD_TIMEOUT) - result = -ETIMEDOUT; + if (!opcode) + return 0; - } + ret = read_poll_timeout(sdricoh_readl, status, + sdricoh_status_ok(host, status, STATUS_CMD_FINISHED), + 32, SDRICOH_CMD_TIMEOUT_US, false, + host, R21C_STATUS); - return result; + /* + * Don't check for timeout status in the loop, as it's not always reset + * correctly. + */ + if (ret || status & STATUS_CMD_TIMEOUT) + return -ETIMEDOUT; + return 0; } static int sdricoh_reset(struct sdricoh_host *host) From patchwork Fri May 8 09:52:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186321 Delivered-To: patches@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp4001887ill; Fri, 8 May 2020 02:52:32 -0700 (PDT) X-Received: by 2002:a2e:b4c2:: with SMTP id r2mr1173228ljm.143.1588931552376; Fri, 08 May 2020 02:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588931552; cv=none; d=google.com; s=arc-20160816; b=kFtP/xb0F1ZfERhXtB9X2YoHTJUs6nxVg1JgHhpToohK4slgxUA62Gvdx0Qz3s80l/ 78kwOYecbqau6DSFHzuMhdwQDol1YomWz+Y2/awMR4Zv2uZs04m0lIwJYFXVoxZx5aen ydetrw40GnntrpwPoNqq/UVC8SBGcmjNTv/osbynEEHBPsM8FvwyW6PBrljJmcCgrTmu bFc6QKkXocW0HYRzwpT3qbLAAmz3qemmNKAzCspv5K+XVwLRqHp3NYgD/HaQTHbegvQv jamGI0rb0kIOjnz+YFIISt5i94an3ZME44pHyHKMlyF1LVxp8E1FCH27BgEeoAjHIeVt 8yHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=4TJAm+9iRwtFh5TlrP2asksTQquFny7nfEfVBEpyuw8=; b=HwkLVb0MyILgdB024UvUaFiK72KdqdlTW0CBamRyWzFZHtkulPfdAlAoHGXEboW526 5klyYOtYqV8Qw76QOC0LHi3jvrAhyAPE/h7SbFcfwadb+XdDQ9QmaWfY+z2Ip6KMKFeV X7wU1iT6faAriTQIMdq7b6mgH8CX+vioc3MWDUDoI0vvWtvs6Raq+v70B+AvngGrQset n7julJhNkyOyJUfTlDvVuYqSIDtAXqSpnpK1Am5C5Y6Q8vRy8pQJHw0/cuUpB4r8xikI 4RwrRGxlyUcUaVhwPozuahouaddNXRd30P/CB9yI8ukptTpOkCGKPkJbGLtAkYFoWYJt o7Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c7Msaojw; 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 y14sor758405ljc.1.2020.05.08.02.52.32 for (Google Transport Security); Fri, 08 May 2020 02:52:32 -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=c7Msaojw; 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:mime-version :content-transfer-encoding; bh=4TJAm+9iRwtFh5TlrP2asksTQquFny7nfEfVBEpyuw8=; b=c7Msaojwv00ZdbXSdNCabebkEe++MednrzhUl3DMwXQem1gVAmWmN6Q2nLJorbp0oo AHJ7j0FrtapDVBhPj45nzqgECClW37RbnRtg1jTX/OcmzsmSEYoAEl+22drLA1L38h/F V72ZlJLhZII3/g7z0QeCtuFNM5bpMBiJi8xXUabJ3YBsZPftogdGmZORQ0y4MCHkBqgt 0BbD6E9JThlpsClq+Jyy5nvZ267EmmiZG0NjkYb7w+2rmXVHEZ+A8gpIYbhGCIuwZWrG qgesNSFmDk3tKa2qEGz174wyq8J1IDrzJ6ZfrvylCTxSzA02+39gPvP+SxHgutYYJ7ek 9p7Q== 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:mime-version :content-transfer-encoding; bh=4TJAm+9iRwtFh5TlrP2asksTQquFny7nfEfVBEpyuw8=; b=Km7KxEkMBcgmp6HrLMTwmr39pF59yqnSzgcKGiN35lvMEvww9VxM5A76n0dj6NKVGS jKUKrQqrfVxLuP7tEZ1O6RQy4Bu6pTpHmToroFvgdCHupTViBgKmsXXRXjRrNu4Ck0pb 6/RN8JZFb80eYBxjECJc7x3DyO5f6EO8Cq/WuGfdUjpIMfZrcObk9YM+3TPMm3EB1J9E mhhYTHenoZ0nrPXx7b7nz9A57sLuU4rrLGEB+G0PXgP26iiADvJEpYyHv9MBbLTWPSr/ QhospJjXjz8eRAiGC0DRKvKZyjAg72WHJ0Ty/NqU9vi/w9x1bBbQg2s4xh+mFSXi9CB7 dWYQ== X-Gm-Message-State: AOAM531NHY8fPFEAC2XQM+vv9pyw/ry/5WmDLqU2RzIEt06eh+W54Hh4 bvC6tiTaHXZv6jArnLGC+B9ITtJC X-Google-Smtp-Source: ABdhPJz4u10vEjx1Wn3f64pWzn2t909DNsFV/HrElxLnIrccwUZtWv9ihIG8S1A1PnzbPDg8o1x6QQ== X-Received: by 2002:a2e:9b0f:: with SMTP id u15mr1146568lji.272.1588931551949; Fri, 08 May 2020 02:52:31 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id t16sm882846lff.72.2020.05.08.02.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 02:52:30 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Sascha Sommer Subject: [PATCH v2 14/19] mmc: sdricoh_cs: Respect the cmd->busy_timeout from the mmc core Date: Fri, 8 May 2020 11:52:28 +0200 Message-Id: <20200508095228.14230-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Using a fixed 1s polling timeout for all commands is a bit problematic. For some commands it means waiting longer than needed for the polling to be aborted, which may not a big issue, but still. For other commands, like for an erase (CMD38) that uses a R1B response, may require longer timeouts than 1s. In these cases, we may end up treating the command as it failed, while it just needed some more time to complete successfully. Fix the problem by respecting the cmd->busy_timeout, which is provided by the mmc core. Note that, even if the sdricoh_cs driver may currently not support HW busy detection on DAT0, some comments in the code refer to that the HW may support it. Therefore, it seems better to be proactive in this case. Cc: Sascha Sommer Signed-off-by: Ulf Hansson --- Changes in v2: - Rebased, no changes. --- drivers/mmc/host/sdricoh_cs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 0594b5ffe151..76a8cd3a186f 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c @@ -157,7 +157,7 @@ static int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted) static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd) { - unsigned int status; + unsigned int status, timeout_us; int ret; unsigned char opcode = cmd->opcode; @@ -179,9 +179,12 @@ static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd) if (!opcode) return 0; + timeout_us = cmd->busy_timeout ? cmd->busy_timeout * 1000 : + SDRICOH_CMD_TIMEOUT_US; + ret = read_poll_timeout(sdricoh_readl, status, sdricoh_status_ok(host, status, STATUS_CMD_FINISHED), - 32, SDRICOH_CMD_TIMEOUT_US, false, + 32, timeout_us, false, host, R21C_STATUS); /*