From patchwork Tue Apr 14 16:14:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185414 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1601784ilf; Tue, 14 Apr 2020 09:14:39 -0700 (PDT) X-Received: by 2002:a19:5217:: with SMTP id m23mr361872lfb.202.1586880878877; Tue, 14 Apr 2020 09:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586880878; cv=none; d=google.com; s=arc-20160816; b=Q2i9ejub5EQvfcyZyQLbkwmfE2yeLpqYAgP2cMtXRIJdQl2Qww3TsOoNynsSfKjKIf PzaH5v/XebChtwGS+lHw0vVuUBChLTm4O3k8QOcycQWLPQ11VUVyINOcpcWdQ0jlBT0B x8DtqhV6qlVkadLI6Cmm+xKA2jpBicxkQEwZ4kIZ6eMSk6VPYMNERts0oWi8AQRV4eoB fmFa+gCo99U20eW3doESptjnkjvv/Y4iLDcLlxGGZd2J/9/UQnkpBdnvqjlbCDDLxtfy fxZKuuWWtShxsjX1iNbwaJ9caLO5xNGc3rvsyws8+iyM4i+4v0tJPSOTmKaJwhsYpa3a uHqg== 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=Dl5IYIZsM+xCsV4Ecpy9SUMpLQO9Iofc7JQPlPyzfk4=; b=RCp/JFYYg4Nx2pdD3dre1P0xlFQDyvxbJnnUymqGPJmRqEMrQqQKoNY2uSH/KkVTsi mUd3HL7Vz80QxpslCDrb37mR2PdpCUCeQ6pGej9T2m6brtQtXXK2nA7FE6lIM8cZpFZo WhC5VBW02PN+aDWI8QBNwiCiH/35oogMwNlx0cQG0L21nyTBj9JZGpt0I4cuK88g0Yfq OHbIkh9FpP3ORTY2veylILRsjyjWLChS95jPH5ZyF19zZkjfO12u//wiyq5A59JPxUpE Eh5cVVNJm0qDHymiVcBBymmPp5Vh5SJFQ4pA0b0SRfircKVxOL/PVZy5qVHLar1oh+tI W0/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DryjMEKr; 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 t9sor7834371ljc.45.2020.04.14.09.14.38 for (Google Transport Security); Tue, 14 Apr 2020 09:14:38 -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=DryjMEKr; 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 :mime-version:content-transfer-encoding; bh=Dl5IYIZsM+xCsV4Ecpy9SUMpLQO9Iofc7JQPlPyzfk4=; b=DryjMEKrVO5cGSgi2YFVMImFkP1YSPCxmWdaNk+r4GvhQkI/mnECJV5s3T9HjkHZlG bJZPSKCUL9mZno5IxN3xnEZhzAks9v4jyto1e6ZQos13mqoLpDdSTZbpixnpdo8QU99v O7HFKT6wTQFvuv9CrIONrD5U+5KNUAP+tLexQyZfqrR3GgC0PN2YUn0ho4cmf6O9Cabe uiNuknLBHu1mgjFhwwGYWppr/vwlgxpBKbuKoGiKP51hoo3gOycSfrD3yrSmETTIv/Zu moyijH48Y0Hkhh53qyoRYZjZv6GE10R240TStiZ4mUfcxTZMctCBRgMUje93aoxMsU90 b7Aw== 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=Dl5IYIZsM+xCsV4Ecpy9SUMpLQO9Iofc7JQPlPyzfk4=; b=Wjk7nhsJfJvn86e1MUhE0Eggr6Xpm/V26lP6hH8Hedh2s1K3nvfpmsfV0uKFmwXDwv 0Cl3JLwl7uabA2/xVog8rJN4MpeA8PSchmD36t84mW8iWY938oHCSRkSsTGISxccdJRO twtmytmcDOYmC7YzzAS8jdQxIebfM90sx2YfJdQz//mrrDeg0kpqq4/qu+o6i8jElUrG oQQijrH4fC4o7xIlOZyIwnLO/MF5Z2uQe2QUdVt5EwIA4tdOcq5cj9kiiuF68t614d3s jdzyhVChebBVKK8meys1uS1dEEG5/cpxGlYuz1oNjb6Iri81+MDujEO4zixJp9/b5fiH xjIg== X-Gm-Message-State: AGi0PuabIjblk13pkklqASDPHYxw4frW+fVWql++7/k4AhQheIKICZ5F eO4pwZadX1Cs4sJjZqCCAV0xd7Xr X-Google-Smtp-Source: APiQypICI5S6iE4gdXMXAr+FOW4UXprBZW6+RBHUTF9xmN/eKtOI8iHHcHKeYxC0pVba8L5j8x8u0Q== X-Received: by 2002:a2e:b8c7:: with SMTP id s7mr582589ljp.212.1586880878482; Tue, 14 Apr 2020 09:14:38 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-131.NA.cust.bahnhof.se. [98.128.181.131]) by smtp.gmail.com with ESMTPSA id a26sm9330669ljn.22.2020.04.14.09.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 09:14:37 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Linus Walleij , Rui Miguel Silva , Johan Hovold , Alex Elder , Greg Kroah-Hartman , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Bruce Chang , Harald Welte , Alex Dubov , Sascha Sommer , Manivannan Sadhasivam , mirq-linux@rere.qmqm.pl, Jesper Nilsson , Lars Persson , Paul Cercueil , Ludovic Desroches , Nicolas Ferre Subject: [PATCH 12/19] mmc: sdricoh_cs: Throttle polling rate for data transfers Date: Tue, 14 Apr 2020 18:14:06 +0200 Message-Id: <20200414161413.3036-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414161413.3036-1-ulf.hansson@linaro.org> References: <20200414161413.3036-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Rather than to poll in a busy-loop, let's convert into using readl_poll_timeout() and insert a small delay between each polling attempts. In particular, this avoids hogging the CPU. Additionally, to convert to readl_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 --- drivers/mmc/host/sdricoh_cs.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 97ef7d71375a..7e407fb6dab8 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,23 @@ 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 = readl_poll_timeout(host->iobase + R21C_STATUS, status, + sdricoh_status_ok(host, status, wanted), + 32, SDRICOH_DATA_TIMEOUT_US); + if (ret) { dev_err(dev, "query_status: timeout waiting for %x\n", wanted); return -ETIMEDOUT; }