From: Takashi Iwai <tiwai-l3A5Bk7waGM@public.gmane.org>
To: Dylan Reid <dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org
Subject: Re: [alsa-devel] [PATCH] ASoC: tegra: Use flat regcache.
Date: Tue, 18 Mar 2014 07:46:09 +0100 [thread overview]
Message-ID: <s5hha6wdmxa.wl%tiwai@suse.de> (raw)
In-Reply-To: <1395115139-22243-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
At Mon, 17 Mar 2014 20:58:59 -0700,
Dylan Reid wrote:
>
> When using an rbtree cache, there can be allocations the first time a
> register is accessed. This can cause an attempt to schedule while
> atomic in the case that the regmap is using a spinlock. This could be
> fixed by either initializing all the registers or using a flat cache.
> The register maps for tegra30_ahub and tegra30_i2s are dense and don't
> save much from using a tree so convert them to flat.
>
> Signed-off-by: Dylan Reid <dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Looking through regmap code, the fast_io lock seems broken in more
places, not only via rbtree cache access. regmap_bulk_write() calls
kmemdup() with GFP_KERNEL in the lock context. Ditto in
regmap_register_patch(), which calls krealloc() with GFP_KERNEL.
The former could be fixed by moving the lock like below. The fix for
the latter depends on whether we need to protect map->patch_regs
growth from races or not. If not, krealloc() can be moved out of the
lock.
Takashi
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 4b2ed0c9e80d..2a1d43e23f1f 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1520,12 +1520,12 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
if (reg % map->reg_stride)
return -EINVAL;
- map->lock(map->lock_arg);
/*
* Some devices don't support bulk write, for
* them we have a series of single write operations.
*/
if (!map->bus || map->use_single_rw) {
+ map->lock(map->lock_arg);
for (i = 0; i < val_count; i++) {
unsigned int ival;
@@ -1554,24 +1554,25 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
if (ret != 0)
goto out;
}
+ out:
+ map->unlock(map->lock_arg);
} else {
void *wval;
wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL);
if (!wval) {
- ret = -ENOMEM;
dev_err(map->dev, "Error in memory allocation\n");
- goto out;
+ return -ENOMEM;
}
+ map->lock(map->lock_arg);
for (i = 0; i < val_count * val_bytes; i += val_bytes)
map->format.parse_inplace(wval + i);
ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count);
+ map->unlock(map->lock_arg);
kfree(wval);
}
-out:
- map->unlock(map->lock_arg);
return ret;
}
EXPORT_SYMBOL_GPL(regmap_bulk_write);
next prev parent reply other threads:[~2014-03-18 6:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 3:58 [PATCH] ASoC: tegra: Use flat regcache Dylan Reid
[not found] ` <1395115139-22243-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2014-03-18 4:07 ` Andrew Bresticker
2014-03-18 5:04 ` Dylan Reid
2014-03-18 6:46 ` Takashi Iwai [this message]
[not found] ` <s5hha6wdmxa.wl%tiwai-l3A5Bk7waGM@public.gmane.org>
2014-03-18 10:28 ` [alsa-devel] " Mark Brown
[not found] ` <20140318102858.GE11706-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-03-18 10:33 ` Takashi Iwai
2014-03-18 10:39 ` Lars-Peter Clausen
[not found] ` <53282262.2030300-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2014-03-18 10:44 ` [alsa-devel] " Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hha6wdmxa.wl%tiwai@suse.de \
--to=tiwai-l3a5bk7wagm@public.gmane.org \
--cc=abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox