From f816fccd598dfc32dd680a69a9a3391869792559 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 21 Nov 2012 13:12:11 +0900 Subject: [PATCH] --- yaml --- r: 347079 b: refs/heads/master c: 31f313d9bebfc17e48c787c8c36b38662b4134a1 h: refs/heads/master i: 347077: 257b51b83ec57f597528969b96eaf50257fdd27b 347075: 44f99c3ac4ded1518976d89aacf121d187c3f695 347071: d2e2e6deb94ed046439d27bcefb65b47f0e0d6b8 v: v3 --- [refs] | 2 +- trunk/drivers/i2c/busses/i2c-s3c2410.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 67ef9a88d174..e46ed6e59398 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c5d5474425c4e7e291a98e739ea65f8acd0d8d5c +refs/heads/master: 31f313d9bebfc17e48c787c8c36b38662b4134a1 diff --git a/trunk/drivers/i2c/busses/i2c-s3c2410.c b/trunk/drivers/i2c/busses/i2c-s3c2410.c index d784c76ae3e8..e93e7d672773 100644 --- a/trunk/drivers/i2c/busses/i2c-s3c2410.c +++ b/trunk/drivers/i2c/busses/i2c-s3c2410.c @@ -554,6 +554,7 @@ static void s3c24xx_i2c_wait_idle(struct s3c24xx_i2c *i2c) unsigned long iicstat; ktime_t start, now; unsigned long delay; + int spins; /* ensure the stop has been through the bus */ @@ -566,12 +567,23 @@ static void s3c24xx_i2c_wait_idle(struct s3c24xx_i2c *i2c) * end of a transaction. However, really slow i2c devices can stretch * the clock, delaying STOP generation. * - * As a compromise between idle detection latency for the normal, fast - * case, and system load in the slow device case, use an exponential - * back off in the polling loop, up to 1/10th of the total timeout, - * then continue to poll at a constant rate up to the timeout. + * On slower SoCs this typically happens within a very small number of + * instructions so busy wait briefly to avoid scheduling overhead. */ + spins = 3; iicstat = readl(i2c->regs + S3C2410_IICSTAT); + while ((iicstat & S3C2410_IICSTAT_START) && --spins) { + cpu_relax(); + iicstat = readl(i2c->regs + S3C2410_IICSTAT); + } + + /* + * If we do get an appreciable delay as a compromise between idle + * detection latency for the normal, fast case, and system load in the + * slow device case, use an exponential back off in the polling loop, + * up to 1/10th of the total timeout, then continue to poll at a + * constant rate up to the timeout. + */ delay = 1; while ((iicstat & S3C2410_IICSTAT_START) && ktime_us_delta(now, start) < S3C2410_IDLE_TIMEOUT) {