mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-04 05:37:36 +00:00
mmc: sdricoh_cs: Throttle polling rate for data transfers
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 <saschasommer@freenet.de> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20200508095210.14123-1-ulf.hansson@linaro.org
This commit is contained in:
parent
85a3f77c1b
commit
eadb789765
1 changed files with 15 additions and 11 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
#include <pcmcia/cistpl.h>
|
||||
|
@ -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 int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted)
|
||||
static bool sdricoh_status_ok(struct sdricoh_host *host, unsigned int status,
|
||||
unsigned int wanted)
|
||||
{
|
||||
unsigned int loop;
|
||||
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;
|
||||
return status & wanted;
|
||||
}
|
||||
|
||||
if (loop == timeout) {
|
||||
static int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted)
|
||||
{
|
||||
int ret;
|
||||
unsigned int status = 0;
|
||||
struct device *dev = host->dev;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue